Don't do sudo
This commit is contained in:
parent
75b33690f6
commit
123ce65c82
|
@ -1,6 +1,10 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
### Note: Currently not complete, needs some features before useable for production
|
### Note: Currently not complete, needs some features before useable for production
|
||||||
|
|
||||||
|
source lib/functions.sh
|
||||||
|
|
||||||
|
exitIfNotRoot
|
||||||
|
|
||||||
if ! ./lib/prerequisites.sh; then
|
if ! ./lib/prerequisites.sh; then
|
||||||
echo "Prerequisites failed, exiting"
|
echo "Prerequisites failed, exiting"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -12,14 +16,15 @@ echo "Installing bridgehead"
|
||||||
_systemd_path=/etc/systemd/system/
|
_systemd_path=/etc/systemd/system/
|
||||||
|
|
||||||
|
|
||||||
echo "Installing bridgehead\@.service in systemd ..."
|
echo "Installing systemd units ..."
|
||||||
sudo cp convenience/bridgehead\@.service $_systemd_path
|
cp -v \
|
||||||
echo "Installing bridgehead\@.update.service in systemd ..."
|
convenience/bridgehead\@.service \
|
||||||
sudo cp convenience/bridgehead-update\@.service $_systemd_path
|
convenience/bridgehead-update\@.service \
|
||||||
sudo cp convenience/bridgehead-update\@.timer $_systemd_path
|
convenience/bridgehead-update\@.timer \
|
||||||
|
$_systemd_path
|
||||||
|
|
||||||
echo "Loading the bridgehead definitions in systemd"
|
echo "Loading the bridgehead definitions in systemd"
|
||||||
sudo systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
|
|
||||||
|
|
||||||
echo "Starting Project ${project} "
|
echo "Starting Project ${project} "
|
||||||
|
@ -28,14 +33,14 @@ echo "Starting Project ${project} "
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo systemctl is-active --quiet bridgehead@"${project}"
|
systemctl is-active --quiet bridgehead@"${project}"
|
||||||
if [ ! $? -eq 0 ]; then
|
if [ ! $? -eq 0 ]; then
|
||||||
echo "Starting bridgehead@${project} service ..."
|
echo "Starting bridgehead@${project} service ..."
|
||||||
sudo systemctl start bridgehead@"${project}"
|
systemctl start bridgehead@"${project}"
|
||||||
echo "Enabling autostart of bridgehead@${project}.service"
|
echo "Enabling autostart of bridgehead@${project}.service"
|
||||||
sudo systemctl enable bridgehead@"${project}"
|
systemctl enable bridgehead@"${project}"
|
||||||
echo "Enabling nightly updates for bridgehead@${project}.service ..."
|
echo "Enabling nightly updates for bridgehead@${project}.service ..."
|
||||||
sudo systemctl enable --now bridgehead-update@"${project}".timer
|
systemctl enable --now bridgehead-update@"${project}".timer
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Switch back to execution directory;
|
# Switch back to execution directory;
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
#!/bin/bash -e
|
||||||
|
|
||||||
|
exitIfNotRoot() {
|
||||||
|
if [ "$EUID" -ne 0 ]; then
|
||||||
|
echo "Please run as root"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
log() {
|
||||||
|
echo "$(date +'%Y-%m-%d %T')" "$1:" "$2"
|
||||||
|
}
|
Loading…
Reference in New Issue