Sunday, April 28, 2024
 Popular · Latest · Hot · Upcoming
8
rated 0 times [  8] [ 0]  / answers: 1 / hits: 30837  / 1 Year ago, tue, january 10, 2023, 8:21:05

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 rich 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 they exists in the repositories) and to create multiple lines of aptitude install.



Then all I have to do after installing Ubuntu from scratch is to install aptitude and run the script.




  1. Will the script run one line 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?


More From » bash

 Answers
2

Yes on all 3 questions.



Regarding the last question on settings: you can use package dconf-tools (included in the example) for a lot of them. And gconftool-2 for some others (though that latter one is phased 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

[#36165] Wednesday, January 11, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
zombieptu

Total Points: 490
Total Questions: 121
Total Answers: 108

Location: Nepal
Member since Mon, Jan 4, 2021
3 Years ago
;