Logo 
Search:

Unix / Linux / Ubuntu Forum

Ask Question   UnAnswered
Home » Forum » Unix / Linux / Ubuntu       RSS Feeds

Using a script to automate apt installation

  Date: Feb 11    Category: Unix / Linux / Ubuntu    Views: 571
  

Having the following in a script called install.sh

#!/bin/bash

apt-get install synaptic
apt-get install mysql-client-core-5.1
apt-get install mysql-cluster-client-5.1

Executing in the CLI

sudo ./install.sh

This works but for each apt I need to enter a 'y' to get the apt to be
downloaded and installed. How can this be automated so I do not have to baby set
the script and give a 'y' permission each program?

Is there a better way to write and execute the script?

Is a 'sudo' needed on the command line?

Share: 

 

9 Answers Found

 
Answer #1    Answered On: Feb 11    

From the command "man apt-get"

Quote------
-y, --yes, --assume-yes Automatic yes to prompts. Assume "yes" as answer to
all prompts and run non-interactively. If an undesirable situation, such as
changing a held package or removing an essential package, occurs then
apt-get will abort. Configuration Item: APT::Get::Assume-Yes.
-----end-quote

I'm on mobile so got the man page off the net. Looks right though. Your
commands would then be like :

apt-get -y install synaptic

And so on then you should be good to go.

 
Answer #2    Answered On: Feb 11    

One other note regarding use of apt-get in a script or invoked at CL,
you should not need a separate line for each program... space
separated works good as far as I know.

> apt-get -y install synaptic mysql-client-core-5.1 mysql-cluster-client-5.1

works just as well as

> apt-get install synaptic
> apt-get install mysql-client-core-5.1
> apt-get install mysql-cluster-client-5.1

 
Answer #3    Answered On: Feb 11    

Well, that worked just exactly like you said. Now I can create a shell
script to install all the software I add after Ubuntu is installed. Seems
to me like I do a lot of installs, or should I say re-installs. I still
think Linux is not ready for prime-time of the masses. Then again many of
us are backyard mechanics. Like Red Green says, "if it ain't broke you
ain't trying". We are always fixing something, adding something, mak'n it
better or any combination thereof. And THERE lies the problem!

After the install, I attempted to install over the previous install. The
jest of what it said, "nothing to do".

 
Answer #4    Answered On: Feb 11    

My method is to save a copy of my sources to my home folder and to save a
list of installed packages. Post installation I update my sources list then
go to Synaptic and open my list of installed packages, then I walk away
from the computer for a couple of hours and I am back to where I was
previously, except with a new version. I have even changed distros this
way, although still within the apt family.

 
Answer #5    Answered On: Feb 11    

I was trying to do this last weekend and couldn't figure out how the
create the list from Synaptic Manager, is that what I use or some
option from the apt-get command to create the list? I do enough of the
trying of new different distros that it would make it easier. I did
nearly the same thing by making a list on paper and entering the
command manually.

 
Answer #6    Answered On: Feb 11    

This is the script I now use as a result of the above thread.
There is the first 'echo' line,
The apt-get - y install ('LINE' is one line all though it may be on two
lines.)
Then the last 'echo' line.

Cut and paste, replacing my apts with your apts.

#!/bin/bash

echo "**Installing software
***********************************************"
apt-get -y install arduino cheese g++ flashplugin-installer idle k3b
mysql-client-core-5.1 mysql-cluster-client-5.1 php5 python3 qcad gimp
sound-juicer synaptic
echo "**Software installation complete ************************************"

I finally figured this out. Makes re-installing Ubuntu not so much a
pain-in-the-a--. Just couldn't figured where to place the 'y' to force it
down apt-get's throat.

 
Answer #7    Answered On: Feb 11    

Saving the list of applications in Synaptic is dead simple. File, Save
markings. Check the box at the bottom to save Full state (not just
changes). Put the file somewhere safe in your home directory if you have a
separate home or on an external device otherwise. Post installation, it is
Read markings and navigate to the file. I always update my sources list
first, otherwise it will only install packages in the repositories and
ignore external sources, like medibuntu, get-deb, Google, PPAs.

You can do the same from the commandline, but I hate navigating folders and
drives from the commandline and then have to move it with the file manager
after which seems to be more work.

 
Answer #8    Answered On: Feb 11    

That is a real jewel!
How do you update the sources/installed file list?

 
Answer #9    Answered On: Feb 11    

Good old fashioned text editing as su. In the old sources, I cut out
references to Ubuntu repos which are grouped. Then replace the word natty
with oneiric for example then copy the remainder to the end of the new
sources. I save and it usually works. If get errors then I ignore them or
troubleshoot. It is harder than it used to be because not everything is in
sources.lst.

 
Didn't find what you were looking for? Find more on Using a script to automate apt installation Or get search suggestion and latest updates.




Tagged: