default appliance: restore some config and users from theDATA volume

This commit is contained in:
Jörg Deckert 2021-03-16 19:20:27 +01:00
parent 955be9cc46
commit 920e63a21f
2 changed files with 43 additions and 1 deletions

View File

@ -39,7 +39,7 @@ $(PAM_SSH_AGENT_AUTH):
touch $(PAM_SSH_AGENT_AUTH)
$(ADMINUSER):
RUN useradd -m -G users,wheel -s /bin/bash --comment="virtual appliance admin" --uid 2000 admin
-RUN useradd -m -G users,wheel -s /bin/bash --comment="virtual appliance admin" --uid 2000 admin
RUN passwd -d admin; $(inroot) passwd -e admin
touch $(ADMINUSER)

View File

@ -33,4 +33,46 @@ if ! mount | grep /$LABEL > /dev/null; then
exit 1
fi
if [ -d "/$LABEL/home" ]; then
cd "/$LABEL/home"
for user in *; do
if [ -d "$user" ]; then
if ! id -u "$user" >/dev/null 2>&1; then
useradd -m -G users,wheel -s /bin/bash --uid $(stat -c '%u' $user) --user-group $user
fi
rm -rf "/home/$user"
ln -nsf "/$LABEL/home/$user" "/home/$user"
fi
done
fi
if [ -d "/$LABEL/etc/ssh" ]; then
rm -rf /etc/ssh
ln -nsf "/$LABEL/etc/ssh" /etc/ssh
systemctl restart sshd
else
mkdir -p "/$LABEL/etc"
mv /etc/ssh "/$LABEL/etc/"
ln -nsf "/$LABEL/etc/ssh" /etc/ssh
fi
if [ -f "/$LABEL/etc/hosts" ]; then
rm -f /etc/hosts
ln -nsf "/$LABEL/etc/hosts" /etc/hosts
else
mkdir -p "/$LABEL/etc"
mv -f /etc/hosts "/$LABEL/etc/hosts"
cp -f "/$LABEL/etc/hosts" "/$LABEL/etc/hosts.orig"
ln -nsf "/$LABEL/etc/hosts" /etc/hosts
fi
if [ -f "/$LABEL/etc/fstab" ]; then
cp -f "/$LABEL/etc/fstab" /etc/fstab
fi
if [ -d "/$LABEL/etc/systemd" ]; then
cp -a "/$LABEL/etc/systemd" /etc/
systemctl daemon-reload
fi
rm /01firstboot