2023-10-20 00:10:39 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# setup server
|
|
|
|
|
|
|
|
## PREFLIGHT
|
|
|
|
|
|
|
|
ORIGIN_PWD="$PWD"
|
|
|
|
|
2023-10-22 17:49:57 +02:00
|
|
|
if ! [ "$(id -u)" = "0" ]; then
|
2023-10-20 00:10:39 +02:00
|
|
|
echo "please perform as root, attempting to escalate privileges..."
|
|
|
|
exec sudo $(cat /proc/$$/cmdline | sed 's/\x00/ /g')
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "testing git connection..."
|
2023-10-22 17:59:48 +02:00
|
|
|
if ! ssh git@git.ixvd.net &>/tmp/$$-ssh-output; then
|
|
|
|
echo "can't connect to git, please setup ssh (logs: /tmp/$$-ssh-output)"
|
2023-10-20 00:10:39 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
2023-10-22 17:59:48 +02:00
|
|
|
rm /tmp/$$-ssh-output
|
2023-10-20 00:10:39 +02:00
|
|
|
|
|
|
|
## MAIN
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2023-10-20 15:44:39 +02:00
|
|
|
if [ -d "servers/$HOSTNAME/setup.d" ]; then
|
|
|
|
echo "running server specific setup scripts..."
|
2023-10-20 15:46:08 +02:00
|
|
|
cd servers/$HOSTNAME
|
|
|
|
for s in setup.d/*; do
|
|
|
|
echo "running (servers/$HOSTNAME/)$s..."
|
2023-10-20 15:44:39 +02:00
|
|
|
sh $s
|
|
|
|
done
|
2023-10-20 15:46:08 +02:00
|
|
|
cd -
|
2023-10-20 15:44:39 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
for s in tools/server-setup.d/*; do
|
2023-10-20 00:10:39 +02:00
|
|
|
echo "running $s..."
|
|
|
|
sh $s
|
2023-10-20 15:44:39 +02:00
|
|
|
done
|