diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..2488fda --- /dev/null +++ b/install.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +run_directory=$(dirname "$0") +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..." + $sudo cp systemd-templates/packages-upgrade-apt.service /etc/systemd/packages-upgrade.service +elif [ -x /usr/bin/pacman ]; then + echo "Pacman detected, copying Systemd unit to system directory, using Pacman template..." + $sudo cp systemd-templates/packages-upgrade-pacman.service /etc/systemd/packages-upgrade.service +else + echo "No supported package manager found. Only APT and Pacman are currently supported. Exiting..." + exit 1 +fi +$sudo cp systemd-templates/packages-upgrade.timer /etc/systemd/system/packages-upgrade.timer + +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