neb/tools/server-setup.sh

44 lines
874 B
Bash
Raw Normal View History

2023-10-22 18:01:36 +02:00
#!/bin/bash
2023-10-20 00:10:39 +02:00
# 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..."
cd servers/$HOSTNAME
for s in setup.d/*; do
echo "running (servers/$HOSTNAME/)$s..."
2023-10-22 18:05:27 +02:00
$s | while read line; do
echo "$s: $line"
done
2023-10-20 15:44:39 +02:00
done
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..."
2023-10-22 18:05:27 +02:00
$s | while read line; do
echo "$s: $line"
done
2023-10-20 15:44:39 +02:00
done