diff --git a/setup.sh b/setup.sh index bde2b6c..fe610ee 100644 --- a/setup.sh +++ b/setup.sh @@ -19,30 +19,23 @@ fi ## MAIN -if ! [ -d "/neb" ]; then - echo "setting up ixvd/neb repo" - git clone \ - --recurse-submodules \ - git@git.ixvd.net:ixvd/neb \ - /neb +if ! [ -f "/etc/ixvd/version" ]; then + echo "applying overlay..." + cp -r skel / +fi + +if ! [ -d "/etc/ixvd/secrets" ]; then + echo "setting up ixvd/secrets" + git clone git@git.ixvd.net/ixvd/secrets /etc/ixvd/secrets fi if ! [ -f "/root/.ssh/authorized_keys" ]; then echo "importing authorized_keys..." mkdir -p /root/.ssh - cp secrets/ssh/authorized_keys /root/.ssh/authorized_keys + cp /etc/ixvd/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 + cat /etc/ixvd/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 +fi \ No newline at end of file diff --git a/skel/etc/cron.d/restic.crontab b/skel/etc/cron.d/restic.crontab index cdd3e11..6869d27 100644 --- a/skel/etc/cron.d/restic.crontab +++ b/skel/etc/cron.d/restic.crontab @@ -1,10 +1,10 @@ # /etc/cron.d/restic.crontab # every 4 hours create a backup -0 */4 * * * root /neb/common/restic/backup.sh +0 */4 * * * root /opt/scripts/restic/backup.sh # every day at 2 in the morning, forget old backups -0 2 * * * root /neb/common/restic/forget.sh +0 2 * * * root /opt/scripts/restic/forget.sh # every 1st of the month at 2 in the morning, prune -50 2 1 * * root /neb/common/restic/prune.sh \ No newline at end of file +50 2 1 * * root /opt/scripts/restic/prune.sh \ No newline at end of file diff --git a/skel/etc/ixvd/version b/skel/etc/ixvd/version new file mode 100644 index 0000000..56a6051 --- /dev/null +++ b/skel/etc/ixvd/version @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git a/skel/opt/ixvd/ntfy.sh b/skel/opt/scripts/ntfy.sh similarity index 100% rename from skel/opt/ixvd/ntfy.sh rename to skel/opt/scripts/ntfy.sh diff --git a/skel/opt/restic/backup.sh b/skel/opt/scripts/restic/backup.sh similarity index 73% rename from skel/opt/restic/backup.sh rename to skel/opt/scripts/restic/backup.sh index c6a4684..071170f 100644 --- a/skel/opt/restic/backup.sh +++ b/skel/opt/scripts/restic/backup.sh @@ -1,7 +1,7 @@ #!/bin/sh ntfy() { - sh /opt/ixvd/ntfy.sh -s "/neb/secrets/ntfy/ixvd-backups" -u "https://push.ixvd.net/ixvd-backups" "$@" + sh /opt/scripts/ntfy.sh -s "/neb/secrets/ntfy/ixvd-backups" -u "https://push.ixvd.net/ixvd-backups" "$@" } ntfy -m "performing backup..." diff --git a/skel/opt/restic/forget.sh b/skel/opt/scripts/restic/forget.sh similarity index 79% rename from skel/opt/restic/forget.sh rename to skel/opt/scripts/restic/forget.sh index c3a8cb9..6a816f7 100644 --- a/skel/opt/restic/forget.sh +++ b/skel/opt/scripts/restic/forget.sh @@ -1,7 +1,7 @@ #!/bin/sh ntfy() { - sh /opt/ixvd/ntfy.sh -s "/neb/secrets/ntfy/ixvd-backups" -u "https://push.ixvd.net/ixvd-backups" "$@" + sh /opt/scripts/ntfy.sh -s "/neb/secrets/ntfy/ixvd-backups" -u "https://push.ixvd.net/ixvd-backups" "$@" } ntfy -m "forgetting old backups..." diff --git a/skel/opt/restic/prune.sh b/skel/opt/scripts/restic/prune.sh similarity index 71% rename from skel/opt/restic/prune.sh rename to skel/opt/scripts/restic/prune.sh index 2c3ecaa..e112cec 100644 --- a/skel/opt/restic/prune.sh +++ b/skel/opt/scripts/restic/prune.sh @@ -1,7 +1,7 @@ #!/bin/sh ntfy() { - sh /opt/ixvd/ntfy.sh -s "/neb/secrets/ntfy/ixvd-backups" -u "https://push.ixvd.net/ixvd-backups" "$@" + sh /opt/scripts/ntfy.sh -s "/neb/secrets/ntfy/ixvd-backups" -u "https://push.ixvd.net/ixvd-backups" "$@" } ntfy -m "pruning old backups..."