Improved install script

This commit is contained in:
toloveru
2017-04-08 17:23:25 +02:00
parent b8e38428a0
commit 86846e29ed
2 changed files with 59 additions and 19 deletions

55
install
View File

@@ -1,10 +1,47 @@
#!/bin/sh #!/bin/sh
printf "Copying files..\n"
sudo cp kernelcheck /usr/local/sbin/kernelcheck if [ $EUID != 0 ]
sudo cp notify_all /usr/local/sbin/notify_all then
printf "Adding hourly service to cron scheduler..\n" printf "This script needs to be run as root.\n"
(sudo crontab -l; echo "@hourly /usr/local/sbin/kernelcheck" ) | sudo crontab - exit 1
printf "Enabling cronie scheduler..\n" # Let me know if you use something else, and enable manually. fi
sudo systemctl start cronie.service
sudo systemctl enable cronie.service function install_arch_manjaro(){
printf "Installation complete.\n" 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"
}
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
fi

View File

@@ -54,20 +54,23 @@ then
make modules_install &>/dev/null make modules_install &>/dev/null
cp arch/$(uname -m)/boot/bzImage /boot/vmlinuz-$latest cp arch/$(uname -m)/boot/bzImage /boot/vmlinuz-$latest
mkinitcpio -k $latest -g /boot/initramfs-$latest.img &>/dev/null mkinitcpio -k $latest -g /boot/initramfs-$latest.img &>/dev/null
if [ "$(echo $(uname -r) | sed 's/ARCH//')" != "$(uname -r)" ] ## Uncomment this code block only if you really know what you are doing!!
then ## It removes the Arch / Manjaro distribution kernel, and should only be done if you know how to recover from chroot!
/usr/local/sbin/notify_all "Kernel update tracker" "Removing the Arch distribution kernel.." --icon=dialog-information
pacman -R --noconfirm linux # if [ "$(echo $(uname -r) | sed 's/ARCH//')" != "$(uname -r)" ]
elif [ "$(echo $(uname -r) | sed 's/MANJARO//')" != "$(uname -r)" ] # then
then # /usr/local/sbin/notify_all "Kernel update tracker" "Removing the Arch distribution kernel.." --icon=dialog-information
/usr/local/sbin/notify_all "Kernel update tracker" "Removing the Manjaro distribution kernel.." --icon=dialog-information # pacman -R --noconfirm linux
pacman -R --noconfirm linux # elif [ "$(echo $(uname -r) | sed 's/MANJARO//')" != "$(uname -r)" ]
else # then
# /usr/local/sbin/notify_all "Kernel update tracker" "Removing the Manjaro distribution kernel.." --icon=dialog-information
# pacman -R --noconfirm linux
# else
/usr/local/sbin/notify_all "Kernel update tracker" "Removing the current kernel.." --icon=dialog-information /usr/local/sbin/notify_all "Kernel update tracker" "Removing the current kernel.." --icon=dialog-information
rm -f /boot/initramfs-$current.img rm -f /boot/initramfs-$current.img
rm -f /boot/vmlinuz-$current rm -f /boot/vmlinuz-$current
rm -rf /usr/lib/modules/$current rm -rf /usr/lib/modules/$current
fi # fi
grub-mkconfig -o /boot/grub/grub.cfg &>/dev/null grub-mkconfig -o /boot/grub/grub.cfg &>/dev/null
/usr/local/sbin/notify_all "Kernel update tracker" "New kernel installed\!" --icon=dialog-information /usr/local/sbin/notify_all "Kernel update tracker" "New kernel installed\!" --icon=dialog-information
elif [[ "$latest" == "$current" ]] && [[ ! -z $latest ]] elif [[ "$latest" == "$current" ]] && [[ ! -z $latest ]]