VNC-Server mit Autostart unter Mandriva: Unterschied zwischen den Versionen

Aus Linupedia.org
Wechseln zu: Navigation, Suche
 
(Eine dazwischenliegende Version desselben Benutzers wird nicht angezeigt)
Zeile 5: Zeile 5:
 
'''1)''' Man schreibe sich ein Skript (einfach folgenden Quelltext in eine leere Datei kopieren und sie "vncserver" nennen)  
 
'''1)''' Man schreibe sich ein Skript (einfach folgenden Quelltext in eine leere Datei kopieren und sie "vncserver" nennen)  
  
Quelltext:
 
-------------
 
 
  #!/bin/bash  
 
  #!/bin/bash  
  # chkconfig: - 91 35  
+
#
  # description: Starts and stops vncserver. \  
+
  # chkconfig: - 91 35  
 +
  # description: Starts and stops vncserver. \  
 
  # used to provide remote X administration services.  
 
  # used to provide remote X administration services.  
 +
 
  # Source function library.  
 
  # Source function library.  
 
  . /etc/init.d/functions  
 
  . /etc/init.d/functions  
 +
 
  # Source networking configuration.  
 
  # Source networking configuration.  
 
  . /etc/sysconfig/network  
 
  . /etc/sysconfig/network  
 +
 
  # Check that networking is up.  
 
  # Check that networking is up.  
  #91; ${NETWORKING} = "no" ] && exit 0  
+
  [ ${NETWORKING} = "no" ] && exit 0  
  VNCSERVERS=""
+
  -f /etc/sysconfig/vncservers ] && . /etc/sysconfig/vncservers  
+
  VNCSERVERS=""
  prog=$"VNC server"
+
  [ -f /etc/sysconfig/vncservers ] && . /etc/sysconfig/vncservers  
  start() {
+
  echo -n $"Starting $prog: "
+
  prog=$"VNC server"
  ulimit -S -c 0 >/dev/null 2>&1  
+
 +
  start() {
 +
  echo -n $"Starting $prog: "
 +
  ulimit -S -c 0 >/dev/null 2>&1  
 
  RETVAL=0  
 
  RETVAL=0  
  for display in ${VNCSERVERS}
+
  for display in ${VNCSERVERS}
 
  do  
 
  do  
  echo -n "${display} "
+
  echo -n "${display} "
 
  unset BASH_ENV ENV  
 
  unset BASH_ENV ENV  
 
  initlog $INITLOG_ARGS -c \  
 
  initlog $INITLOG_ARGS -c \  
  "su ${display##*:} -l -c \"cd ~${display##*:} && [ -f .vnc/passwd ] && vncserver :${display%%:*}\""
+
  "su ${display##*:} -l -c \"cd ~${display##*:} && [ -f .vnc/passwd ] && vncserver :${display%%:*}\""
 
  RETVAL=$?  
 
  RETVAL=$?  
  [ "$RETVAL" -ne 0 ] && break  
+
  [ "$RETVAL" -ne 0 ] && break  
 
  done  
 
  done  
  [ "$RETVAL" -eq 0 ] && success $"vncserver startup" || \  
+
  [ "$RETVAL" -eq 0 ] && success $"vncserver startup" || \  
  failure $"vncserver start"
+
  failure $"vncserver start"
 
  echo  
 
  echo  
  [ "$RETVAL" -eq 0 ] && touch /var/lock/subsys/vncserver  
+
  [ "$RETVAL" -eq 0 ] && touch /var/lock/subsys/vncserver  
  }
+
  }
  stop() {
+
  echo -n $"Shutting down $prog: "
+
  stop() {
  for display in ${VNCSERVERS}
+
  echo -n $"Shutting down $prog: "
 +
  for display in ${VNCSERVERS}
 
  do  
 
  do  
  echo -n "${display} "
+
  echo -n "${display} "
 
  unset BASH_ENV ENV  
 
  unset BASH_ENV ENV  
 
  initlog $INITLOG_ARGS -c \  
 
  initlog $INITLOG_ARGS -c \  
  "su ${display##*:} -c \"vncserver -kill :${display%%:*}\" >/dev/null 2>&1"
+
  "su ${display##*:} -c \"vncserver -kill :${display%%:*}\" >/dev/null 2>&1"
 
  done  
 
  done  
 
  RETVAL=$?  
 
  RETVAL=$?  
  [ "$RETVAL" -eq 0 ] && success $"vncserver shutdown" || \  
+
  [ "$RETVAL" -eq 0 ] && success $"vncserver shutdown" || \  
  failure $"vncserver shutdown"
+
  failure $"vncserver shutdown"
 
  echo  
 
  echo  
  [ "$RETVAL" -eq 0 ] && rm -f /var/lock/subsys/vncserver  
+
  [ "$RETVAL" -eq 0 ] && rm -f /var/lock/subsys/vncserver  
  }
+
  }
 +
 
  # See how we were called.  
 
  # See how we were called.  
  case "$1" in  
