Created
April 29, 2012 20:37
-
-
Save seeRead/2553127 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# boot_enhancer.sh | |
# also see Bootchart http://www.bootchart.org/ | |
# source http://www.ubuntubuzz.com/2012/01/how-to-increasespeed-up-ubuntu-booting.html | |
first_half() | |
{ | |
sudo apt-get -y install prelink # http://ubuntuforums.org/showthread.php?t=832615 | |
sudo /etc/cron.daily/prelink | |
sudo apt-get -y install preload # http://ubuntuforums.org/showthread.php?t=832615 | |
sudo sed -i 's/PRELINKING\=unknown/PRELINKING\=yes/g' /etc/default/prelink | |
sudo perl -pe "s/CONCURRENCY\=makefile\n\n/CONCURRENCY\=shell\n\n/g;" \ | |
-0777i /etc/init.d/rc # multicore boot improvement; 0777 => process whole file so match double return (so correct match) | |
sudo sed -i 's/quiet splash/quiet splash profile/g' /etc/default/grub # grub profiling | |
sudo update-grub2 | |
read -p "Reboot? [Y/n]: " | |
[[ $REPLY != n && $REPLY != N ]] && sudo reboot | |
} | |
second_half() | |
{ | |
sudo sed -i 's/quiet splash profile/quiet splash/g' /etc/default/grub # grub profiling | |
sudo update-grub2 | |
} | |
create_notice() | |
{ # create script for next login | |
NOTICE=$(cat <<\EOF | |
#!/bin/bash | |
zenity --question --title="Finish your boot enhancement" \ | |
--text="Do you want to finish the boot enhancement script?" | |
if [[ $? ]]; then | |
#same as second_half | |
gksu 'sed -i 's/quiet splash profile/quiet splash/g' /etc/default/grub && update-grub2' | |
fi | |
#remove this script and autostart config | |
rm /usr/bin/boot_enhancer_login_note.sh | |
rm ~/.config/autostart/boot-notice.desktop | |
EOF | |
) | |
loc=/tmp/boot_enhancer_login_note.sh | |
echo "$NOTICE" > $loc | |
chmod +x $loc | |
sudo mv $loc /usr/bin | |
# autostart it | |
LOGIN=$(cat <<\EOF | |
[Desktop Entry] | |
Type=Application | |
Exec=/usr/bin/boot_enhancer_login_note.sh | |
Hidden=false | |
NoDisplay=false | |
X-GNOME-Autostart-enabled=true | |
Name[en_US]=boot notice | |
Name=boot notice | |
Comment[en_US]=located in home directory | |
Comment= | |
EOF | |
) | |
echo "$LOGIN" > ~/.config/autostart/boot-notice.desktop | |
chmod 664 ~/.config/autostart/boot-notice.desktop | |
echo "Notification created for next login" | |
} | |
#here's the prompt | |
echo "$(cat << \EOF | |
Let's make your machine boot faster! | |
This requires two steps, one before and one after a reboot. | |
This script can create a Zenity prompt for you after the reboot so you don't forget to run the second half. | |
READ THIS SCRIPT before you run it. It calls sudo multiple times. You have been warned. | |
Here are your options: | |
[1] Run first half, reboot, and, on next login, prompt (and then run) second half. | |
[2] Run first half and reboot. | |
[3] Run second half. | |
[4] Get outta here. | |
EOF | |
)" | |
read -p "Pick your poison [1,2,3,4]: " | |
case "$REPLY" in | |
1) | |
create_notice | |
first_half | |
;; | |
2) | |
first_half | |
;; | |
3) | |
second_half | |
;; | |
4) | |
echo "Adios!" | |
;; | |
*) | |
exit 1 | |
;; | |
esac | |
exit; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment