network shenanigans or just smoke and mirrors

Automated Ubuntu Package Installations

January 7th, 2009 by geezer

The other day I found myself working on an installation script for a program that required a number of software packages from Ubuntu’s repositories.

After a couple hours of continually hitting the “y” button during testing, I finally figured out a method to automate the process without user interaction. You use a “-y” flag with apt-get (it pays to read the man pages!).

So if you’re looking for an automated way to download and install packages from within a Bash script, feel free to use this function I whipped up. Of course, if you have ways to improve it, please post some comments!

Be sure to add the packages you need to the script! Those are the one’s I needed. I’m sure your needs are different.

Enjoy!

#/bin/bash

functionInstall ()
{
     clear
     packages=(build-essential libpcap-dev bison flex libgtk2.0-dev)
     echo "Downloading and installing packages."
     echo
     for i in "${packages[@]}"; do
          echo "     * $i... "
          /usr/bin/apt-get -y install $i &> /dev/null
          echo "done."
     exit 0
}

Posted in Chatter | No Comments »

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.