From 905a258562d43a98129144cdc4a7d6f19464e4c2 Mon Sep 17 00:00:00 2001 From: Jack-Benny Persson Date: Sat, 11 Jan 2014 17:56:19 +0100 Subject: [PATCH] Wrote README and some additional comments and moved root-check --- README.md | 12 ++++++++++++ dpkg-frontend.sh | 23 +++++++++++++---------- 2 files changed, 25 insertions(+), 10 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..10d8a2d --- /dev/null +++ b/README.md @@ -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 -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. + + diff --git a/dpkg-frontend.sh b/dpkg-frontend.sh index 4f7f391..ee009a3 100755 --- a/dpkg-frontend.sh +++ b/dpkg-frontend.sh @@ -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 dpkg-frontend 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 dpkg-frontend 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 $Search 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