Need help to automate installation and customization

Questions about other topics - please check if your question fits better in another category before posting here
Forum rules
Before you post please read how to get help
Post Reply
User avatar
tovian
Level 5
Level 5
Posts: 529
Joined: Sun Nov 22, 2015 1:17 pm
Location: Heart of Dixie

Need help to automate installation and customization

Post by tovian » Sun May 13, 2018 2:24 pm

For many years I have had scripts to add all/most of the software and tweaks I want to apply to a new installation of Windows (XP, 7, 8, 10). I am finally trying to do something very similar for Linux/Mint. I will start with simple steps, then make it more complicated later. I am starting the development of this script/system on a computer running Mint-17.3/64-KDE. I want to build my automated post-installation system using BASH (mostly because that's all I know).

My first step is to identify the programs I want to add to the basic (initial) Mint/KDE installation (or other DE if I need to change DE's later). I have most of this done. Although some of these may already be installed, I want to make sure they are in place or I want this process to add them. This set includes programs like Firefox, Thunderbird, Samba, Smbclient, IPscan, Grub-customizer, apt, aptitude, etc. - about 50 "must-haves".

Next I want to compare this list to a list of "already installed" programs. I found an "aptitude" command that builds this list fairly well and is very simple to use.

Code: Select all

tmpfile=/tmp/instapps.txt
rm "$tmpfile" >/dev/null 2>&1
aptitude -F' * %p -> %d ' --no-gui --disable-columns search '?and(~i,!?section(libs), !?section(kernel), !?section(devel))' > $tmpfile
Lastly, I want to invoke "apt-get..." to install any software that is not already installed (no match when the lists are compared). I know I will also have to have another list and special routines to add PPA's for some things (Grub-customizer, IPscan, etc.). I don't anticipate that being a problem.

My first big problem is in trying to programatically (inside the script) determine all the components that need to be manually installed for each program. For example, it's not a problem to identify and install Geany, but that installation will not AUTOMATICALLY bring in any of the Geany-plugins I need. It's also easy to install Firefox, but Firefox has a language-pack that might also need to be manually installed. APT has a number of separate components. Which ones come in automatically and which ones need to be installed manually? (APT is a rather poor example since none of this will work if APT is not already installed, but the principle of identifying the components is valid - and APT has several). If I cannot do this programatically I will have to use the special list for PPA's (above) as a way to identify all the components that have to be manually installed - and that list will have to be manually populated and updated.

Has anyone written a system similar to this? (Even parts/subroutines would be helpful) Does anyone have any other suggestions?
“I think that this situation absolutely requires a really futile and stupid gesture be done on somebody's part!"
"We're just the guys to do it.”

Animal House

User avatar
smurphos
Level 8
Level 8
Posts: 2005
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher...

Re: Need help to automate installation and customization

Post by smurphos » Wed May 16, 2018 2:58 am

Hi Tovian,

I think you might be overcomplicating some things.

I'd simply approach this with an apt-get and the 'master' list of packages having added any relevant PPAs. If they are already installed it does no harm, if not it will install them. No need to try and get a subset of missing packages from the master list to feed to apt-get.

Extras like plugins etc not in repos/PPAs you'll need to wget or curl or git clone from the relevant source in your script and then unzip or mv to the correct location.

Personally, I think the time taken to write/test these types of post install scripts is wasted unless you are a frequent reinstaller or are in the business of helping others install Mint and have come up with one size fits all script. Still it is a good learning experience.....

Hoser Rob
Level 12
Level 12
Posts: 4313
Joined: Sat Dec 15, 2012 8:57 am

Re: Need help to automate installation and customization

Post by Hoser Rob » Wed May 16, 2018 9:07 am

Yes, I'm sure this would be a good learning experience.

But the trouble with something like this is that unless you're pretty expert in Linux, it will take so long to fix any mistakes you make that just doing it manually will probably take less time. And AFAIK Linux pros do this sort of thing manually.

There are other good learning experiences that can be a lot safer for your machine.

User avatar
tovian
Level 5
Level 5
Posts: 529
Joined: Sun Nov 22, 2015 1:17 pm
Location: Heart of Dixie

Re: Need help to automate installation and customization

Post by tovian » Wed May 16, 2018 11:44 am

Thank You for both those replies.

First, more than anything else the primary goal is, indeed, a learning experience. I used to do a LOT of Windows installations so I developed a set of scripts that did 99% of my post-install customizations. My system was never perfect, but it was/is good and has saved me a TON of time over the years.

Second, as part of the learning experience, I wanted to see if I could more-or-less replicate what I had done on the Windows side. I seem to learn more - or learn better - when I can actually see face-to-face differences between Windows things (which I know) and Linux things (which I am learning).

I may not ever use the system I am working on "for real", but I've already learned from my script testing and from the replies in this thread.

Thanks, again !!
“I think that this situation absolutely requires a really futile and stupid gesture be done on somebody's part!"
"We're just the guys to do it.”

Animal House

User avatar
tovian
Level 5
Level 5
Posts: 529
Joined: Sun Nov 22, 2015 1:17 pm
Location: Heart of Dixie

Re: Need help to automate installation and customization

Post by tovian » Thu May 24, 2018 7:35 pm

Making some progress.

I have more questions:
I'm assuming I can call apt from inside a bash script.
If I call apt to do things (add a ppa, install a program, uninstall a program)...
- Can I queue the requests or do I have to make a single call for each action?
- Do I have to supply the admin password with each call?

Any other tips for calling apt from a (bash) script?
“I think that this situation absolutely requires a really futile and stupid gesture be done on somebody's part!"
"We're just the guys to do it.”

Animal House

User avatar
smurphos
Level 8
Level 8
Posts: 2005
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher...

Re: Need help to automate installation and customization

Post by smurphos » Thu May 24, 2018 10:39 pm

The long form commands i.e. apt-get are recommended for scripts. The 18.3 version of mint app has a small bug that causes problems if it's run outside of a tty so should be avoided for script use.

Re sudo requirments you can just run the whole script as sudo and include a quick check for sudo in the script...https://ubuntuforums.org/showthread.php?t=479255

Or you can use sudo or gksudo in the script e.g

- https://askubuntu.com/questions/746350/ ... -a-script/

Hoser Rob
Level 12
Level 12
Posts: 4313
Joined: Sat Dec 15, 2012 8:57 am

Re: Need help to automate installation and customization

Post by Hoser Rob » Sat May 26, 2018 11:36 am

Linux is different enough from Windows that trying to "see if I could more-or-less replicate what I had done on the Windows side" is a bit pointless. Professional Linux IT people don't of this kind of thing much.

User avatar
tovian
Level 5
Level 5
Posts: 529
Joined: Sun Nov 22, 2015 1:17 pm
Location: Heart of Dixie

Re: Need help to automate installation and customization

Post by tovian » Sat May 26, 2018 11:54 am

Hoser Rob wrote:
Sat May 26, 2018 11:36 am
Professional Linux IT people don't of this kind of thing much.
Sewing a "I'm a NON Professional Linux IT person" patch onto the top pocket of my navy-blue wool blazer right now. I'll get one for my Biker-Club "colors" later.

I guess everybody does the best he/she can.
“I think that this situation absolutely requires a really futile and stupid gesture be done on somebody's part!"
"We're just the guys to do it.”

Animal House

Post Reply

Return to “Other topics”