You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

vncserver.service 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #!/bin/bash
  2. #
  3. # Init file for TigerVNC Server
  4. #
  5. # Written by Dag Wieers <dag@wieers.com>
  6. #
  7. # chkconfig: - 91 35
  8. # description: TigerVNC remote X administration daemon.
  9. #
  10. # processname: Xvnc
  11. source /etc/rc.d/init.d/functions
  12. source /etc/sysconfig/network
  13. # Check that networking is up.
  14. [ ${NETWORKING} = "no" ] && exit 1
  15. [ -x /usr/bin/Xvnc ] || exit 1
  16. ### Default variables
  17. SYSCONFIG="/etc/sysconfig/vncservers"
  18. VNCSERVERS=""
  19. ### Read configuration
  20. [ -r "$SYSCONFIG" ] && source "$SYSCONFIG"
  21. RETVAL=0
  22. prog="Xvnc"
  23. desc="TigerVNC remote administration daemon"
  24. start() {
  25. echo -n $"Starting $desc ($prog):"
  26. ulimit -S -c 0 &>/dev/null
  27. for display in ${VNCSERVERS}; do
  28. echo -n "${display} "
  29. unset BASH_ENV ENV
  30. initlog $INITLOG_ARGS -c \
  31. "su ${display##*:} -c \"cd ~${display##*:} && [ -f .vnc/passwd ] && vncserver :${display%:*} ${VNCSERVERARGS[${display%:*}]}\""
  32. RETVAL=$?
  33. [ "$RETVAL" -ne 0 ] && break
  34. done
  35. [ "$RETVAL" -eq 0 ] && success $"vncserver startup" || failure $"vncserver start"
  36. echo
  37. [ "$RETVAL" -eq 0 ] && touch /var/lock/subsys/$prog
  38. return $RETVAL
  39. }
  40. stop() {
  41. echo -n $"Shutting down $desc ($prog): "
  42. for display in ${VNCSERVERS}; do
  43. echo -n "${display} "
  44. unset BASH_ENV ENV
  45. initlog $INITLOG_ARGS -c \
  46. "su ${display##*:} -c \"vncserver -kill :${display%:*}\" &>/dev/null"
  47. done
  48. RETVAL=$?
  49. [ "$RETVAL" -eq 0 ] && success $"vncserver shutdown" || failure $"vncserver shutdown"
  50. echo
  51. [ "$RETVAL" -eq 0 ] && rm -f /var/lock/subsys/$prog
  52. return $RETVAL
  53. }
  54. restart() {
  55. stop
  56. start
  57. }
  58. case "$1" in
  59. start)
  60. start
  61. ;;
  62. stop)
  63. stop
  64. ;;
  65. restart|reload)
  66. restart
  67. ;;
  68. condrestart)
  69. [ -e /var/lock/subsys/$prog ] && restart
  70. RETVAL=$?
  71. ;;
  72. status)
  73. status $prog
  74. RETVAL=$?
  75. ;;
  76. *)
  77. echo $"Usage: $0 {start|stop|restart|condrestart|status}"
  78. RETVAL=1
  79. esac
  80. exit $RETVAL