2023-10-18 01:31:05 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# setup new server
|
|
|
|
|
|
|
|
## PREFLIGHT
|
|
|
|
|
2023-10-18 18:08:05 +02:00
|
|
|
ORIGIN_PWD="$PWD"
|
|
|
|
|
2023-10-18 01:31:05 +02:00
|
|
|
if ! [ "$UID" = "0" ]; then
|
|
|
|
echo "please perform as root, attempting to escalate privileges..."
|
2023-10-18 18:08:05 +02:00
|
|
|
exec sudo $(cat /proc/$$/cmdline | sed 's/\x00/ /g')
|
2023-10-18 01:31:05 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! ssh git@git.ixvd.net; then
|
|
|
|
echo "can't connect to git, please setup ssh"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
## MAIN
|
|
|
|
|
|
|
|
if ! [ -d "/neb" ]; then
|
|
|
|
echo "setting up ixvd/neb repo"
|
|
|
|
git clone \
|
|
|
|
--recurse-submodules \
|
|
|
|
git@git.ixvd.net:ixvd/neb \
|
|
|
|
/neb
|
|
|
|
fi
|
|
|
|
|
2023-10-18 18:08:05 +02:00
|
|
|
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
|