#!/bin/bash Version="2.0"; AppData="$HOME/.KernUP"; AppName="kernup"; AliasName="$HOME/.bash_aliases"; InstalledVersion=$(uname -r | cut -d "-" -f1 | sort -V | cut -d "." -f1,2,3 | tail -n 1); KernelInstalled=`echo $InstalledVersion` Architecture=`uname -m`; Core_Url="https://raw.githubusercontent.com/DamiaX/KernUP/master/KernUP"; Updater_Url="https://raw.githubusercontent.com/DamiaX/KernUP/master/Updater"; Lang_Name="KernUP.lang"; SettingFile="setting.kernup"; Pass=''; term="/dev/tty"; RunDir=`echo $PWD`; VboxDir='/etc/inid.d/vboxdrv' su='0'; KernelVer=''; DecryptPass=''; SaveSettings() { if [ -f $SettingFile ]; then rm -rf $SettingFile; fi echo $Pass > $SettingFile echo $KernelVer >> $SettingFile } LoadSettings() { if [ -f $SettingFile ]; then LoadPass=$(head -n1 $SettingFile); KernelLoad=$(tail -n1 $SettingFile); sed -i "s@^Pass='';@Pass='$LoadPass';@g" $0 sed -i "s@^KernelVer='';@KernelVer='$KernelLoad';@g" $0 rm -rf $SettingFile; bash $0; exit; fi } Color() { Alert='33'; Text='36'; Wow='31'; Suprise='34'; Action='32'; } RecompileVirtualbox() { if [ -f $VboxDir ] ; then "$VboxDir setup" fi; } MaskandUnmaskPass() { if [ -z $Pass ] ; then CryptPass=$(echo $1 | openssl enc -base64); sed -i "s@^Pass='[a-zA-Z0-9_]*';@Pass='$CryptPass';@g" $0 else DecryptPass=$(echo $Pass | openssl base64 -d); fi } Root() { if [ "$(id -u)" != "0" ]; then echo -e -n "\E[$Alert;1m$Information \033[0m"; cd $RunDir if [ -z $Pass ] ; then echo -e "\E[$Suprise;1m$AdminPass\033[0m"; read -s Password < $term MaskandUnmaskPass $Password; fi if [ -z $Pass ] ; then echo "$Password" | sudo -S sh -c "bash $0 $1" else MaskandUnmaskPass $Pass; echo "$DecryptPass" | sudo -S sh -c "bash $0 $1" fi exit fi } InstallApp() { if [ ! -f "$AppData/$AppName" ] ; then echo -e -n "\E[$Alert;1m$Information\033[0m"; echo -e -n "\E[$Text;1m $AppInstallng\033[0m "; echo -e "\E[$Alert;1m $Odplng\033[0m"; read Answer < $term; Default_Answer "t"; if [[ $Answer == "T" || $Answer == "t" || $Answer == "y" || $Answer == "Y" ]]; then cp -r $0 "$AppData/$AppName"; chmod +x -f "$AppData/$AppName"; echo "alias $AppName='$AppData/$AppName'" >> $AliasName; crontab -l > "$AppData/Temp/cronfile"; echo "*/10 * * * * $AppData/$AppName -au" >> "$AppData/Temp/cronfile"; crontab "$AppData/Temp/cronfile"; rm -rf "$AppData/Temp/cronfile"; fi fi } Welcome() { clear; Color; CreateData; Language; echo -e -n "\E[28;1m [[ KernUP: \040"; echo -e -n "\E[31;1m$Version\033[0m"; echo -e -n "\E[28;1m ]] -\040" ; echo -e "\E[$Alert;1m$EGGlng \033[0m"; CheckReboot; TestNetwork; AppUpdate; LoadSettings; SetupGenericLowlatency; InstallApp; } CheckReboot() { if [ -f /var/run/reboot-required ]; then echo -e -n "\E[$Action;1m$Information \033[0m"; echo -e -n "\E[$Wow;1m$Restart $Odplng\033[0m"; read Answer < $term; Default_Answer "t"; if [[ $Answer == "T" || $Answer == "t" || $Answer == "y" || $Answer == "Y" ]]; then systemctl reboot fi fi } AppUpdate() { Server_Version=$(wget -q "https://raw.githubusercontent.com/DamiaX/KernUP/master/Version" -O -); New_Version=$(echo $Server_Version | tr '.' ',' | sed -e 's@,@@g'); Actual_Version=$(echo $Version | tr '.' ',' | sed -e 's@,@@g'); if [ $Actual_Version != $New_Version ] then echo -e -n "\E[$Alert;1m$Information\033[0m"; echo -e "\E[$Wow;1m $Updatelng\033[0m"; SaveSettings; wget -q $Updater_Url -O "update.kernup" | chmod +x -f "update.kernup"; bash "update.kernup" exit; echo -e -n "\E[$Alert;1m$Information\033[0m"; echo -e "\E[$Action;1m $Rebotlng \040"; exit; fi } RemoveKernel() { Root -rk; echo -e -n "\E[$Alert;1m$Information \033[0m"; echo -e -n "\E[$Suprise;1m$RemoveK_Ask \033[0m"; echo -e "\E[$Alert;1m$Odplng\033[0m"; read Answer < $term; Default_Answer "t"; if [[ $Answer == "T" || $Answer == "t" || $Answer == "y" || $Answer == "Y" ]]; then apt-get remove -y --purge $(dpkg -l 'linux-image-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d'); apt-get remove -y --purge $(dpkg -l 'linux-headers-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d'); apt-get -y autoremove; apt-get -y autoclean; apt-get -y clean; numbermodules=$(ls /lib/modules | wc -l); if [[ $numbermodules != "1" ]] ; then modules=$(ls --sort=version /lib/modules | head -n 1); rm -rf "/lib/modules/"$modules; update-grub; fi fi } DownloadKernel() { if [ $KernelInstalled == $Kernel_Latest_Version ] ; then echo -e -n "\E[$Alert;1m$Information\033[0m"; echo -e "\E[$Action;1m $Gitlng \040"; rm -rf "$AppData/Temp"; exit else if [ -e "/usr/bin/notify-send" ] ; then notify-send -i stock_lock-broken "KernUP" "$Chicklng" fi echo -e -n "\E[$Alert;1m$Information \033[0m"; echo -e "\E[$Wow;1m$Chicklng \033[0m" ; echo -e -n "\E[$Alert;1m$Information \033[0m"; echo -e -n "\E[$Text;1m$Momlng \0$Alert[0m"; echo -e -n "\E[$Suprise;1m$KernelInstalled\033[0m"; echo -e -n "\E[$Text;1m,$Givelng \0$Alert[0m"; echo -e -n "\E[$Suprise;1m$Kernel_Latest_Version\033[0m"; echo -e "\E[$Suprise;1m! \033[0m"; echo -e -n "\E[$Alert;1m$Information \033[0m"; echo -e -n "\E[$Action;1m$Downloadlng\040"; cd "$AppData/Temp"; if [ $Architecture == "x86_64" ] ; then if [[ $KernelVer == '1' ]]; then echo -e "\E[$Text;1m$Kernel_Latest_Version (Generic) \040"; wget -q -c "$Headers_Download_Url_Generic"'_amd64.deb'; wget -q -c "$Image_Download_Url_Generic"'_amd64.deb'; wget -q -c "$Kernel_Download_Url_All"; wget -q -c "$Module_Download_Url_Generic"'_amd64.deb'; else echo -e "\E[$Text;1m$Kernel_Latest_Version (Lowlatency) \040"; wget -q -c "$Headers_Download_Url_Lowlatency"'_amd64.deb'; wget -q -c "$Image_Download_Url_Lowlatency"'_amd64.deb'; wget -q -c "$Kernel_Download_Url_All"; wget -q -c "$Module_Download_Url_Lowlatency"'_amd64.deb'; fi; fi; if [ $Architecture == "i686" ] || [ $Architecture == "i386" ] || [ $Architecture == "x86" ] ; then if [[ $KernelVer == '1' ]]; then echo -e "\E[$Text;1m$Kernel_Latest_Version (Generic) \040"; wget -q -c "$Headers_Download_Url_Generic"'_i386.deb'; wget -q -c "$Image_Download_Url_Generic"'_i386.deb'; wget -q -c "$Kernel_Download_Url_All"; wget -q -c "$Module_Download_Url_Generic"'_i386.deb'; else echo -e "\E[$Text;1m$Kernel_Latest_Version (Lowlatency) \040"; wget -q -c "$Headers_Download_Url_Lowlatency"'_i386.deb'; wget -q -c "$Image_Download_Url_Lowlatency"'_i386.deb'; wget -q -c "$Kernel_Download_Url_All"; wget -q -c "$Module_Download_Url_Lowlatency"'_i386.deb'; fi; fi; echo -e -n "\E[$Alert;1m$Information \033[0m"; echo -e "\E[$Text;1m$FinishDownloadlng\040"; fi; } RemoveApp() { echo -e -n "\E[$Alert;1m$Information \033[0m"; echo -e -n "\E[$Text;1m$AnswerRemove\033[0m "; echo -e "\E[$Alert;1m $Odplng\033[0m"; read Answer; Default_Answer "t"; if [[ $Answer == "T" || $Answer == "t" || $Answer == "y" || $Answer == "Y" ]]; then sed -i "s@alias $AppName='$AppData/$AppName'@@g" $AliasName; crontab -l > "$AppData/Temp/cronfile"; sed -i "s#*/10 * * * * $AppData/$AppName -au##g" "$AppData/Temp/cronfile"; crontab "$AppData/Temp/cronfile"; rm -rf $AppData; fi } SudoSetting() { echo -e -n "\E[$Alert;1m$Information \033[0m"; echo -e -n "\E[$Text;1m$RunAslng\033[0m "; echo -e "\E[$Alert;1m[1/2]\033[0m"; echo -e -n "\E[$Alert;1m$Information \033[0m"; echo -e "\E[$Text;1m1) sudo\033[0m"; echo -e -n "\E[$Alert;1m$Information \033[0m"; echo -e "\E[$Text;1m2) su\033[0m"; read Answer; Default_Answer "1"; if [[ $Answer == "1" ]]; then sed -i "s@^su='[0-9]';@su='0';@g" $0 else sed -i "s@^su='[0-9]';@su='1';@g" $0 fi } SudoChoose() { if [ $su == 0 ] then sudo $1 else su $1 fi } TestNetwork() { wget -q --spider http://google.com if [ $? != 0 ]; then echo -e -n "\E[$Alert;1m$Information \033[0m"; echo -e "\E[$Wow;1m$Internetlng\033[0m"; exit; fi } function Default_Answer() { if [ -z $Answer ]; then Answer="$1"; fi } Language() { case $LANG in *PL*) if [ ! -f "$AppData/$Lang_Name" ] ; then Lang_pl=$(wget "https://raw.githubusercontent.com/DamiaX/KernUP/master/KernUP.pl.lang" -q -O -); PL=`echo $Lang_pl > "$AppData/$Lang_Name"`; fi ;; *) if [ ! -f "$AppData/$Lang_Name" ] ; then Lang_en=$(wget "https://raw.githubusercontent.com/DamiaX/KernUP/master/KernUP.en.lang" -q -O -); EN=`echo $Lang_en > "$AppData/$Lang_Name"`; fi ;; esac source "$AppData/$Lang_Name"; } CreateData() { mkdir -p $AppData; mkdir -p "$AppData/Temp"; } Check_Distro() { if [ ! -e "/usr/bin/dpkg" ] ; then echo -e -n "\E[$Alert;1m$Information \033[0m"; echo -e "\E[$Wow;1m$Dist\033[0m"; exit; fi } RefreshSystem() { Root -su; SudoChoose "apt-get update -y -qq"; SudoChoose "apt-get upgrade -y -qq"; } SetupGenericLowlatency() { if [ -z $KernelVer ] ; then SettingGenericLowlatency; Root; fi } SettingGenericLowlatency() { echo -e -n "\E[$Alert;1m$Information \033[0m"; echo -e "\E[$Action;1m$InstallGenLow\033[0m"; read KernelVerChose; if [ -z $KernelVerChose ]; then KernelVerChose="1"; fi sed -i "s@^KernelVer='[a-zA-Z0-9_]*';@KernelVer='$KernelVerChose';@g" $0; } GetLink() { Kernel_List_Get=$(wget -qO- 'http://kernel.org'); Kernel_Latest_Version=$(echo $Kernel_List_Get | perl -l -0777 -ne 'print $1 if /