2022-07-24 20:28:08 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
run_directory=$(dirname "$0")
|
|
|
|
user=$(whoami)
|
|
|
|
|
|
|
|
source "$run_directory/variables.conf"
|
|
|
|
|
|
|
|
if [ -f $run_directory/.disabled ]; then
|
|
|
|
echo "Installation is disabled. Exiting..."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Copying Systemd units to system directory..."
|
|
|
|
if [[ $user != 'root' ]]; then
|
|
|
|
sudo cp systemd-templates/cont-snap@.service /etc/systemd/system/
|
|
|
|
sudo cp systemd-templates/conts-snap.service /etc/systemd/system/
|
|
|
|
sudo sed -i -e "s:PH_DIRECTORY:$(pwd):g" /etc/systemd/system/conts-snap.service
|
|
|
|
sudo cp systemd-templates/conts-snap.timer /etc/systemd/system/
|
|
|
|
sudo cp systemd-templates/docker-upgrade.service /etc/systemd/system/
|
|
|
|
sudo sed -i -e "s:PH_DIRECTORY:$(pwd):g" /etc/systemd/system/docker-upgrade.service
|
|
|
|
sudo cp systemd-templates/docker-upgrade.timer /etc/systemd/system/
|
|
|
|
sudo cp systemd-templates/machines-start.service /etc/systemd/system/
|
|
|
|
else
|
|
|
|
cp systemd-templates/cont-snap@.service /etc/systemd/system/
|
|
|
|
cp systemd-templates/conts-snap.service /etc/systemd/system/
|
|
|
|
sed -i -e "s:PH_DIRECTORY:$(pwd):g" /etc/systemd/system/conts-snap.service
|
|
|
|
cp systemd-templates/conts-snap.timer /etc/systemd/system/
|
|
|
|
cp systemd-templates/docker-upgrade.service /etc/systemd/system/
|
|
|
|
sed -i -e "s:PH_DIRECTORY:$(pwd):g" /etc/systemd/system/docker-upgrade.service
|
|
|
|
cp systemd-templates/docker-upgrade.timer /etc/systemd/system/
|
|
|
|
cp systemd-templates/machines-start.service /etc/systemd/system/
|
|
|
|
fi
|
|
|
|
echo "Reloading Systemd..."
|
|
|
|
if [[ $user != 'root' ]]; then
|
|
|
|
sudo systemctl daemon-reload
|
|
|
|
else
|
|
|
|
systemctl daemon-reload
|
|
|
|
fi
|
|
|
|
echo "Enabling timer (not starting it, either do it manually or reboot)..."
|
|
|
|
if [[ $user != 'root' ]]; then
|
2022-07-24 20:57:30 +02:00
|
|
|
sudo systemctl enable conts-snap.timer
|
|
|
|
sudo systemctl enable docker-upgrade.timer
|
2022-07-24 20:28:08 +02:00
|
|
|
else
|
2022-07-24 20:57:30 +02:00
|
|
|
systemctl enable conts-snap.timer
|
|
|
|
systemctl enable docker-upgrade.timer
|
2022-07-24 20:28:08 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Finished install. Exiting..."
|
|
|
|
exit 0
|