Wrote README and some additional comments and moved root-check

This commit is contained in:
Jack-Benny Persson 2014-01-11 17:56:19 +01:00
parent 99c8cff113
commit 905a258562
2 changed files with 25 additions and 10 deletions

12
README.md Normal file
View File

@ -0,0 +1,12 @@
# dpkg-frontend #
This is a simple frontend for dpkg (and apt-get) on Debian-based systems.
I wrote it as a part of a class assignment. The script uses Zenity to display
the GTK-dialogs and then executes diffrent commands for different things.
Note that when installing packages, this runs `apt-get install <PKG> -y`. This
means that all dependencies will be install without asking.
The script uses as few hardcoded path as possible and then finds the rest of the
binaries with `which` and puts them variables with the same name as the binarie
but with an uppercase initial letter.

View File

@ -171,13 +171,6 @@ $Which $i &> /dev/null
fi
done
# Check if we are root
if [ $EUID -ne 0 ]; then
$Zenity --title "dpkg-frontend" --error \
--text "You need to run <b>dpkg-frontend</b> as root"
exit 1
fi
# Parse command line options and arguments
while getopts Vvho: Opt; do
case "$Opt" in
@ -196,10 +189,18 @@ while getopts Vvho: Opt; do
esac
done
# Check if we are root
if [ $EUID -ne 0 ]; then
$Zenity --title "dpkg-frontend" --error \
--text "You need to run <b>dpkg-frontend</b> as root"
exit 1
fi
### Main ###
search_pkg
case $? in
1) exit 0
search_pkg # Start with search for a package.
case $? in # Do different things depending on return code
1) exit 0 # from the function search_pkg().
;;
5) $Zenity --title "dpkg-frontend" --question \
--text="Package <b>$Search</b> is not installed. Install it?"
@ -211,6 +212,8 @@ case $? in
;;
esac
# If the package that was searched for is installed on the system
# present different action to perform for the user.
choice_dialog
case $? in
11) uninstall_pkg