82 lines
2.4 KiB
Bash
Executable File
82 lines
2.4 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
# Copyright 2017 Michael De Roover
|
|
|
|
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"
|
|
}
|
|
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"
|
|
}
|
|
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
|
|
elif [ $(uname) == Linux ]
|
|
then
|
|
printf "Distribution not yet supported.\nInstalling for generic Linux..\n"
|
|
install_generic
|
|
fi
|