+
  case "$1" in  
  start)
+
  start)
 
  start  
 
  start  
 
  ;;  
 
  ;;  
  stop)
+
  stop)
 
  stop  
 
  stop  
 
  ;;  
 
  ;;  
  restart|reload)
+
  restart|reload)
 
  stop  
 
  stop  
 
  sleep 1  
 
  sleep 1  
 
  start  
 
  start  
 
  ;;  
 
  ;;  
  condrestart)
+
  condrestart)
  if [ -f /var/lock/subsys/vncserver ]; then  
+
  if [ -f /var/lock/subsys/vncserver ]; then  
 
  stop  
 
  stop  
 
  start  
 
  start  
 
  fi  
 
  fi  
 
  ;;  
 
  ;;  
  status)
+
  status)
 
  status Xvnc  
 
  status Xvnc  
 
  ;;  
 
  ;;  
  *)
+
  *)
  echo $"Usage: $0 {start|stop|restart|condrestart|status}"
+
  echo $"Usage: $0 {start|stop|restart|condrestart|status}"
 
  exit 1  
 
  exit 1  
  esac  
+
  esac
 
 
-----------------------------------------------------------------------------------
 
  
 
'''2)''' diese Datei speichert man im Verzeichnis "/etc/init.d/"  
 
'''2)''' diese Datei speichert man im Verzeichnis "/etc/init.d/"  
Zeile 95: Zeile 100:
 
'''5)''' Man editiert die Datei "/etc/sysconfig/vncservers"  
 
'''5)''' Man editiert die Datei "/etc/sysconfig/vncservers"  
  
Quelltext:
 
---------------------------------------------------------------------
 
 
Contents of /etc/sysconfig/vncservers:  
 
Contents of /etc/sysconfig/vncservers:  
  
# The VNCSERVERS variable is a list of display:user pairs.  
+
# The VNCSERVERS variable is a list of display:user pairs.  
#  
+
#  
# Uncomment the line below to start a VNC server on display :1  
+
# Uncomment the line below to start a VNC server on display :1  
# as my 'myusername' (adjust this to your own). You will also  
+
# as my 'myusername' (adjust this to your own). You will also  
# need to set a VNC password; run 'man vncpasswd' to see how  
+
# need to set a VNC password; run 'man vncpasswd' to see how  
# to do that.  
+
# to do that.  
#  
+
#  
# DO NOT RUN THIS SERVICE if your local area network is  
+
# DO NOT RUN THIS SERVICE if your local area network is  
# untrusted! For a secure way of using VNC, see  
+
# untrusted! For a secure way of using VNC, see  
# URL:http://www.uk.research.att.com/vnc/sshvnc.html.  
+
# URL:http://www.uk.research.att.com/vnc/sshvnc.html.  
 
+
# VNCSERVERS="1:myusername"  
+
# VNCSERVERS="1:myusername"  
VNCSERVERS="1:bob 2:sally 3:jim"  
+
VNCSERVERS="1:bob 2:sally 3:jim"  
----------------------------------------------------------
+
 
Logischer Weise muss man anstatt "bob", "sally" und "jim" den Namen des eigenen Nutzers oder der Nutzerin angeben.  
 
Logischer Weise muss man anstatt "bob", "sally" und "jim" den Namen des eigenen Nutzers oder der Nutzerin angeben.  
  
