add ssh ecryptfs auto mount

This commit is contained in:
Yann Autissier
2022-04-10 02:21:44 +00:00
parent d328ae3e24
commit e6fe7dcf0c
9 changed files with 133 additions and 39 deletions
+10 -6
View File
@@ -1,4 +1,5 @@
#!/bin/sh
[ -n "${DEBUG}" ] && set -x
### every exit != 0 fails the script
set -eu
@@ -9,8 +10,9 @@ if [ ! -f /app/.setup_done ]; then
/app/setup_timezone.sh
fi
# /home is mounted in RAM and does not survive on restart
/app/setup_ecryptfs.sh
/app/setup_ecryptfs.sh /dev/shm
# /shared encryption will not survive on restart
/app/setup_ecryptfs.sh /shared
/app/setup_users.sh
## Start-up our services manually (since Docker container will not invoke all init scripts).
@@ -24,28 +26,30 @@ service dbus start
service rsyslog start
# prevent fail2ban to fail starting
touch /var/log/auth.log
# prevent tail -f to fail starting
touch /var/log/pam-script.log
# prevent fail2ban to fail restarting
rm -f /var/run/fail2ban/fail2ban.sock
# Start fail2ban (for security reasons)
service fail2ban start
cleanup() {
/bin/umount -fl /home
/bin/umount -fl /home ||:
service dbus stop
service fail2ban stop
service rsyslog stop
service ssh stop
kill $PID 2>/dev/null
kill "$PID" 2>/dev/null
exit
}
trap "cleanup" INT TERM
if [ $# -eq 0 ]; then
exec tail -f /dev/null &
exec tail -f /var/log/fail2ban.log /var/log/syslog /var/log/auth.log /var/log/pam-script.log &
PID=$! && wait
else
# WARNING: cleanup is not called
exec /bin/bash -c "set -e && $@"
exec /bin/bash -c "set -e && $*"
fi
cleanup