From 065795d198a8f98159cf7d6e40efb2209ed85d14 Mon Sep 17 00:00:00 2001 From: Jack-Benny Persson Date: Sat, 11 Jan 2014 13:16:17 +0100 Subject: [PATCH] Fixed missing indenting, vim messed it up? --- dpkg-frontend.sh | 120 ++++++++++++++++++++++++----------------------- 1 file changed, 61 insertions(+), 59 deletions(-) diff --git a/dpkg-frontend.sh b/dpkg-frontend.sh index 973e8bc..f50271f 100755 --- a/dpkg-frontend.sh +++ b/dpkg-frontend.sh @@ -27,6 +27,7 @@ Author="Jack-Benny Persson (jack-benny@cyberinfo.se)" # Binaries Which="/usr/bin/which" Aptget="/usr/bin/apt-get" + # Binaries entered in the list will be avalible to the script as variables with # the first letter uppercase Binaries=(dpkg sed awk egrep printf cat grep mktemp rm tail zenity) @@ -63,89 +64,90 @@ EOT # Dialog for package searching search_pkg() { -Search=`$Zenity --title "dpkg-frontend" --entry \ ---text="Search for package"` -if [ $? -eq 1 ]; then -return 1 -fi -$Dpkg --list | $Awk '{ print $2 }' | $Egrep -x $Search &> /dev/null -if [ $? -eq 0 ]; then -return 0 -else -return 5 -fi + Search=`$Zenity --title "dpkg-frontend" --entry \ + --text="Search for package"` + if [ $? -eq 1 ]; then + return 1 + fi + + $Dpkg --list | $Awk '{ print $2 }' | $Egrep -x $Search &> /dev/null + if [ $? -eq 0 ]; then + return 0 + else + return 5 + fi } uninstall_pkg() { -$Zenity --title "dpkg-frontend" \ ---question \ ---text="Package $Search is installed.\nUninstall ${Search}?" -if [ $? -eq 0 ]; then # CHANGE NEXT LINE -$Dpkg -r $Search | $Zenity --title "dpkg-frontend" \ ---progress --pulsate --text "Uninstalling ${Search}..." -fi + $Zenity --title "dpkg-frontend" \ + --question \ + --text="Package $Search is installed.\nUninstall ${Search}?" + if [ $? -eq 0 ]; then # CHANGE NEXT LINE + $Dpkg -r $Search | $Zenity --title "dpkg-frontend" \ + --progress --pulsate --text "Uninstalling ${Search}..." + fi } install_pkg() { -$Aptget install $Search -y | \ -$Zenity --title "dpkg-fronend" --progress --pulsate \ ---text "Installing package $Search" -if [ $? -eq 0 ]; then - $Zenity --title "dpkg-frontend" --info \ - --text="Succesfully installed $Search" - exit 0 -else - $Zenity --title "dpkg-frontend" --error \ - --text="Something went wrong with the installation of $Search" - exit 1 -fi + $Aptget install $Search -y | \ + $Zenity --title "dpkg-fronend" --progress --pulsate \ + --text "Installing package $Search" + if [ $? -eq 0 ]; then + $Zenity --title "dpkg-frontend" --info \ + --text="Succesfully installed $Search" + exit 0 + else + $Zenity --title "dpkg-frontend" --error \ + --text="Something went wrong with the installation of $Search" + exit 1 + fi } show_selections() { -Selections=`dpkg --get-selections $Search | awk '{ print $2 }'` -$Zenity --title "dpkg-frontend" \ ---info --text "Selections for $Search is: ${Selections}" + Selections=`$Dpkg --get-selections $Search | awk '{ print $2 }'` + $Zenity --title "dpkg-frontend" \ + --info --text "Selections for $Search is: ${Selections}" } set_selections() { -SetSelections=`$Zenity --title "dpkg-frontend" --entry \ ---text="Type selections for package $Search"` -echo "$Search $SetSelections" | $Dpkg --set-selections -if [ $? -eq 0 ]; then -$Zentiy --title "dpkg-frontend" --info \ ---text "${SetSelections} is set for ${Search}" -else -$Zenity --title "dpkg-frontend" --error \ ---text "Couldn't set selections for $Search" -fi + SetSelections=`$Zenity --title "dpkg-frontend" --entry \ + --text "Type selections for package $Search"` + echo "$Search $SetSelections" | $Dpkg --set-selections + if [ $? -eq 0 ]; then + $Zentiy --title "dpkg-frontend" --info \ + --text "${SetSelections} is set for ${Search}" + else + $Zenity --title "dpkg-frontend" --error \ + --text "Couldn't set selections for $Search" + fi } show_info() { -Info=`$Dpkg --status $Search` -$Zenity --no-markup --title "dpkg-frontend" --info \ ---text "$Info" + Info=`$Dpkg --status $Search` + $Zenity --no-markup --title "dpkg-frontend" --info \ + --text "$Info" } choice_dialog() { -Choice=`$Zenity --list --column=Action --column=Description \ ---radiolist uninstall "Uninstall" set "Set selections" \ -show "Show selections" \ -info "Show information"` -if [ "$Choice" == "Uninstall" ]; then -return 11 -elif [ "$Choice" == "Show selections" ]; then -return 12 -elif [ "$Choice" == "Show information" ]; then -return 13 -elif [ "$Choice" == "Set selections" ]; then -return 14 -fi + Choice=`$Zenity --list --column=Action --column=Description \ + --radiolist uninstall "Uninstall" set "Set selections" \ + show "Show selections" \ + info "Show information"` + if [ "$Choice" == "Uninstall" ]; then + return 11 + elif [ "$Choice" == "Show selections" ]; then + return 12 + elif [ "$Choice" == "Show information" ]; then + return 13 + elif [ "$Choice" == "Set selections" ]; then + return 14 + fi } # Create variables with absolute path to binaries and check