Update install scripts and prereqs (sudo)

This commit is contained in:
Martin Lablans 2022-09-30 15:25:09 +02:00
parent 4c84d65548
commit 7692c4e889
5 changed files with 37 additions and 11 deletions

View File

@ -23,6 +23,12 @@ for prerequisite in $prerequisites; do
# TODO: Check for specific version # TODO: Check for specific version
done done
log INFO "Checking if sudo is installed ..."
if [ ! -d /etc/sudoers.d ]; then
log ERROR "/etc/sudoers.d does not exist. Please install sudo package."
exit 1
fi
log INFO "Checking configuration ..." log INFO "Checking configuration ..."
## Download submodule ## Download submodule

View File

@ -16,6 +16,10 @@ export PROJECT=$1
#checkRequirements // not needed when uninstalling #checkRequirements // not needed when uninstalling
log INFO "Removing bridgehead sudoers permissions."
rm -vf /etc/sudoers.d/bridgehead-${PROJECT}
log "INFO" "Stopping system units and removing bridgehead for ${PROJECT} ..." log "INFO" "Stopping system units and removing bridgehead for ${PROJECT} ..."
systemctl disable --now bridgehead@${PROJECT}.service bridgehead-update@${PROJECT}.timer bridgehead-update@${PROJECT}.service systemctl disable --now bridgehead@${PROJECT}.service bridgehead-update@${PROJECT}.timer bridgehead-update@${PROJECT}.service

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash -e
source lib/functions.sh source lib/functions.sh
@ -18,6 +18,18 @@ export PROJECT=$1
checkRequirements checkRequirements
log "INFO" "Allowing the bridgehead user to start/stop the bridgehead."
cat <<EOF > /etc/sudoers.d/bridgehead-"${PROJECT}"
# This has been added by the Bridgehead installer. Remove with bridgehead uninstall.
Cmnd_Alias BRIDGEHEAD${PROJECT} = \\
/bin/systemctl start bridgehead@${PROJECT}.service, \\
/bin/systemctl stop bridgehead@${PROJECT}.service, \\
/bin/systemctl restart bridgehead@${PROJECT}.service
bridgehead ALL= NOPASSWD: BRIDGEHEAD${PROJECT}
EOF
log "INFO" "Register system units for bridgehead and bridgehead-update" log "INFO" "Register system units for bridgehead and bridgehead-update"
cp -v \ cp -v \
lib/systemd/bridgehead\@.service \ lib/systemd/bridgehead\@.service \
@ -27,11 +39,14 @@ cp -v \
systemctl daemon-reload systemctl daemon-reload
if ! systemctl is-active --quiet bridgehead@"${PROJECT}"; then log INFO "Trying to update your bridgehead ..."
log "INFO" "Enabling autostart of bridgehead@${PROJECT}.service"
systemctl enable bridgehead@"${PROJECT}"
log "INFO" "Enabling nightly updates for bridgehead@${PROJECT}.service ..."
systemctl enable --now bridgehead-update@"${PROJECT}".timer
fi
log "INFO" "\nDone - now start your bridgehead by running\n\tsystemctl start bridgehead@${PROJECT}.service\nor by rebooting your machine." systemctl start bridgehead-update@"${PROJECT}".service
log "INFO" "Enabling autostart of bridgehead@${PROJECT}.service"
systemctl enable bridgehead@"${PROJECT}".service
log "INFO" "Enabling auto-updates for bridgehead@${PROJECT}.service ..."
systemctl enable --now bridgehead-update@"${PROJECT}".timer
log "INFO" "\nSuccess - now start your bridgehead by running\n systemctl start bridgehead@${PROJECT}.service\n or by rebooting your machine."

View File

@ -1,8 +1,8 @@
[Unit] [Unit]
Description=Nightly Updates of Bridgehead (%i) Description=Hourly Updates of Bridgehead (%i)
[Timer] [Timer]
OnCalendar=*-*-* 03:00:00 OnCalendar=*-*-* *:00:00
[Install] [Install]
WantedBy=basic.target WantedBy=basic.target

View File

@ -1,5 +1,6 @@
[Unit] [Unit]
Description=Bridgehead (%i) Service Description=Bridgehead (%i)
Requires=docker.service
[Service] [Service]
User=bridgehead User=bridgehead