14

How do I make post-install scripts so when I reinstall ubuntu everything is as I want it?

Things I want to achive:

  • Installing PPA
  • installing my programs
  • themes needs to be installed
  • Settings needs to be changed (power management, short commands, startup applications, etc.)
  • system reboots
Alvar
  • 17,058

1 Answers1

22

Easiest way is to gather all the commands you need and put them in a text file and make the text file executable.

We start out with going command line and do this:

touch post_install_script
sudo 775 post_install_script
gedit post_install_script

And you start putting in commands you want to be executed.

Installing packages that are in Ubuntu Software Center.

Start with enabling all repositories and refreshing the software list because the LiveCD is outdated:

sudo sed 's/# deb/deb/' -i /etc/apt/sources.list
sudo apt-get update

Look up inside USC what already is there and check the package name. Examples with VLC and smplayer:

sudo apt-get install vlc
sudo apt-get install smplayer

In the same way of adding software like this you can also remove packages with:

sudo apt-get remove {package_name}

(just be careful to check dependencies first)

PPA for installing nautilus elementary:

sudo add-apt-repository ppa:am-monkeyd/nautilus-elementary-ppa
sudo apt-get update && sudo apt-get upgrade

Themes

Those are either in USC or have a PPA so you can add these with either one of the 2. For instance I like the equinox themes and I can add them like this:

sudo add-apt-repository ppa:tiheum/equinox
sudo apt-get update && sudo apt-get install gtk2-engines-equinox

or the Faenza icon sets:

sudo add-apt-repository ppa:tiheum/equinox
sudo apt-get update && sudo apt-get install faenza-icon-theme


So you gather all the installation instructions that you want to add and put them in your script each on a new line. You can speed things up by removing duplicate entries: sudo apt-get upgrade does not need to be done with every PPA: you can do that after adding all the PPAs but(!) before you install the software from the PPA.

Theoretically you can have 1 of these script files for all Ubuntu installations but you might need to tweak them for every system.

This is my newest attempt to creating a post install script:

enter image description here

What does this do?

  1. update sources list
  2. remove all directories in my home and create them again in /discworld2/ After that I recreate my home directory directories using symlinks. This way I am able to format my home and keep my files (they are not only on another partition but even on another disc);
  3. install software I want;
  4. set power management the way I want it.
  5. add ppa's I want

After installing I just execute my post_install file and it will run for a long time but it will take care of everything I want (well I will be adding more and more things over time so it will get longer).

I probably can improve it by making compound statements of some of these lines

Rinzwind
  • 299,756
  • Could you give us an example of what a post-install script can look like? picture or code. – Alvar Jun 07 '11 at 21:57
  • 1
    Awesome! This will help a lot! :D – Alvar Jun 11 '11 at 22:44
  • shouldn't PPA:s be added first? So you add your links and then download all your software in one command! more efficent! :D I normally do a sudo apt-get update and a sudo apt-get upgrade before the reboot. – Alvar Jun 12 '11 at 21:41
  • Yeah well... I am adding stuff as I install it and add those to my script. I already have it set up with less commands by putting ppa's more in front but the actual testing of my scripts needs a reinstall and I am not doing that yet ;-) – Rinzwind Jun 12 '11 at 21:49
  • And it's a guideline not exact sience ;) @alvar: new image added in. No idea if these commands are valid this way ... after I did a re-install I'll get back to you ;) (upgrade and dist-upgrade probably need to be behind the apt-get install??) – Rinzwind Jun 12 '11 at 22:19
  • so just sudo apt-get upgrade for a system upgrade of the software (like new vlc, bugs or stuff like that.) dist-upgrade is for upgrading form a system version to another like 10.04 - 10.10. – Alvar Jun 13 '11 at 12:31
  • dist-upgrade is needed for elementary. – Rinzwind Jun 13 '11 at 12:37
  • What do you mean? I only use update/upgrade I like the terminal more... – Alvar Jun 13 '11 at 20:41