2017-04-03 19:45:41 +02:00
|
|
|
#!/bin/sh
|
2017-04-08 17:23:25 +02:00
|
|
|
|
|
|
|
if [ $EUID != 0 ]
|
|
|
|
then
|
|
|
|
printf "This script needs to be run as root.\n"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
function install_arch_manjaro(){
|
|
|
|
cp kernelcheck /usr/local/sbin/kernelcheck
|
|
|
|
cp notify_all /usr/local/sbin/notify_all
|
|
|
|
if ! hash crontab &>/dev/null
|
|
|
|
then
|
|
|
|
printf "Installing cronie command scheduler..\n"
|
|
|
|
pacman -S --noconfirm cronie &>/dev/null
|
|
|
|
fi
|
|
|
|
if hash systemctl &>/dev/null
|
|
|
|
then
|
|
|
|
if [ $(systemctl is-active cronie) == inactive ]
|
|
|
|
then
|
|
|
|
printf "Enabling cronie command scheduler..\n"
|
|
|
|
systemctl start cronie.service &>/dev/null
|
|
|
|
systemctl enable cronie.service &>/dev/null
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
printf "You don't seem to be using systemd.. Please enable cronie manually.\n"
|
|
|
|
fi
|
|
|
|
if ! grep -Fxq "@hourly /usr/local/sbin/kernelcheck" /var/spool/cron/root 2>/dev/null
|
|
|
|
then
|
|
|
|
printf "Installing hourly service in crontab..\n"
|
|
|
|
(crontab -l 2>/dev/null; echo "@hourly /usr/local/sbin/kernelcheck" ) | crontab -
|
|
|
|
elif grep -Fxq "@hourly /usr/local/sbin/kernelcheck" /var/spool/cron/root
|
|
|
|
then
|
|
|
|
printf "Crontab entry found. Skipping..\n"
|
|
|
|
fi
|
|
|
|
printf "Installation complete.\n"
|
|
|
|
}
|
2017-04-08 17:58:34 +02:00
|
|
|
function install_generic(){
|
|
|
|
cp kernelcheck /usr/local/sbin/kernelcheck
|
|
|
|
cp notify_all /usr/local/sbin/notify_all
|
|
|
|
if ! hash crontab &>/dev/null
|
|
|
|
then
|
|
|
|
printf "This tool depends on cron to schedule kernel checks. Exiting..\n"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if hash systemctl &>/dev/null
|
|
|
|
then
|
|
|
|
if [ $(systemctl is-active cronie) == inactive ]
|
|
|
|
then
|
|
|
|
printf "Enabling cronie command scheduler..\n"
|
|
|
|
systemctl start cronie.service &>/dev/null
|
|
|
|
systemctl enable cronie.service &>/dev/null
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
printf "You don't seem to be using systemd.. Please enable cronie manually.\n"
|
|
|
|
fi
|
|
|
|
if ! grep -Fxq "@hourly /usr/local/sbin/kernelcheck" /var/spool/cron/root 2>/dev/null
|
|
|
|
then
|
|
|
|
printf "Installing hourly service in crontab..\n"
|
|
|
|
(crontab -l 2>/dev/null; echo "@hourly /usr/local/sbin/kernelcheck" ) | crontab -
|
|
|
|
elif grep -Fxq "@hourly /usr/local/sbin/kernelcheck" /var/spool/cron/root
|
|
|
|
then
|
|
|
|
printf "Crontab entry found. Skipping..\n"
|
|
|
|
fi
|
|
|
|
printf "Installation complete.\n"
|
|
|
|
}
|
2017-04-08 17:23:25 +02:00
|
|
|
if [ -f /etc/manjaro-release ]
|
|
|
|
then
|
|
|
|
printf "Installing for Manjaro Linux...\n"
|
|
|
|
install_arch_manjaro
|
|
|
|
elif [ -f /etc/arch-release ]
|
|
|
|
then
|
|
|
|
printf "Installing for Arch Linux...\n"
|
|
|
|
install_arch_manjaro
|
2017-04-08 17:58:34 +02:00
|
|
|
elif [ $(uname) == Linux ]
|
|
|
|
then
|
|
|
|
printf "Distribution not yet supported.\nInstalling for generic Linux..\n"
|
|
|
|
install_generic
|
2017-04-08 17:23:25 +02:00
|
|
|
fi
|