Automatically install package with “apt-get install”, clean exit if it failsBy neokrates, written on July 19, 2010 |
bash snippet |
- neokrates
- Email: uwarov@yahoo.com
- Website: http://www.thinkplexx.com
- Join date: 05-31-09
- Posts: 20
Rate it
Ad
Poll
Your favorite way to manage packages is?
- Something else (100%, 9 Votes)
- Tarball command Line (0%, 0 Votes)
- Debian Dpkg command Line (0%, 0 Votes)
- Manually (0%, 0 Votes)
- Synaptic (0%, 0 Votes)
- Adept (0%, 0 Votes)
- Apt-get command line (0%, 0 Votes)
Total Voters: 9
Loading ...
Most popular search terms:
apt-get install with some options and scripting results in nice pattern for package installation. For example, this can help to make your script FAI – ready, because this tool is very sensitive to any ‘chaotic’ script output.
What we need:
- Function to check the last operation success or die
quitOnError - Suppress the apt-get user interaction
--force-yes --yes - Suppress any standard output (we only need to know if it worked or not)
> /dev/null 2>&1 ;
Install the improved random number generator for Linux (rng-tools), clean quit if no install was possible.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #!/bin/bash function quitOnError { if [ $? -gt 0 ] then echo -e "\n\n $@ ...FAIL" exit 10 else echo "$@ ...OK" fi } apt-get install --force-yes --yes rng-tools > /dev/null 2>&1 ; quitOnError "Installing rng tools now" echo "rng tools installed, /etc/init.d/rng-tools start to increase you linux system entropy level" |
|
TAGS
|
|
SOCIAL
|


