Zeile 118: Zeile 121:
  
 
'''7)''' have a lot of fun
 
'''7)''' have a lot of fun
 +
 +
[[Category:grafische Fernsteuerungen]]

Aktuelle Version vom 25. August 2006, 21:06 Uhr

Mit bestem Dank an id3pr.

0) Allg: Man muss als erstes normal einen Vncserver über die Konsole starten und ein Passwort festlegen. Dann den vncserver wieder schließen.

1) Man schreibe sich ein Skript (einfach folgenden Quelltext in eine leere Datei kopieren und sie "vncserver" nennen)

#!/bin/bash 
# 
# chkconfig: - 91 35 
# description: Starts and stops vncserver. \ 
# used to provide remote X administration services. 

# Source function library. 
. /etc/init.d/functions 

# Source networking configuration. 
. /etc/sysconfig/network 

# Check that networking is up. 
[ ${NETWORKING} = "no" ] && exit 0 

VNCSERVERS="" 
[ -f /etc/sysconfig/vncservers ] && . /etc/sysconfig/vncservers 

prog=$"VNC server" 

start() { 
echo -n $"Starting $prog: " 
ulimit -S -c 0 >/dev/null 2>&1 
RETVAL=0 
for display in ${VNCSERVERS} 
do 
echo -n "${display} " 
unset BASH_ENV ENV 
initlog $INITLOG_ARGS -c \ 
"su ${display##*:} -l -c \"cd ~${display##*:} && [ -f .vnc/passwd ] && vncserver :${display%%:*}\"" 
RETVAL=$? 
[ "$RETVAL" -ne 0 ] && break 
done 
[ "$RETVAL" -eq 0 ] && success $"vncserver startup" || \ 
failure $"vncserver start" 
echo 
[ "$RETVAL" -eq 0 ] && touch /var/lock/subsys/vncserver 
} 

stop() { 
echo -n $"Shutting down $prog: " 
for display in ${VNCSERVERS} 
do 
echo -n "${display} " 
unset BASH_ENV ENV 
initlog $INITLOG_ARGS -c \ 
"su ${display##*:} -c \"vncserver -kill :${display%%:*}\" >/dev/null 2>&1" 
done 
RETVAL=$? 
[ "$RETVAL" -eq 0 ] && success $"vncserver shutdown" || \ 
failure $"vncserver shutdown" 
echo 
[ "$RETVAL" -eq 0 ] && rm -f /var/lock/subsys/vncserver 
} 

# See how we were called. 
case "$1" in 
start) 
start 
;; 
stop) 
stop 
;; 
restart|reload) 
stop 
sleep 1 
start 
;; 
condrestart) 
if [ -f /var/lock/subsys/vncserver ]; then 
stop 
start 
fi 
;; 
status) 
status Xvnc 
;; 
*) 
echo $"Usage: $0 {start|stop|restart|condrestart|status}" 
exit 1 
esac

2) diese Datei speichert man im Verzeichnis "/etc/init.d/"

3) die Datei, genauergesagt das Script, muss ausfühbar sein. Also:

"chmod +x /etc/init.d/vncserver"

4) das script soll in den richtigen runlevel um automatisch zu starten. Also:

"chkconfig --level 5 vncserver on" "chkconfig --add vncserver"

5) Man editiert die Datei "/etc/sysconfig/vncservers"

Contents of /etc/sysconfig/vncservers:

# The VNCSERVERS variable is a list of display:user pairs. 
# 
# Uncomment the line below to start a VNC server on display :1 
# as my 'myusername' (adjust this to your own). You will also 
# need to set a VNC password; run 'man vncpasswd' to see how 
# to do that. 
# 
# DO NOT RUN THIS SERVICE if your local area network is 
# untrusted! For a secure way of using VNC, see 
# URL:http://www.uk.research.att.com/vnc/sshvnc.html. 

# VNCSERVERS="1:myusername" 
VNCSERVERS="1:bob 2:sally 3:jim" 

Logischer Weise muss man anstatt "bob", "sally" und "jim" den Namen des eigenen Nutzers oder der Nutzerin angeben.

6) rebooten

7) have a lot of fun