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 @@
# License version 2. This program is licensed "as is" without any
# 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
{
#------------------------------------------------------------------------------------------------------------------------------------------
......@@ -50,19 +52,23 @@ function choose_webserver
#------------------------------------------------------------------------------------------------------------------------------------------
# Target web server selection
#------------------------------------------------------------------------------------------------------------------------------------------
if [ -f /etc/default/openmediavault ]; then
# OMV installed, prevent switching from nginx to apache which would trash OMV installation
server="nginx"
else
dialog --title "Choose a webserver" --backtitle "$backtitle" --yes-label "Apache" --no-label "Nginx" \
--yesno "\nChoose a web server which you are familiar with. They both work almost the same." 8 70
response=$?
case $response in
0) server="apache";;
1) server="nginx";;
255) exit;;
esac
fi
check_if_installed openmediavault
case $? in
0)
# OMV installed, prevent switching from nginx to apache which would trash OMV installation
server="nginx"
;;
*)
dialog --title "Choose a webserver" --backtitle "$backtitle" --yes-label "Apache" --no-label "Nginx" \
--yesno "\nChoose a web server which you are familiar with. They both work almost the same." 8 70
response=$?
case $response in
0) server="apache";;
1) server="nginx";;
255) exit;;
esac
;;
esac
}
......@@ -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
......
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