packages-upgrade/install.sh

37 lines
1.2 KiB
Bash
Raw Normal View History

2022-08-28 12:23:57 +02:00
#!/usr/bin/env bash
run_directory=$(dirname $(readlink -f "$0"))
2022-08-28 12:23:57 +02:00
user=$(whoami)
if [ -f $run_directory/.disabled ]; then
echo "Installation is disabled. Exiting..."
exit 0
fi
if [[ $user != 'root' ]]; then
sudo="sudo"
else
sudo=""
fi
if [ -x /usr/bin/apt-get ]; then
echo "APT detected, copying Systemd unit to system directory, using APT template..."
2022-12-21 10:08:57 +01:00
$sudo cp $run_directory/systemd-templates/packages-upgrade-apt.service /etc/systemd/system/packages-upgrade.service
2022-08-28 12:23:57 +02:00
elif [ -x /usr/bin/pacman ]; then
echo "Pacman detected, copying Systemd unit to system directory, using Pacman template..."
2022-12-21 10:08:57 +01:00
$sudo cp $run_directory/systemd-templates/packages-upgrade-pacman.service /etc/systemd/system/packages-upgrade.service
2022-08-28 12:23:57 +02:00
else
echo "No supported package manager found. Only APT and Pacman are currently supported. Exiting..."
exit 1
fi
2022-12-21 10:08:57 +01:00
$sudo cp $run_directory/systemd-templates/packages-upgrade.timer /etc/systemd/system/packages-upgrade.timer
2022-08-28 12:23:57 +02:00
echo "Reloading Systemd..."
$sudo systemctl daemon-reload
echo "Enabling timer (not starting it, either do it manually or reboot)..."
$sudo systemctl enable packages-upgrade.timer
echo "Finished install. Exiting..."
exit 0