Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
43 lines (34 sloc) 983 Bytes
#!/bin/bash
set -e
# Raspberry Pi auto update script
# Runar Ovesen Hjerpbakk
# https://hjerpbakk.com
#
# Usage:
# $ sudo ./auto-update
#
# Run from GitHub:
# $ curl -s https://raw.githubusercontent.com/Sankra/dotfiles/master/tasks/auto-update | sudo bash
# Must be run as root or sudo
if [ $(id -u) != 0 ]
then
echo "This script must be run as root or with sudo."
exit
fi
echo "Installing automatic updates..."
if crontab -l | grep -q "sudo apt -y update";
then
echo "Auto update of package list already exists in crontab"
else
echo "Adding auto update of package list to crontab"
(crontab -l || true; echo "0 3 * * * sudo apt -y update") | crontab -
fi
if crontab -l | grep -q "sudo apt -y dist-upgrade";
then
echo "Upgrade of installed packages already exists in crontab"
else
echo "Adding upgrade of installed packages"
(crontab -l || true; echo "0 4 * * * sudo apt -y dist-upgrade") | crontab -
fi
crontab -l
echo "Installation complete. Enjoy!"