xenopeek wrote:Moved here by moderator
I'd make a few changes, to make it do steps without confirmation and to fully remove packages (including now unneeded dependencies). Perhaps include script header that automatically makes the script run from the terminal if not started from there (and it pauses after completion before closing the terminal). Now all it is missing is a way to check if the script was started as root (else it won't do anything of course).
Code: Select all
#!/bin/bash
# if the script was not launched from a terminal, restart it from a terminal
if [[ ! -t 0 ]] && [[ -x /usr/bin/x-terminal-emulator ]]; then
/usr/bin/x-terminal-emulator -e "bash -c \"$0 $*; read -s -p 'Press enter to continue...'\""
exit
fi
echo "Installing Applications"
echo
apt-get --assume-yes install audacity devede xsensors pithos deluge dropbox openshot xvidcap cheese
echo
echo "Detecting Sensors (for xsensors) - Answer All Questions with 'YES'."
sensors-detect
echo
echo "Removing Unwanted Application"
echo
apt-get --assume-yes --purge autoremove transmission-gtk libreoffice-core
apt-get --assume-yes --purge autoremove
apt-get autoclean
apt-get clean
echo
echo "Installation and Uninstallation Complete"
echo
echo "Enjoy Linux Mint!"
echo
Pilosopong Tasyo wrote:xenopeek wrote:Now all it is missing is a way to check if the script was started as root (else it won't do anything of course).
Code: Select all
...
if [ `whoami` = "root" ]
then
...
else
echo "Run me as as root."
fi
...
I personally believe in convienence. What i usually do is to ask for the password first in a script, and add sudo to each line (that might be troublesome, but it is worth the effort. More effort on scripting for your users' less effort.
)
Also, sudo dpkg --configure -a should be used in case of interrupted installation of programs from another time.
Here's my version:
Code: Select all
#!/bin/bash
# if the script was not launched from a terminal, restart it from a terminal
if [[ ! -t 0 ]] && [[ -x /usr/bin/x-terminal-emulator ]]; then
/usr/bin/x-terminal-emulator -e "bash -c \"$0 $*; read -s -p 'Press enter to continue...'\""
exit
fi
echo "Installing Applications"
echo
sudo dpkg --configure -a
clear
sudo apt-get -q=1 -y install audacity devede xsensors pithos deluge dropbox openshot xvidcap cheese deborphan preload
clear
echo
echo "Detecting Sensors (for xsensors) - Answer All Questions with 'YES'."
sudo sensors-detect
echo
echo "Removing Unwanted Application"
echo
sudo apt-get -q=1 -y --purge autoremove transmission-gtk libreoffice-core brltty brltty-x11 foo2zjs gwibber gwibber-service hplip hplip-cups hplip-data hpijs min12xxw pxljr splix ttf-indic-fonts-core ttf-kacst-one ttf-khmeros-core ttf-lao ttf-punjabi-fonts ttf-unfonts-core
sudo apt-get -q=1 -y --purge autoremove
sudo apt-get -q=1 autoclean
sudo apt-get -q=1 clean
clear
echo
echo "Installation and Uninstallation Complete"
echo
echo "Cleaning starts now!"
echo
## wei2912's cleanPackages script
### Start of removing old packages ###
sudo deborphan | xargs sudo apt-get -y remove --purge
sudo apt-get -q=1 -y autoremove --purge
dpkg --list |grep "transitional" | cut -d " " -f 3 | xargs sudo dpkg --purge #Transitional packages
dpkg --list |grep "meta" | cut -d " " -f 3 | xargs sudo dpkg --purge #Meta packages
### End of removing old packages ###
### Start of removing residual config ###
dpkg --list |grep "^rc" | cut -d " " -f 3 | xargs sudo dpkg --purge
### End of removing residual config ###
### Start of removing downloaded deb files ###
sudo apt-get -q=1 autoclean
sudo aptitude -q=1 autoclean
### End of removing downloaded deb files ###
#Clean up cache
sudo apt-get -q=1 clean
sudo aptitude -q=1 clean
clear
echo "Enjoy Linux Mint!"
echo "Press enter to exit."
read enter
Feel free to remove the "#wei2912's cleanPackages script" part. If you are still going to use my cleaning script, please add me in the credits. Also, DO NOT REMOVE DEBORPHAN FROM THE INSTALLATION PART, OR ELSE MY SCRIPT WILL FAIl.
One more thing. I feel that you should register this under the GPL license.
All you need to do is to add this section to the top of your script:
Code: Select all
## COPYRIGHT
##
## These scripts are registed under the GNU General Public License v3.0.
##
## Copyright (C) <year> <name of author>
##
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
And a page you might be interested in for reinstalling (but it requires the software list of the previous installation)
http://www.cyberciti.biz/tips/linux-get ... store.html
mintBackup can do the job too, but you probably don't want it to popup half-way in your script. So its better to do by commands.
Cons:
It requires a backup file.
Unneeded software which is no longer in the new release might be installed.'
Finally, here's one more of my scripts (lol) for PPAs:
Code: Select all
#!/bin/bash
sudo dpkg --configure -a
clear
while true;do
clear
echo "Please select PPAs to install by typing out the number. If you have no more PPAs to install, type 'd' and press enter."
echo "1) New overlay scrollbars."
echo "2) Gnomenu for gtk 2.0."
echo "3) Opera browser"
echo "4) Banshee (Stable) music player"
echo "5) Banshee (Unstable) music player"
echo "6) Y PPA Manager"
echo "7) Pinta painter"
echo ""
read answer
case "$answer" in
1)
echo ""
echo "Adding overlay scrollbars..."
sudo apt-add-repository 'deb http://ppa.launchpad.net/ayatana-scrollbar-team/release/ubuntu oneiric main'
echo ""
echo "Now you can install them by typing out this command after this script finishes:"
echo "sudo apt-get install overlay-scrollbars"
echo "If the package is already installed, the remaining part of the script will upgrade it."
echo ""
echo "Press enter to proceed."
read enter
clear
;;
2)
echo ""
echo "Adding Gnomenu ppa..."
sudo apt-add-repository 'deb http://ppa.launchpad.net/gnomenu-team/ppa/ubuntu natty main '
echo ""
echo "Now you can install them by typing out this command after this script finishes:"
echo "sudo apt-get install gnomenu"
echo "If the package is already installed, the remaining part of the script will upgrade it."
echo ""
echo "Press enter to proceed."
read enter
clear
;;
3)
echo ""
echo "Adding Opera"
wget -O - http://deb.opera.com/archive.key | sudo apt-key add -
sudo add-apt-repository 'deb http://deb.opera.com/opera/ stable non-free'
echo ""
echo "Now you can install them by typing out this command after this script finishes:"
echo "sudo apt-get install opera"
echo "If the package is already installed, the remaining part of the script will upgrade it."
echo ""
echo "Press enter to proceed."
read enter
clear
;;
4)
echo ""
echo "Adding Banshee (Stable)"
sudo add-apt-repository 'deb http://ppa.launchpad.net/banshee-team/ppa/ubuntu oneiric main'
echo ""
echo "Now you can install them by typing out this command after this script finishes:"
echo "sudo apt-get install banshee"
echo "If the package is already installed, the remaining part of the script will upgrade it."
echo ""
echo "Press enter to proceed."
read enter
clear
;;
5)
echo ""
echo "Adding Banshee (Unstable)"
sudo add-apt-repository 'deb http://ppa.launchpad.net/banshee-team/banshee-unstable/ubuntu oneiric main '
echo ""
echo "Adding Banshee Extensions PPA (same as Banshee Stable ppa)"
sudo add-apt-repository 'deb http://ppa.launchpad.net/banshee-team/ppa/ubuntu oneiric main'
echo ""
echo "Now you can install them by typing out this command after this script finishes:"
echo "sudo apt-get install banshee"
echo "Extensions can be installed by searching for banshee-extensions-<extension name>."
echo "If the package is already installed, the remaining part of the script will upgrade it."
echo ""
echo "Press enter to proceed."
read enter
clear
;;
6)
echo ""
echo "Adding Y PPA Manager"
sudo add-apt-repository 'deb http://ppa.launchpad.net/webupd8team/y-ppa-manager/ubuntu oneiric main'
echo ""
echo "Now you can install them by typing out this command after this script finishes:"
echo "sudo apt-get install y-ppa-manager"
echo "If the package is already installed, the remaining part of the script will upgrade it."
echo ""
echo "Press enter to proceed."
read enter
clear
;;
7)
echo ""
echo "Adding Pinta"
sudo add-apt-repository ppa:nilarimogard/webupd8
echo ""
echo "Now you can install them by typing out this command after this script finishes:"
echo "sudo apt-get install pinta"
echo "If the package is already installed, the remaining part of the script will upgrade it."
echo ""
echo "Press enter to proceed."
read enter
clear
;;
d)
clear
sudo apt-get update
sudo aptitude dist-upgrade
sudo apt-get clean
echo "Cleaning your system with the cleanPackages script... To cancel, please close the terminal window now."
echo "If you would like to continue, press enter."
read enter
./cleanPackages.sh
;;
esac
done
You can add it to the script, but remember to edit the last part so that it won't launch a non-existent script.
Hope I get to see more advancements in this script. I'm interested in using it.