bridgehead/lib/setup-bridgehead-units.sh

40 lines
1003 B
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
2022-05-09 12:57:24 +02:00
log "Please provide a Project as argument"
2022-05-04 13:50:33 +02:00
exit 1
fi
if [ $1 != "ccp" ] && [ $1 != "nngm" ] && [ $1 != "gbn" ]; then
2022-05-09 12:57:24 +02:00
log "Please provide a supported project like ccp, gbn or nngm"
2022-05-04 13:50:33 +02:00
exit 1
fi
export PROJECT=$1
2022-05-04 13:50:33 +02:00
checkRequirements
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
if ! systemctl is-active --quiet bridgehead@"${PROJECT}"; then
log "Enabling autostart of bridgehead@${PROJECT}.service"
systemctl enable bridgehead@"${PROJECT}"
log "Enabling nightly updates for bridgehead@${PROJECT}.service ..."
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."