diff --git a/setup.sh b/setup.sh index 18a4446..bde2b6c 100644 --- a/setup.sh +++ b/setup.sh @@ -4,9 +4,11 @@ ## PREFLIGHT +ORIGIN_PWD="$PWD" + if ! [ "$UID" = "0" ]; then echo "please perform as root, attempting to escalate privileges..." - exec sudo $0 + exec sudo $(cat /proc/$$/cmdline | sed 's/\x00/ /g') exit 1 fi @@ -25,8 +27,22 @@ if ! [ -d "/neb" ]; then /neb fi -if ! [ -d "/etc/cron.d/restic.crontab" ]; then - echo "setting up restic cron" - mkdir -p /etc/cron.d/ - cp /neb/common/restic/restic.crontab /etc/cron.d/restic.crontab -fi \ No newline at end of file +if ! [ -f "/root/.ssh/authorized_keys" ]; then + echo "importing authorized_keys..." + mkdir -p /root/.ssh + cp secrets/ssh/authorized_keys /root/.ssh/authorized_keys +else + if ! grep -q "# IXVD keys" /root/.ssh/authorized_keys; then + echo "importing authorized_keys..." + cat secrets/ssh/authorized_keys >> /root/.ssh/authorized_keys + fi +fi + +mkdir -p /etc/cron.d +cd common/cron +for cronfile in *.crontab; do + [ -f "/etc/cron.d/$cronfile" ] && continue + echo "installing $cronfile..." + cp $cronfile /etc/cron.d/$cronfile +done +cd $ORIGIN_PWD \ No newline at end of file