Add new is_installed function; fix bug preventing VNC server from being stopped

This commit is contained in:
Simon Long 2020-02-06 11:52:12 +00:00
parent b872f11509
commit 7535cdd94e

View File

@ -81,6 +81,14 @@ is_fkms() {
fi fi
} }
is_installed() {
if [ "$(dpkg -l "$1" 2> /dev/null | tail -n 1 | cut -d ' ' -f 1)" != "ii" ]; then
return 1
else
return 0
fi
}
deb_ver () { deb_ver () {
ver=`cat /etc/debian_version | cut -d . -f 1` ver=`cat /etc/debian_version | cut -d . -f 1`
echo $ver echo $ver
@ -803,7 +811,7 @@ do_vnc() {
RET=$1 RET=$1
fi fi
if [ $RET -eq 0 ]; then if [ $RET -eq 0 ]; then
if [ -d /usr/share/doc/realvnc-vnc-server ] || apt-get install realvnc-vnc-server; then if is_installed realvnc-vnc-server || apt install -y realvnc-vnc-server; then
systemctl enable vncserver-x11-serviced.service && systemctl enable vncserver-x11-serviced.service &&
systemctl start vncserver-x11-serviced.service && systemctl start vncserver-x11-serviced.service &&
STATUS=enabled STATUS=enabled
@ -811,10 +819,8 @@ do_vnc() {
return 1 return 1
fi fi
elif [ $RET -eq 1 ]; then elif [ $RET -eq 1 ]; then
if [ ! -d /usr/share/doc/realvnc-vnc-server ] ; then systemctl disable vncserver-x11-serviced.service
systemctl disable vncserver-x11-serviced.service systemctl stop vncserver-x11-serviced.service
systemctl stop vncserver-x11-serviced.service
fi
STATUS=disabled STATUS=disabled
else else
return $RET return $RET