Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I find myself moving between multiple new machines lately (new laptop, new computer at work, etc.). I want to create a bash script to install all the software I use. Ninite is not reach enough. I have no experience in bash scripts, I'm learning it. I'm planing to use aptitude search to find the packages names (if the exists in the repositories) and to create multiple line of aptitude install.

Than all I will have to do after installing Ubuntu from scratch is to install altitude and run the script.

  1. Will the script line will run one after another (and not in parallel and fail)?
  2. Can I do a "silent install" so the installation program won't prompt for answers (pre-define the answers or user default)?
  3. Is there a way to define some system settings by bash script?
share|improve this question
    
if you need more please add it into your question @tibo –  Rinzwind Aug 14 '12 at 18:35

2 Answers 2

up vote 5 down vote accepted

Yes on all 3 questions.

Regarding the last question: you can use package dconf-tools (included in the example) for alot of settings. And gconftool-2 for some others (though that latter one is fased out) I added one line at the bottom of the example. You can search for them like so gsettings list-recursively | grep plugins.power|more. This will show anything related to power settings.

If you need conditional commands you can use &&: {command && command2} will only issue command 2 if command 1 does not fail.


Create a text file and make it executable and add in exectable pieces of code. Example with some random things I do post install (that includes symlinking my home to a seperate disc (that does not get formatted when re-installing):

# Enable sources, add PPAs and update sources: 
sudo sed 's/# deb/deb/' -i /etc/apt/sources.list

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

# Symlinking home folders.
cd /discworld2/
mkdir Desktop/ Downloads/ Pictures/ Videos/ Public/ Music/ Templates/ Documents/ 
cd
rm -rf Desktop/ Downloads/ Pictures/ Videos/ Public/ Music/ Templates/ Documents/ 
ln -s /discworld2/Desktop/   Desktop
ln -s /discworld2/Documents/ Documents
ln -s /discworld2/Downloads/ Downloads
ln -s /discworld2/Pictures/  Pictures
ln -s /discworld2/Templates/ Templates
ln -s /discworld2/Videos     Videos

# Adding software:
sudo apt-get install -y dconf-tools powertop htop compizconfig-settings-manager deluge vlc smplayer shutter chromium-browser cheese gtk2-engines-equinox faenza-icon-theme equinox-theme

# restart nautilus (req. to activate elementary):
nautilus -q

# remove lock screen

gsettings set org.gnome.desktop.screensaver lock-enabled false

# Altering settings power management (OLD method):

gconftool-2 --set --type string /apps/gnome-power-manager/critical_battery       shutdown 
gconftool-2 --set --type bool   /apps/gnome-power-manager/battery_reduce         false
gconftool-2 --set --type bool   /apps/gnome-power-manager/idle_dim_battery       false
gconftool-2 --set --type string /apps/gnome-power-manager/lid_ac                 blank
gconftool-2 --set --type string /apps/gnome-power-manager/lid_battery            blank
gconftool-2 --set --type string /apps/gnome-power-manager/sleep_computer_ac      0
gconftool-2 --set --type string /apps/gnome-power-manager/sleep_computer_battery 0
gconftool-2 --set --type string /apps/gnome-power-manager/power                  interactive
share|improve this answer
    
thanks! two questions: 1. why do you use apt-get and not aptitude? I thought that aptitude is dealing with dependencies better? 2. How do you make the apt-get to not prompt the user with questions? –  Tibo Aug 14 '12 at 19:20
    
1. I always use apt-get. If you want to use aptitude go ahead. BUT mixing the 2 is bad practise ;) 2. these did not ask for confirmation but if needed you can add the -y option. –  Rinzwind Aug 14 '12 at 19:25
1  
aptitude is not even installed by default anymore. I don't know any reason to use it. Also.. be careful with the above script. It seems to have been written for older Ubuntu versions. –  mniess Aug 14 '12 at 19:32
    
@mniess where do you see that? –  Tibo Aug 14 '12 at 19:58
    
@tibo it was in 1 of the changelogs for 11.10 or 12.04 ;) man aptitude nowadays gives No manual entry for aptitude. –  Rinzwind Aug 14 '12 at 20:00

You can use Ubuntu One to sync installed applications between computers. The option is available in the software-center menu.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.