Commit 5f52776a authored by ThomasKaiser's avatar ThomasKaiser
Browse files

Provide a saner way to get installation status of certain packages

parent 4ba72249
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
# License version 2. This program is licensed "as is" without any # License version 2. This program is licensed "as is" without any
# warranty of any kind, whether express or implied. # warranty of any kind, whether express or implied.
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
function check_status function check_status
{ {
#------------------------------------------------------------------------------------------------------------------------------------------ #------------------------------------------------------------------------------------------------------------------------------------------
...@@ -50,19 +52,23 @@ function choose_webserver ...@@ -50,19 +52,23 @@ function choose_webserver
#------------------------------------------------------------------------------------------------------------------------------------------ #------------------------------------------------------------------------------------------------------------------------------------------
# Target web server selection # Target web server selection
#------------------------------------------------------------------------------------------------------------------------------------------ #------------------------------------------------------------------------------------------------------------------------------------------
if [ -f /etc/default/openmediavault ]; then check_if_installed openmediavault
# OMV installed, prevent switching from nginx to apache which would trash OMV installation case $? in
server="nginx" 0)
else # OMV installed, prevent switching from nginx to apache which would trash OMV installation
dialog --title "Choose a webserver" --backtitle "$backtitle" --yes-label "Apache" --no-label "Nginx" \ server="nginx"
--yesno "\nChoose a web server which you are familiar with. They both work almost the same." 8 70 ;;
response=$? *)
case $response in dialog --title "Choose a webserver" --backtitle "$backtitle" --yes-label "Apache" --no-label "Nginx" \
0) server="apache";; --yesno "\nChoose a web server which you are familiar with. They both work almost the same." 8 70
1) server="nginx";; response=$?
255) exit;; case $response in
esac 0) server="apache";;
fi 1) server="nginx";;
255) exit;;
esac
;;
esac
} }
...@@ -932,6 +938,18 @@ echo "PHPmyadmin: http://$serverIP:8081/phpmyadmin" ...@@ -932,6 +938,18 @@ echo "PHPmyadmin: http://$serverIP:8081/phpmyadmin"
} }
check_if_installed (){
#------------------------------------------------------------------------------------------------------------------------------------------
# check dpkg status of $1 -- currently only 'not installed at all' case catched
#------------------------------------------------------------------------------------------------------------------------------------------
local DPKG_Status="$(dpkg -s "$1" 2>/dev/null | awk -F": " '/^Status/ {print $2}')"
if [ "X${DPKG_Status}" = "X" ]; then
return 1
else
return 0
fi
}
#------------------------------------------------------------------------------------------------------------------------------------------ #------------------------------------------------------------------------------------------------------------------------------------------
# Main choices # Main choices
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment