bridgehead/lib/setup-bridgehead-units.sh

43 lines
1.1 KiB
Bash
Raw Normal View History

2021-12-21 13:48:28 +01:00
#!/bin/bash
2022-01-10 15:31:07 +01:00
source lib/functions.sh
exitIfNotRoot
2022-05-04 13:50:33 +02:00
if [ $# -eq 0 ]; then
echo "Please provide a Project as argument"
exit 1
fi
if [ $1 != "ccp" ] && [ $1 != "nngm" ] && [ $1 != "gbn" ]; then
echo "Please provide a supported project like ccp, gbn or nngm"
exit 1
fi
export project=$1
2022-01-10 14:45:52 +01:00
if ! ./lib/prerequisites.sh; then
log "Prerequisites failed, exiting"
2022-01-10 15:11:57 +01:00
exit 1
fi
2021-12-21 13:48:28 +01:00
echo -e "\nInstalling systemd units ..."
2022-01-10 15:31:07 +01:00
cp -v \
2022-01-10 16:42:13 +01:00
lib/systemd/bridgehead\@.service \
lib/systemd/bridgehead-update\@.service \
lib/systemd/bridgehead-update\@.timer \
/etc/systemd/system/
2021-12-21 13:48:28 +01:00
2022-01-10 15:31:07 +01:00
systemctl daemon-reload
2021-12-21 13:48:28 +01:00
2022-01-10 16:31:48 +01:00
echo
2021-12-21 13:48:28 +01:00
2022-01-10 16:31:48 +01:00
if ! systemctl is-active --quiet bridgehead@"${project}"; then
echo "Enabling autostart of bridgehead@${project}.service"
2022-01-10 15:31:07 +01:00
systemctl enable bridgehead@"${project}"
echo "Enabling nightly updates for bridgehead@${project}.service ..."
2022-01-10 15:31:07 +01:00
systemctl enable --now bridgehead-update@"${project}".timer
2022-01-10 16:31:48 +01:00
fi
echo -e "\nDone - now start your bridgehead by running\n\tsystemctl start bridgehead@${project}.service\nor by rebooting your machine."