[packages/tigervnc] cleanup & simplify
glen
glen at pld-linux.org
Thu Jul 18 22:38:13 CEST 2013
commit b09dcb235c504f2c8a93689f46379cf32f37e4aa
Author: Elan Ruusamäe <glen at delfi.ee>
Date: Thu Jul 18 23:37:47 2013 +0300
cleanup & simplify
vncserver.init | 116 ++++++++++++++++++++++++++++-----------------------------
1 file changed, 56 insertions(+), 60 deletions(-)
---
diff --git a/vncserver.init b/vncserver.init
old mode 100644
new mode 100755
index 88c85fa..393fa29
--- a/vncserver.init
+++ b/vncserver.init
@@ -7,7 +7,6 @@
# description: Starts and stops vncserver.
# Used to provide remote X administration services.
#
-# $Id$
# Source function library
. /etc/rc.d/init.d/functions
@@ -30,70 +29,70 @@ fi
start() {
# Check if the service is already running?
- if [ ! -f /var/lock/subsys/vncserver ]; then
- ulimit -S -c 0 >/dev/null 2>&1
- RETVAL=0
+ if [ -f /var/lock/subsys/vncserver ]; then
+ msg_already_running vncserver
+ return
+ fi
- if [ ! -d /tmp/.X11-unix ]
- then
- mkdir -m 1777 /tmp/.X11-unix || :
- restorecon /tmp/.X11-unix 2>/dev/null || :
- fi
+ ulimit -S -c 0 >/dev/null 2>&1
+ RETVAL=0
- NOSERV=1
- for display in $VNCSERVERS
- do
- msg_starting "vncserver ($display)"
- NOSERV=0
- DISP="${display%%:*}"
- USER="${display##*:}"
- if [ "x$USER" == "xroot" ]; then
- fail
- echo "-- Do not run vncserver as root!"
- continue
- fi
- VNCUSERARGS="${VNCSERVERARGS[${DISP}]}"
- USEREXISTS=`cat /etc/passwd | awk -F: "{ if (\"$USER\"==\\\$1) print \"yes\" }"`
- if [ "x$USEREXISTS" != "xyes" ]; then
- fail
- echo "-- User $USER does not exists!"
- continue
- fi
- USERHOME=`runuser $USER -c 'echo $HOME'`
- if [ ! -f "$USERHOME/.vnc/passwd" ]; then
- fail
- echo "-- No password file found for user $USER!"
- continue
- fi
- export USER VNCUSERARGS
- daemon --user ${USER} "vncserver :${DISP} ${VNCUSERARGS}"
- RETVAL=$?
- [ "$RETVAL" -eq 0 ] && echo $display >> /var/lock/subsys/vncserver && continue
- done
- else
- msg_already_running vncserver
+ if [ ! -d /tmp/.X11-unix ]; then
+ mkdir -m 1777 /tmp/.X11-unix || :
+ restorecon /tmp/.X11-unix 2>/dev/null || :
fi
+
+ NOSERV=1
+ for display in $VNCSERVERS; do
+ msg_starting "vncserver ($display)"
+ NOSERV=0
+ DISP="${display%%:*}"
+ USER="${display##*:}"
+ if [ "x$USER" == "xroot" ]; then
+ fail
+ echo "-- Do not run vncserver as root!"
+ continue
+ fi
+ VNCUSERARGS="${VNCSERVERARGS[${DISP}]}"
+ USEREXISTS=`cat /etc/passwd | awk -F: "{ if (\"$USER\"==\\\$1) print \"yes\" }"`
+ if [ "x$USEREXISTS" != "xyes" ]; then
+ fail
+ echo "-- User $USER does not exists!"
+ continue
+ fi
+ USERHOME=`runuser $USER -c 'echo $HOME'`
+ if [ ! -f "$USERHOME/.vnc/passwd" ]; then
+ fail
+ echo "-- No password file found for user $USER!"
+ continue
+ fi
+ export USER VNCUSERARGS
+ daemon --user ${USER} "vncserver :${DISP} ${VNCUSERARGS}"
+ RETVAL=$?
+ [ "$RETVAL" -eq 0 ] && echo $display >> /var/lock/subsys/vncserver
+ done
}
stop() {
- if [ -f /var/lock/subsys/vncserver ]; then
- # Stop daemons.
- ERRDISP=""
- for display in `cat /var/lock/subsys/vncserver`
- do
- msg_stopping "vncserver ($display)"
- export USER="${display##*:}"
- runuser ${USER} -c "vncserver -kill :${display%%:*}" >/dev/null 2>&1
- RETVAL=$?
- [ "$RETVAL" -eq 0 ] && ok && continue
- fail
- ERRDISP="$ERRDISP $display"
- done
- rm -f /var/lock/subsys/vncserver
- [ "x$ERRDISP" != "x" ] && echo "$ERRDISP" > /var/lock/subsys/vncserver
- else
+ if [ ! -f /var/lock/subsys/vncserver ]; then
msg_not_running vncserver
+ return
fi
+
+ # Stop daemons.
+ ERRDISP=""
+ for display in `cat /var/lock/subsys/vncserver`
+ do
+ msg_stopping "vncserver ($display)"
+ export USER="${display##*:}"
+ runuser ${USER} -c "vncserver -kill :${display%%:*}" >/dev/null 2>&1
+ RETVAL=$?
+ [ "$RETVAL" -eq 0 ] && ok && continue
+ fail
+ ERRDISP="$ERRDISP $display"
+ done
+ rm -f /var/lock/subsys/vncserver
+ [ "x$ERRDISP" != "x" ] && echo "$ERRDISP" > /var/lock/subsys/vncserver
}
RETVAL=0
@@ -121,6 +120,3 @@ case "$1" in
esac
exit $RETVAL
-
-# This must be last line !
-# vi:syntax=sh
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/tigervnc.git/commitdiff/b09dcb235c504f2c8a93689f46379cf32f37e4aa
More information about the pld-cvs-commit
mailing list