Results 1 to 2 of 2
This is a great little method that I found on the net. Kudos to whoever wrote it.
Installation: Create file /etc/axvnc
Paste the code below in "axvnc". (you may have ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 10-21-2005 #1Just Joined!
- Join Date
- Oct 2005
- Posts
- 2
Easy VNC Setup (Tested with RealVNC and TightVNC)
This is a great little method that I found on the net. Kudos to whoever wrote it.
Installation: Create file /etc/axvnc
Paste the code below in "axvnc". (you may have to make a few changes based on errors. I got it to work and I don't know what I am doing)
Set execute permission (chmod +x /etc/axvnc).
Using: run /etc/axvnc from the graphical Unix/Linux console.
START CODE:
Code:############################################################### # A X V N C H I S T O R Y # # # # # # V1.0-1: # # - First version # # V1.0-2: # # - Other O.S. are now supported: UW7, OpenServer # # - Modification of different menus (main, add and delete) # # - Using FREELIST to check display number # # - Checking /etc/hosts consistence for GDM style # # - The system configuration is now displayed # # V1.0-3: # # - LOGNAME must be root # # - Absolute pathname is used for 'sed'. And we check the # # presence of sed # # - A <M>odify option is now available (in fact this is a # # message to explain how to modify an existing display) # # - Bug fixed with GDM: it was impossible to delete a display # # (due to an incorrect token searched in /etc/inittab) # # - govnc: the -auth Xvnc option is replaced by -ac # # V1.0-4: # # - Modification of the /etc/hosts file checking # # - Warning for the maximum font server clients # # V1.0-5: # # - Add a signature in /etc/govnc to be sure to have the # # correct script # # V1.0-6: # # - For Linux, a menu allows to run script instead of login # # V1.1-0: # # - HP-UX is now supported # # - SunOS is now supported # # - axvnc can be run from any graphical display (and not # # only display :0) # # - New version of govnc (V1.1): instead of using the host # # name, Xvnc uses 'localhost' # # - Auto-application method is now allowed for any O.S. (only # # restriction: xsetroot, xterm and files must be supported) # # - Modification of syntax for creating scripts (\044 is \$) # # V1.1-1: # # - Change defaut Xservers location for SunOS # # - The pathname of the file utility is now into FILEPATH # # - if no font path is detected, Xvnc is run without '-fp' # # option # # - RunScriptVNC is now run with 'respawn' (an not 'once') # # - New version of govnc (V1.2): finally the hostname is # # required in /etc/govnc # # V1.1-2: # # - SCO 5.0.6 also accepted # # - In /etc/X11/gdm/gdm.conf, in the xdmcp sction Enable=0 # # and Enable=true are now supported # # - Moficiation of /etc/hosts check procedure (checking if # # every alias begins by localhost) # # - KDE2.2 is now supported (using /etc/inittab method) # # - New version of govnc (V1.3): with KDE22 the hostname is # # not needed (localhost is used) # # V1.1-3: # # - new method to get font path: searching information # # between 'Font Path' and 'Bug'. In event of failure the # # previous method is kept # # - xset command is redirected to /dev/null to avoid warning # # messages # # V1.1-4: # # - bug fixed about the SCO version test # # - New version of RunSCriptVNC (V1.2): with SCO, the # # '-geometry' xterm option is not used. # # - Open UNIX 8 is now supported. # # - bug fixed about the rgb file location # # V1.1-5: # # - a second location (/etc/opt/gnome/gdm) for gdm.conf is # # now possible. # # - axvnc runtime option: # # -h: on-line help # # -nofp: no font path (xset is not used to get font info) # # V1.1-6: # # - a logfile is used in /etc/inittab for non-login terminals # # - the 'init q' command is invoked without full pathname # # V1.1-7: # # - A new location for kdmrc is supported (SuSE 7.3 & OL311) # # - Delete option: a list of display number is now allowed # # Note: before, the use of a list flushed /etc/inittab # # - The Xvnc '-ac' option is now always used # # - In 'Any software' mode, the 'login terminals' handled # # by KDE2 are now seen as 'busy' # # V1.1-8: # # - In /etc/govnc (V1.5) and /etc/RunScriptVNC (V1.3) the # # outputs are now not redirected in /tmp/axvnclog because # # this is already done in /etc/inittab. # # - With kdm (KDE or KDE2.2), the Xaccess file is checked to # # detect if VNC connections can be opened by any host # # V1.2-0: # # - With KDE 2.2, two methods are available to get logins: # # - inetd: Xvnc is respawned at the connection # # - inittab: multiple Xvnc daemons are run at the boot # # V1.2-1: # # - An additional check is done to get the runlevel # # V1.2-2: # # - KDE 3 is now supported. (tested only with Suse 8.0) # # V1.2-3: # # - Use It is now supported. (KDE 3) # # V1.2-4: # # - The 1280x1024 resolution is now supported # # - Bug fixed: depending on the /etc/services contents, the # # vnc800x600 service may be added as a commented line # # - Additional check: rename autologin file if exits # # V1.2-5: # # - Bug fixed: when SCRIPT_OK was 0 the Linux method failed. # # V1.2-6: # # - Bug fixed: for a 800x600/16bpp terminal, only a 8bpp # # terminal was detected (now grep -w is used) # # - Bug fixed: it was impossible to use the auto-application # # mode. # # V1.2-7: # # - Suse 8.1 is now supported. Two modifications: # # -gdm: gdm.conf location is /etc/opt/gnome2/gdm/ # # -kdm: kdmrc location is /etc/opt/kde3/share/config/kdm/ # # - The '-os' option lists the certificated Operating Systems # # V1.2-8: # # - In login mode with kdm, ALL the existing kdmrc files are # # modified to enable xdmcp # # V1.2-9: # # - Grep -w is not supported by some O.S. (GetBPP proc) # # - Additional test to dected the syntax Enable=true or =0 # # V1.3-0: # # - Xvnc 4 is now supported. The option -SecurityType is set # # to None for disabling password request # # - the govnc version is now set to 1.6 # # V1.3-1: # # - The resolution is no longer checked. This allows any # # resolution to be select (could be useful for status line).# # - The version of the RunScriptVNC file was wrong # # V1.3-2: # # - SCO 6.0.0 is now supported # ################################################################ GetYN() { default=$1 shift while : do echo $ECHO_OPT "$* $default\b\c" read rep [ ! "$rep" ] && rep=$default case $rep in $YES) return $OK;; $yes) return $OK;; $NO) return $FAIL;; $no) return $FAIL;; *) echo "Invalid response" esac done } AskGeometry() { default=$1 shift echo $ECHO_OPT "$* [$default]: \c" read rep [ ! "$rep" ] && rep=$default GEOMETRY=$rep } AskBPP() { default=$1 shift while : do echo $ECHO_OPT "$* [$default]: \c" read rep [ ! "$rep" ] && rep=$default case $rep in 8) BPP="8" return $OK;; 16) BPP="16" return $OK;; *) echo "Invalid response" esac done } GetCR() { echo $ECHO_OPT "\nPress <CR>\c" read t } ComputeToken() { if [ "$1" -lt "10" ]; then TOKEN="axv" else if [ "$1" -lt "100" ]; then TOKEN="ax" else TOKEN="a" fi fi } CheckInList () { ITEM=$1 shift THELIST=$* if [ -z "$THELIST" ]; then return $FAIL fi for IDX in $THELIST do if [ "$IDX" = "$ITEM" ]; then return $OK fi done return $FAIL } AddOneDisplay() { clear echo " ADDING A DISPLAY" echo " " DispFile echo $ECHO_OPT "Enter the display number (or press <CR> to exit): \c" read DISP if [ -z "$DISP" ]; then return 0 fi CheckInList $DISP $DISPLIST if [ $? = $OK ]; then echo "This display has been already created!" GetCR return 1 fi CheckInList $DISP $BUSYLIST if [ $? = $OK ]; then echo "This display number is not allowed!" GetCR return 1 fi CheckInList $DISP $FREELIST if [ ! $? = $OK ]; then echo "This display number is not valid!" GetCR return 1 fi QUESTION="Enter the resolution (800x600, 1024x768...) " AskGeometry "1024x768" $QUESTION QUESTION="Enter the number of bits/pixel (8 or 16) " AskBPP 8 $QUESTION if [ "$MANAGER" = "GDM" ]; then CreateLineInittab $DISP $GEOMETRY $BPP fi if [ "$MANAGER" = "KDM" ]; then CreateLineXservers $DISP $GEOMETRY $BPP fi if [ "$MANAGER" = "SCRIPT" ]; then echo $ECHO_OPT "Enter the associated command (full pathname and options): \c" read VNCSCRIPT CreateLineInittab $DISP $GEOMETRY $BPP $VNCSCRIPT fi echo $LINE >> $FILE_XS echo " " echo "OK, display ':"$DISP"' added." MODIF="1" GetCR return 1 } AddDisplays() { while : do AddOneDisplay if [ "$?" = "0" ]; then return fi done } DelOneDisplay() { clear echo " DELETING A DISPLAY" echo " " DispFile echo $ECHO_OPT "Enter a display number or a list of display numbers (<CR>: exit): \c" read NUM if [ -z "$NUM" ]; then return 0 fi QUESTION="Are you sure ?: " GetYN $YES $QUESTION if [ $? = $FAIL ]; then return 0 fi for II in $NUM do CheckInList $II $DISPLIST if [ $? = $FAIL ]; then echo "Error, display number "$II" doesn't exist!" continue fi DISP=":"$II if [ "$MANAGER" = "KDM" ]; then CMD="/"$DISP"/d" else ComputeToken $II CMD="/"$TOKEN$II":/d" fi TMP_FILE="/tmp/axel.$$" /bin/sed $CMD $FILE_XS > $TMP_FILE cp -f $TMP_FILE $FILE_XS rm -f $TMP_FILE echo "OK, display '"$DISP"' deleted." MODIF="1" done GetCR return 1 } DelDisplays() { while : do DelOneDisplay if [ "$?" = "0" ]; then return fi done } ChgOneDisplay() { clear echo " MODIFYING A DISPLAY SETTINGS" echo " " echo "To change a display settings (number of colors or resolution), please perform" echo "the following:" echo " - delete the display(s)" echo " - EXIT and RESTART this utility" echo " - add the display(s) with the new settings" echo " " echo "If the display is deleted and added without exiting this utility, the new" echo "settings will not automatically enabled. The Unix/Linux machine will have to" echo "be rebooted" echo " " GetCR } GetGeometry () { set `echo $LINE` if [ "$MANAGER" = "SCRIPT" ]; then TOK=$3 else if [ "$KDE22" = "0" ]; then TOK=$7 else TOK=$3 fi fi RES=`/usr/bin/printf '%9s' $TOK` return } GetBPP () { if [ "$OS" = "Linux" ]; then GREP="grep -w" else GREP="grep" fi BPP=`echo $LINE | $GREP 16` if [ "$BPP" ]; then BPP="16" else BPP=`echo $LINE | $GREP 8` if [ "$BPP" ]; then BPP=" 8" else BPP="unknown" fi fi } GetScript () { set `echo $LINE` STR=$5".........................." SCRIPTNAME=`echo $STR | cut -b 1-16` SCRIPTNAME=$SCRIPTNAME"..." } DispFile () { echo "Contents of "$FILE_XS":" if [ "$MANAGER" = "GDM" ]; then DEB="1" MAXLIG="15" MAXCOL="3" fi if [ "$MANAGER" = "KDM" ]; then DEB="0" MAXLIG="14" MAXCOL="3" fi if [ "$MANAGER" = "SCRIPT" ]; then DEB="1" MAXLIG="15" MAXCOL="2" fi DISPLIST="" BUSYLIST="" FREELIST="" EOL="1" NB=$DEB NBDISP="0" while : do if [ "$NB" -gt "9" ]; then TAB="" else TAB=" " fi DISP=":"$NB RES="" BPP="" SCRIPTNAME="" if [ "$MANAGER" = "GDM" ]; then ComputeToken $NB STR=$TOKEN$NB":" LINE=`grep "^$STR" $FILE_XS` if [ -z "$LINE" ]; then STATUS="free" FREELIST=$FREELIST" "$NB else LINE=`echo $LINE | grep govnc` if [ -z "$LINE" ]; then STATUS="busy" BUSYLIST=$BUSYLIST" "$NB else STATUS="Xvnc" fi fi fi if [ "$MANAGER" = "KDM" ]; then ComputeToken $NB STR=$TOKEN$NB":.:respawn:/etc/RunScriptVNC" LINE=`grep "^$STR" /etc/inittab` if [ "$LINE" ]; then STATUS="busy" BUSYLIST=$BUSYLIST" "$NB else STR=$DISP" [Ll]ocal" LINE=`grep "^$STR" $FILE_XS` if [ -z "$LINE" ]; then STATUS="free" FREELIST=$FREELIST" "$NB else LINE=`echo $LINE | grep Xvnc` if [ -z "$LINE" ]; then STATUS="busy" # local X consol BUSYLIST=$BUSYLIST" "$NB else STATUS="Xvnc" fi fi fi fi if [ "$MANAGER" = "SCRIPT" ]; then LINE="" if [ "$DM" = "kdm" ]; then if [ "$KDE22" = "0" ]; then STR=$DISP" [lL]ocal" LINE=`grep "^$STR" $LOC_XS/Xservers` else ComputeToken $NB STR=$TOKEN$NB":.:respawn:/etc/govnc" LINE=`grep "^$STR" /etc/inittab` fi fi if [ "$DM" = "gdm" ]; then ComputeToken $NB STR=$TOKEN$NB":.:respawn:/etc/govnc" LINE=`grep "^$STR" /etc/inittab` fi if [ "$LINE" ]; then STATUS="busy" BUSYLIST=$BUSYLIST" "$NB else ComputeToken $NB STR=$TOKEN$NB":.:respawn:/etc/RunScriptVNC" LINE=`grep "^$STR" $FILE_XS` if [ -z "$LINE" ]; then STATUS="free" FREELIST=$FREELIST" "$NB else STATUS="Xvnc" fi fi fi if [ "$STATUS" = "Xvnc" ]; then GetGeometry GetBPP if [ "$MANAGER" = "SCRIPT" ]; then GetScript fi DISPLIST=$DISPLIST" "$NB NBDISP=`expr $NBDISP + 1` fi echo $ECHO_OPT "$DISP$TAB \c" if [ "$STATUS" = "Xvnc" ]; then if [ "$MANAGER" = "SCRIPT" ]; then echo $ECHO_OPT "($RES-$BPP) $SCRIPTNAME\c" else echo $ECHO_OPT "$STATUS $RES-$BPP bpp\c" fi else echo $ECHO_OPT "$STATUS \c" if [ "$MANAGER" = "SCRIPT" ]; then echo $ECHO_OPT " \c" fi fi if [ "$EOL" = "$MAXCOL" ]; then echo " " EOL="1" NB=`expr $DEB + 1` DEB=$NB if [ "$NB" -gt "$MAXLIG" ]; then break fi else EOL=`expr $EOL + 1` echo $ECHO_OPT " \c" #trailer spaces NB=`expr $NB + $MAXLIG` fi done echo " " } CreateLineInittab () { P1=$1 P2=$2 P3=$3 shift shift shift P4=$* LOG="1>/tmp/axvnclog"$P1" 2>&1" ComputeToken $P1 LINE=$TOKEN$P1":"$RUNLEVEL":" if [ -z "$P4" ]; then #no script LINE=$LINE"respawn:"$FILE_GOVNC else LINE=$LINE"respawn:"$FILE_VNCSCR fi LINE=$LINE" "$P1" "$P2" "$P3" "$P4" "$LOG } CreateLineXservers () { DISPLAY=":"$1 PORT=`expr 5900 + $1` GEOMETRY=$2 if [ "$3" = "8" ]; then BPP="-depth 8 -cc 3" else BPP="-depth 16" fi LINE=$DISPLAY" "$LOCAL" /usr/local/bin/Xvnc "$DISPLAY" "$SECURITYTYPES" -ac -geometry "$GEOMETRY" "$BPP" -rfbwait 120000 -rfbport $PORT "$FP" -co "$X11LIB"rgb " } BackUp () { SAV_FILE=$1".SAV" if [ ! -f $SAV_FILE ]; then echo "Backing up $1 into $SAV_FILE..." cp $1 $SAV_FILE sleep 1 fi } ManageFile () { MANAGER=$1 MODIF="0" while : do clear echo " MANAGING GRAPHICAL DISPLAY FILE" echo " " DispFile echo "<A>dd a display / <D>elete a display / <M>odify a display settings / <Q>uit" echo " " echo $ECHO_OPT "Enter your choice (A, D, M or Q): \c" read rep case $rep in [Aa]) AddDisplays;; [Dd]) DelDisplays;; [Mm]) ChgOneDisplay;; [Qq]) break;; *) echo "Invalid choice" GetCR;; esac done if [ "$MODIF" = "0" ]; then exit fi } CheckHostFile () { RET=`grep "127.0.0.1" /etc/hosts` CORRECTFILE="1" set `echo $RET` shift for i in $* do WORD=`echo $i | cut -b 1-9` if [ ! "$WORD" = "localhost" ]; then CORRECTFILE="0" fi done if [ "$CORRECTFILE" = "0" ]; then MYHOST=`hostname` echo " " echo " " echo "*** ERROR ***" echo "The /etc/hosts file hasn't been correctly created during Linux installation." echo "This hosts file should contain one line about the loopback driver (localhost)" echo "and one line about the Linux Ethernet interface." echo "Example:" echo " 127.0.0.1 localhost" echo " x.x.x.x "$MYHOST echo " " echo "Please fix the problem and restart this utility." echo " " exit fi } CheckAutoLog () { if [ ! -f "$FILE_AUTOLOG" ]; then return fi echo " " echo "*** AUTO-LOGIN " echo "To get a desktop through VNC the autologin function MUST be disabled." GetYN $YES "Please confirm "$FILE_AUTOLOG" can be renamed as a '.sav':" if [ $? = $FAIL ]; then return fi mv $FILE_AUTOLOG $FILE_AUTOLOG".SAV" echo "OK, this is done" } EnableXDMCP () { echo " " NEW_LIST="" for ONEFILE in $FILE_GDM do echo "*** Checking XDMCP ("$ONEFILE")" LINE=`grep "axvnc" $ONEFILE` if [ ! "$LINE" ]; then NEW_LIST=$NEW_LIST" "$ONEFILE echo "-> must be modified" else echo "-> xdmcp has been already enabled !" fi done if [ ! "$NEW_LIST" ]; then return fi echo "Xdmcp is not enabled." echo $NEW_LIST" must be modified. Press <CR> to confirm" read key for ONEFILE in $NEW_LIST do echo "Enabling xdmcp in "$ONEFILE"..." LINE1=`grep "Enable=false" $ONEFILE` LINE2=`grep "Enable=true" $ONEFILE` if [ ! "$LINE1$LINE2" ]; then STRMODIF="\044r1o" # replacing Enable=0 by Enable=1 else STRMODIF="ddkoEnable=true " # replacing Enable=false by Enable=true fi echo $ECHO_OPT "1G/"$STRXDMCP" /Enable "$STRMODIF"#modified by axvnc:x! " > /tmp/axscr vi -s /tmp/axscr $ONEFILE echo "OK, "$ONEFILE" has been modified" read key clear done echo " " echo "This modification will take effect either after rebooting the Linux machine" echo " " exit } GDMStyle () { echo " " echo "/etc/inittab and "$FILE_GDM" will be modified." QUESTION="Please confirm: " GetYN $YES $QUESTION if [ $? = $FAIL ]; then exit fi FILE_XS="/etc/inittab" BackUp $FILE_XS BackUp $FILE_GDM FILE_GOVNC="/etc/govnc" CREATE="0" if [ ! -f "$FILE_GOVNC" ]; then CREATE="1" else RES=`cat /etc/govnc | grep "Axel-V1.6"` if [ -z "$RES" ]; then CREATE="1" fi fi if [ "$CREATE" = "1" ]; then CreateGovnc $FILE_GOVNC fi ManageFile GDM CheckAutoLog EnableXDMCP echo " " echo "*** The /etc/inittab file has been modified ***" echo "This modification will take effect after invoking 'init q'" QUESTION="Do you want to invoke 'init q' now?: " GetYN $YES $QUESTION if [ $? = $OK ]; then init q echo "OK, command done" else echo "This modification will take effect after rebooting the Linux box" exit fi if [ "$NBDISP" -gt "3" -a "$FONTSERVER" = "1" ]; then echo " " echo "*** FONT SERVER WARNING *** " echo "You are using a Font Server. By default a font server is only able to server" echo "4 clients (i.e displays)." echo "Your current configuration is "$NBDISP" displays" echo "Please check in /etc/X11/fs/config, if the 'client-limit' is set to the proper" echo "value." fi exit } KDMStyle () { FILE_XS=$LOC_XS"/Xservers" echo $FILE_XS" will be modified." QUESTION="Please confirm: " GetYN $YES $QUESTION if [ $? = $FAIL ]; then exit fi if [ ! -f "$FILE_XS" ]; then echo $FILE_XS" doesn't exist!" exit fi BackUp $FILE_XS ManageFile KDM echo " " echo " " echo "*** The Xserver file has been modified ***" echo " " if [ "$PIDFILE" ]; then PIDXDM=`cat $PIDFILE` fi if [ "$PIDXDM" ]; then echo "This modification will take effect by sending the signal HUP to the " echo "process "$PIDXDM"." QUESTION="Do you want to send the send the signal HUP ? : " GetYN $YES $QUESTION if [ $? = $OK ]; then kill -HUP $PIDXDM echo "OK, signal sent" exit fi fi echo " " if [ "$OS" = "SCO_SV" ]; then echo "This modification will take effect after invoking 'scologin start' then " echo "'scologin stop'" else echo "This modification will take effect after rebooting the machine" fi } CheckInet () { if [ ! -f "$LOC_INETD" ]; then echo "Creating "$LOC_INETD"..." echo "### VNC servers" > $LOC_INETD else BackUp $LOC_INETD fi GEOMETRY=$1 BPP=$2 PORT=$3 echo $ECHO_OPT $GEOMETRY" - "$BPP" bpp (port "$PORT"): \c" STR="vnc"$GEOMETRY"-"$BPP RET=`grep $STR $FILE_SERVICES` if [ ! -z "$RET" ]; then echo "OK (already set)" return fi RET=`grep $PORT $FILE_SERVICES` if [ ! -z "$RET" ]; then echo "FAILED (port already in use)" return fi MODIF="1" echo "OK" echo $ECHO_OPT $STR"\t"$PORT"/tcp" >> $FILE_SERVICES RET=`grep $STR $LOC_INETD` if [ ! -z "$RET" ]; then return fi if [ "$BPP" = "8" ]; then BPP="-depth 8 -cc 3" else BPP="-depth 16" fi if [ "$XINET" = "0" ]; then echo $STR" stream tcp nowait nobody /usr/local/bin/Xvnc Xvnc -inetd -query localhost -once -geometry "$GEOMETRY" "$BPP >> $LOC_INETD else echo "service "$STR >> $LOC_INETD echo " {" >> $LOC_INETD echo " disable = no" >> $LOC_INETD echo " protocol = tcp" >> $LOC_INETD echo " socket_type = stream" >> $LOC_INETD echo " wait = no" >> $LOC_INETD echo " user = nobody" >> $LOC_INETD echo " server = /usr/local/bin/Xvnc" >> $LOC_INETD echo " server_args = -inetd "$SECURITYTYPES" -query localhost -once -geometry "$GEOMETRY" "$BPP >> $LOC_INETD echo " }" >> $LOC_INETD echo " " >> $LOC_INETD fi } KDE22Style () { echo " " echo "(x)inetd and "$FILE_GDM" will be modified." QUESTION="Please confirm: " GetYN $YES $QUESTION if [ $? = $FAIL ]; then exit fi FILE_SERVICES="/etc/services" RET=`ps -ef |grep xinetd | grep -v grep` if [ ! -z "$RET" ]; then if [ -d "/etc/xinetd.d" ]; then LOC_INETD="/etc/xinetd.d/vnc" else LOC_INETD="/etc/xinetd.conf" fi SIG="-USR2" XINET="1" else RET=`ps -ef |grep inetd | grep -v grep` if [ ! -z "$RET" ]; then if [ -d "/etc/inet.d" ]; then LOC_INETD="/etc/inet.d/vnc" else LOC_INETD="/etc/inetd.conf" fi SIG="-HUP" XINET="0" else echo "*** ERROR: no (x)inetd daemon running." exit fi fi set `echo $RET` PID=$2 echo " " echo "*** Checking INET environment ("$FILE_SERVICES" and "$LOC_INETD")" BackUp $FILE_SERVICES echo "### VNC Displays" >> $FILE_SERVICES MODIF="0" CheckInet 800x600 8 5950 CheckInet 800x600 16 5951 CheckInet 1024x768 8 5952 CheckInet 1024x768 16 5953 CheckInet 1280x1024 8 5954 CheckInet 1280x1024 16 5955 if [ "$MODIF" = "1" ]; then echo " " echo "NOTE: modifications will take effect either after rebooting the Linux machine" echo " or sending signal "$SIG" to (x)inetd process." echo " " if [ "$PID" ]; then QUESTION="Do you want to send the signal "$SIG" to (x)inetd (pid: "$PID") ? : " GetYN $YES $QUESTION if [ $? = $OK ]; then kill $SIG $PID echo "OK, signal sent" fi fi fi CheckAutoLog BackUp $FILE_GDM EnableXDMCP exit } CreateScriptVNC () { FILE=$1 echo "Creating "$FILE"..." if [ "$OS" = "SCO_SV" ]; then XTERM_OPT="" else XTERM_OPT="-geometry 170x60-0+0" fi sleep 1 echo $ECHO_OPT "#### Axel-V1.6 - Do not edit this first line " > $FILE echo $ECHO_OPT "#### This script runs Xvnc and script through /etc/inittab " >> $FILE echo $ECHO_OPT "#### Parameters: " >> $FILE echo $ECHO_OPT "#### - Display number " >> $FILE echo $ECHO_OPT "#### - Geometry " >> $FILE echo $ECHO_OPT "#### - BPP " >> $FILE echo $ECHO_OPT "#### - Script and parameters " >> $FILE echo $ECHO_OPT " " >> $FILE echo $ECHO_OPT "DISPLAY=\":\"\$1" >> $FILE echo $ECHO_OPT "export DISPLAY " >> $FILE echo $ECHO_OPT " " >> $FILE echo $ECHO_OPT "PORT=\`expr 5900 + \$1\`" >> $FILE echo $ECHO_OPT " " >> $FILE echo $ECHO_OPT "GEOMETRY=\$2 " >> $FILE echo $ECHO_OPT " " >> $FILE echo $ECHO_OPT "if [ \"\$3\" = \"8\" ]; then " >> $FILE echo $ECHO_OPT " BPP=\"-depth 8 -cc 3\" " >> $FILE echo $ECHO_OPT " else " >> $FILE echo $ECHO_OPT " BPP=\"-depth 16\" " >> $FILE echo $ECHO_OPT " fi " >> $FILE echo $ECHO_OPT " " >> $FILE echo $ECHO_OPT "/usr/local/bin/Xvnc \$DISPLAY "$SECURITYTYPES" -ac -geometry \$GEOMETRY \$BPP -rfbwait 120000 -rfbport \$PORT "$FP" -co "$X11LIB"rgb &" >> $FILE echo $ECHO_OPT " " >> $FILE echo $ECHO_OPT "sleep 1 " >> $FILE echo $ECHO_OPT $X11BIN"xsetroot -solid grey " >> $FILE echo $ECHO_OPT "shift" >> $FILE echo $ECHO_OPT "shift" >> $FILE echo $ECHO_OPT "shift" >> $FILE echo $ECHO_OPT "CMD=\$*" >> $FILE echo $ECHO_OPT "TYPE=\`"$PATHFILE"file \$1\` " >> $FILE echo $ECHO_OPT "TEXT=\`echo \$TYPE | grep \"text\"\` " >> $FILE echo $ECHO_OPT "if [ ! -z \"\$TEXT\" ]; then " >> $FILE echo $ECHO_OPT " CMD=\""$X11BIN"xterm "$XTERM_OPT" -e \"\$CMD " >> $FILE echo $ECHO_OPT " fi " >> $FILE echo $ECHO_OPT " " >> $FILE echo $ECHO_OPT "while : " >> $FILE echo $ECHO_OPT " do " >> $FILE echo $ECHO_OPT " REP=\`ps -ef | grep \"Xvnc \$DISPLAY\" | grep -v grep\` " >> $FILE echo $ECHO_OPT " if [ -z \"\$REP\" ]; then " >> $FILE echo $ECHO_OPT " exit " >> $FILE echo $ECHO_OPT " fi " >> $FILE echo $ECHO_OPT " \$CMD " >> $FILE echo $ECHO_OPT " done " >> $FILE chmod +x $FILE } CreateGovnc () { FILE=$1 echo "Creating "$FILE"..." sleep 1 echo $ECHO_OPT "#### Axel-V1.6 - Do not edit this first line " > $FILE echo $ECHO_OPT "#### This script runs Xvnc through /etc/inittab " >> $FILE echo $ECHO_OPT "#### Parameters: " >> $FILE echo $ECHO_OPT "#### - Display number " >> $FILE echo $ECHO_OPT "#### - Geometry " >> $FILE echo $ECHO_OPT "#### - BPP " >> $FILE echo $ECHO_OPT " " >> $FILE echo $ECHO_OPT "DISPLAY=\":\"\$1 " >> $FILE echo $ECHO_OPT " " >> $FILE echo $ECHO_OPT "PORT=\`expr 5900 + \$1\`" >> $FILE echo $ECHO_OPT " " >> $FILE echo $ECHO_OPT "GEOMETRY=\$2 " >> $FILE echo $ECHO_OPT " " >> $FILE echo $ECHO_OPT "if [ \"\$3\" = \"8\" ]; then " >> $FILE echo $ECHO_OPT " BPP=\"-depth 8 -cc 3\" " >> $FILE echo $ECHO_OPT " else " >> $FILE echo $ECHO_OPT " BPP=\"-depth 16\" " >> $FILE echo $ECHO_OPT " fi " >> $FILE echo $ECHO_OPT " " >> $FILE if [ "$KDE22" = "0" ]; then #### GDM #### echo $ECHO_OPT "HOST=\`hostname\`" >> $FILE echo $ECHO_OPT " " >> $FILE echo $ECHO_OPT "/usr/local/bin/Xvnc \$DISPLAY "$SECURITYTYPES" -ac -query \$HOST -once -terminate -geometry \$GEOMETRY \$BPP -rfbwait 120000 -rfbport \$PORT "$FP" -co "$X11LIB"rgb" >> $FILE else #### KDE 2.2 #### echo $ECHO_OPT "/usr/local/bin/Xvnc \$DISPLAY "$SECURITYTYPES" -ac -query localhost -once -geometry \$GEOMETRY \$BPP -rfbwait 120000 -rfbport \$PORT "$FP >> $FILE fi chmod +x $FILE } CreateExampleFiles() { echo "Creating example files:" CreateLineXservers "1" "800x600" "8" FILE="/tmp/xservers.add" echo " - $FILE..." echo $LINE > $FILE FILE="/tmp/govnc" echo " - $FILE..." CreateGovnc $FILE echo "OK" } Banner () { clear echo " AXEL VNC UTILITY ($VERSION)" echo " -------------------------" echo " " echo " " } ConfOpenServer () { Banner echo "This utility allows you to set-up OpenServer to run automatically at boot time" echo "Xvnc servers. For each display, a different resolution and a different number" echo "of colors can be chosen." echo " " echo "The VNC terminals are listed in the Xservers file. This file is located in" echo "/usr/lib/X11/scologin." KDMStyle } ConfUW () { Banner echo "This utility allows you to set-up UnixWare 7 to run automatically at boot time" echo "Xvnc servers. For each display, a different resolution and a different number" echo "of colors can be chosen." echo " " echo "The VNC terminals are listed in the Xservers file. This file is located in" echo "/usr/dt/config." KDMStyle } ConfOU8 () { Banner echo "This utility allows you to set-up OpenUNIX 8 to run automatically at boot time" echo "Xvnc servers. For each display, a different resolution and a different number" echo "of colors can be chosen." echo " " echo "The VNC terminals are listed in the Xservers file. This file is located in" echo "/usr/dt/config." KDMStyle } ConfHPUX () { Banner echo "This utility allows you to set-up HP_UX to run automatically at boot time" echo "Xvnc servers. For each display, a different resolution and a different number" echo "of colors can be chosen." echo " " echo "The VNC terminals are listed in the Xservers file. This file is located in" echo "/etc/dt/config." KDMStyle } ConfSunOS () { Banner echo "This utility allows you to set-up SunOS to run automatically at boot time" echo "Xvnc servers. For each display, a different resolution and a different number" echo "of colors can be chosen." echo " " echo "The VNC terminals are listed in the Xservers file. This file is located in" echo "/etc/dt/config." KDMStyle } SelectMethod () { KDE22="0" if [ "$OS" = "Linux" ]; then DM="" RET=`ps -ef | grep kdm | grep -v grep` FILE_GDM="" if [ "$RET" ]; then DM="kdm" ##### KDE 2.2 ##### if [ -f "/etc/kde/kdm/kdmrc" ]; then KDE22="1" FILE_GDM=$FILE_GDM" /etc/kde/kdm/kdmrc" fi if [ -f "/usr/share/config/kdm/kdmrc" ]; then KDE22="1" FILE_GDM=$FILE_GDM" /usr/share/config/kdm/kdmrc" fi if [ -f "/opt/kde2/share/config/kdm/kdmrc" ]; then KDE22="1" FILE_GDM=$FILE_GDM" /opt/kde2/share/config/kdm/kdmrc" fi ##### KDE 3 ##### if [ -f "/opt/kde3/share/config/kdm/kdmrc" ]; then KDE22="1" FILE_GDM=$FILE_GDM" /opt/kde3/share/config/kdm/kdmrc" fi if [ -f "/usr/kde/share/config/kdm/kdmrc" ]; then #Use It KDE22="1" FILE_GDM=$FILE_GDM" /usr/kde/share/config/kdm/kdmrc" fi if [ -f /etc/opt/kde3/share/config/kdm/kdmrc ]; then #Suse 8.1 KDE22="1" FILE_GDM=$FILE_GDM" /etc/opt/kde3/share/config/kdm/kdmrc" fi else RET=`ps -ef | grep gdm | grep -v grep` if [ "$RET" ]; then DM="gdm" fi fi else DM="kdm" fi if [ "$SCRIPT_OK" = "1" ]; then Banner echo "This utility allows you to set-up Unix/Linux to run automatically at boot time" echo "Xvnc servers. For each display, a different resolution and a different number" echo "of colors can be chosen." echo " " echo "An Xvnc daemon can be used:" echo " - either to get a graphical login and to access a desktop (KDE, GNOME, etc.)" echo " - or to run automatically an X software (netscape, rdesktop, etc.)" echo " " while : do echo $ECHO_OPT "Select the method (<L>ogin or <A>ny software): \c" read rep [ ! "$rep" ] && rep=$default case $rep in [Ll]) break;; [Aa]) RunScriptMethod return;; *) echo "Invalid response" esac done fi ### LOGIN METHOD ### case $OS in "SCO_SV") ConfOpenServer;; "UnixWare") ConfUW;; "OpenUNIX") ConfOU8;; "Linux") ConfLinux;; "HP-UX") ConfHPUX;; "SunOS") ConfSunOS;; *) echo "ERROR: $OS is a non-supported operating system!" exit;; esac } RunScriptMethod () { Banner FILE_XS="/etc/inittab" BackUp $FILE_XS FILE_VNCSCR="/etc/RunScriptVNC" CREATE="0" if [ ! -f "$FILE_VNCSCR" ]; then CREATE="1" else RES=`cat /etc/RunScriptVNC | grep "Axel-V1.6"` if [ -z "$RES" ]; then CREATE="1" fi fi if [ "$CREATE" = "1" ]; then CreateScriptVNC $FILE_VNCSCR fi ManageFile SCRIPT echo " " echo "*** The /etc/inittab file has been modified ***" echo "This modification will take effect after invoking 'init q'" QUESTION="Do you want to invoke 'init q' now?: " GetYN $YES $QUESTION if [ $? = $OK ]; then init q echo "OK, command done" else echo "This modification will take effect after rebooting the Unix/Linux box" exit fi } CheckXaccess () { XACC=$LOC_XS"/Xaccess" echo " " echo $ECHO_OPT "*** Checking "$XACC"\c" if [ ! -f "$XACC" ]; then echo " " echo "*** WARNING: "$XACC" not present" echo " " return fi RESTRICTION="0" RET=`grep "^[*]" $XACC` if [ -z "$RET" ]; then RESTRICTION="1" else RET2=`echo $RET | grep "any host"` if [ -z "$RET2" ]; then RESTRICTION="1" fi fi if [ "$RESTRICTION" = "1" ]; then echo " " echo "*** WARNING: access restriction seems to be enabled" echo "Xaccess must be modified to allow a login box is 'sent' on VNC terminals" QUESTION="Do you want to exit axvnc and modify Xaccess now ?: " GetYN $YES $QUESTION if [ $? = $OK ]; then exit fi echo "OK, let's go. But remind to modify Xaccess later." echo " " return fi echo " -> OK" echo " " } KDE22Method () { STRXDMCP="Xdmcp" #with KDE22 no font path is needed. FP="" while : do echo $ECHO_OPT "Do you want to use the <X>inet method or the [I]nittab method (X/I) ?: \c" read rep case $rep in [xX]) KDE22Style;; [iI]) GDMStyle;; *) echo "Invalid response" esac done } ConfLinux () { Banner echo "Getting a login on VNC terminals, depends on the current display manager." echo " " echo $ECHO_OPT "Detecting current display manager\c" STRFOR="1 2 3" for II in $STRFOR do # sleep 1 echo $ECHO_OPT ".\c" done echo " " if [ "$DM" = "kdm" ]; then if [ "$KDE22" = "1" ]; then echo "*** INFO: KDE 2.2 or KDE 3 is running" echo " " echo "With KDE 2.2 or KDE 3, three operations must be performed:" echo " * enabling access (Xaccess)" echo " * adding VNC terminals. Two methods can be used to run Xvnc daemons:" echo " 1 - using (x)inetd (a Xvnc daemon is only spawned when a VNC connection" echo " is opened)" echo " 2 - using /etc/inittab (at Linux boot time one Xvnc daemon is run" echo " per VNC terminal)" echo " * enabling XDMCP (kdmrc)" echo " " echo "Note: with KDE 2.2 or KDE 3 no font path is needed (-fp Xvnc option). " else echo "*** INFO: KDE (kdm) is running" echo " " echo "With KDE, two operations must be performed:" echo " * enabling access (Xaccess)" echo " * adding VNC terminals in the file Xservers" fi CheckXaccess if [ "$KDE22" = "1" ]; then KDE22Method else KDMStyle fi exit fi if [ "$DM" = "gdm" ]; then echo "*** INFO: GNOME (gdm) is running" echo " " echo "With GNOME, two operations must be performed:" echo " * adding VNC terminals. This is done through /etc/inittab (at Linux" echo " boot time, one Xvnc daemon is run per VNC terminal)" echo " * enabling XDMCP (file gdm.conf)" echo " " KDE22="0" FILE_GDM="" if [ -f "/etc/X11/gdm/gdm.conf" ]; then FILE_GDM="/etc/X11/gdm/gdm.conf" fi if [ -f "/etc/opt/gnome/gdm/gdm.conf" ]; then FILE_GDM="/etc/opt/gnome/gdm/gdm.conf" fi if [ -f "/etc/opt/gnome2/gdm/gdm.conf" ]; then FILE_GDM="/etc/opt/gnome2/gdm/gdm.conf" fi if [ -z "$FILE_GDM" ]; then echo "ERROR: Can not find gdm.conf. " echo "axvnc ended." exit fi STRXDMCP="xdmcp" CheckHostFile GDMStyle exit fi echo "*** INFO: gdm and kdm are not running" echo "You must configure manually Linux. To help you the following files are created." CreateExampleFiles echo " " } ################ ##### MAIN ##### ################ VERSION="V1.3-2" if [ "$1" = "-h" ]; then echo "Axel VNC Configurator for Unix/Linux" echo "Version "$VERSION echo "(C) 2002-2003 - Axel" echo " " echo "Usage:" echo " axvnc [-nofp] [-h]" echo " -h: on-line help " echo " -nofp: No Font Path" echo " -os: display certificated O.S." echo " " echo "Note: axvnc must be run from the graphical Unix/Linux console. " echo " " exit fi if [ "$1" = "-os" ]; then echo "Axel VNC Configurator for Unix/Linux" echo "Version "$VERSION echo "(C) 2002-2003 - Axel" echo " " echo "This utility is certified for:" echo " - HP-UX 11" echo " - Mandrake 9.0 (and old previous versions)" echo " - Open Unix 8.0" echo " - Open Linux 3.11" echo " - Red Hat 9.0 (and old previous versions)" echo " - SCO OpenServer 5 and 6" echo " - Sun OS" echo " - Suse 8.1 (and old previous versions)" echo " - United Linux 4.0" echo " - UnixWare 7.11" echo " - Use It 1.3" echo " " exit fi if [ "$1" = "-nofp" ]; then NOFP="1" else NOFP="0" fi YES="Y" yes="y" NO="N" no="n" : ${OK=0} : ${FAIL=1} FILE_AUTOLOG="/etc/sysconfig/autologin" Banner #if [ ! "$LOGNAME" = "root" ]; then # echo "Please, logon as root and restart this utility." # exit # fi OS=`uname -s` if [ "$OS" = "SCO_SV" -o "$OS" = "UnixWare" -o "$OS" = "HP-UX" -o "$OS" = "SunOS" -o "$OS" = "OpenUNIX" ]; then STR=`who -r` if [ ! "$STR" ]; then echo "*** ERROR: can not get runlevel" exit fi set `echo $STR` RUNLEVEL=$3 fi if [ "$OS" = "Linux" ]; then ECHO_OPT=" -e " STR=`runlevel` if [ ! "$STR" ]; then echo "*** ERROR: can not get runlevel" exit fi set `echo $STR` RUNLEVEL=$2 fi if [ "$OS" = "SunOS" ]; then X11BIN="/usr/openwin/bin/" X11LIB="/usr/openwin/lib/" else X11BIN="/usr/bin/X11/" X11LIB="/usr/lib/X11/" fi echo "Checking system configuration:" echo " " echo " - Operating System:" echo " --> "$OS" (runlevel "$RUNLEVEL")" if [ -z "$RUNLEVEL" ]; then echo " " echo "ERROR: the RUNLEVEL environment variable is not set" echo " " exit fi PATHFILE="/usr/bin/" if [ "$OS" = "SCO_SV" ]; then ver=`uname -v` PATHFILE="/bin/" major=`expr substr $ver 1 1` minor=`expr substr $ver 5 1` if [ "$major" = "5" -a "$minor" -lt "5" ]; then echo "ERROR: SCO versions lower than 5.0.5 are not supported by this utility" exit fi if [ "$major" = "6" ]; then NOFP="1" fi fi echo " " echo $ECHO_OPT " - VNC server (Xvnc):" if [ ! -f /usr/local/bin/Xvnc ]; then echo " " echo "ERROR: Xvnc is not present in /usr/local/bin. " echo "Please copy it and restart this utility." echo " " exit fi if [ ! -x /usr/local/bin/Xvnc ]; then echo " " echo "ERROR: Xvnc is not set as an executable program. " echo "Please use 'chmod +x /usr/local/bin/Xvnc' and restart this utility." echo " " exit fi echo $ECHO_OPT " --> OK\c" RET=`/usr/local/bin/Xvnc -h 2>&1 | grep SecurityTypes` VNC4=$FAIL SECURITYTYPES="" if [ -z "$RET" ]; then echo " " else echo " (Version 4 detected)" VNC4=$OK SECURITYTYPES="-SecurityTypes None" fi echo " " echo " - Misc Utilities:" if [ ! -x "/bin/sed" ]; then echo " " echo "ERROR: '/bin/sed' is not present " exit fi if [ ! -x "/usr/bin/printf" ]; then echo " " echo "ERROR: '/usr/bin/printf' is not present " exit fi SCRIPT_OK="1" if [ ! -x $X11BIN"xsetroot" ]; then echo "WARNING: '"$X11BIN"xsetroot' is not present " SCRIPT_OK="0" fi if [ ! -x $X11BIN"xterm" ]; then echo "WARNING: '"$X11BIN"xterm' is not present " SCRIPT_OK="0" fi if [ ! -x $PATHFILE"file" ]; then echo "WARNING: '"$PATHFILE"file' is not present " SCRIPT_OK="0" fi if [ "$SCRIPT_OK" = "1" ]; then echo " --> OK" else echo " --> Auto-Application method not available" fi echo " " echo " - X11 font:" FONTSERVER="0" if [ "$NOFP" = "1" ]; then echo " --> Font Path not used" else XSET=$X11BIN"xset" if [ ! -f $XSET ]; then echo " " echo "ERROR: xset utility is not available. " echo "Please install xset and and restart this utility." echo " " exit fi XSET=$XSET" -q" RET=`$XSET 2>/dev/null` if [ -z "$RET" ]; then echo " " echo "ERROR: can not execute '$XSET' " echo "Please logon on the main console (:0) and restart the utility" echo " " exit fi FSNAME="unix" #font server name rm -f /tmp/axfont ## Searching current Font paths ## We assume the information begins by 'Font Path' and is ended by 'Bug' $XSET 2>/dev/null > /tmp/axfont FP=`/bin/sed -n "/Font Path/{ n :x p n /Bug/b bx }" /tmp/axfont` rm -f /tmp/axfont if [ ! -z "$FP" ]; then #OK, Check if a font server is used FS=`echo $FP | grep $FSNAME` if [ ! -z "$FS" ]; then FONTSERVER="1" fi else #the previous search fails FP=`$XSET 2>/dev/null | grep lib 2>/dev/null` if [ -z "$FP" ]; then FP=`$XSET 2>/dev/null | grep $FSNAME 2>/dev/null` FONTSERVER="1" fi fi if [ -z "$FP" ]; then echo " --> ERROR: Can not get Font Paths. Default one is used." else echo " -->"$FP FP="-fp "$FP fi fi GetCR case $OS in "SCO_SV") LOC_XS="/usr/lib/X11/scologin" LOCAL="local";; "UnixWare") LOC_XS="/usr/dt/config" LOCAL="local@none" PIDFILE="/var/dt/Xpid";; "OpenUNIX") LOC_XS="/usr/dt/config" LOCAL="local@none" PIDFILE="/usr/dt/Xpid";; "Linux") if [ -f "/etc/X11/kdm/Xservers" ]; then # CALDERA LOC_XS="/etc/X11/kdm" else # OTHER LINUX: RED HAT, SUSE, MANDRAKE LOC_XS="/etc/X11/xdm" PIDFILE="/var/run/xdm.pid" fi LOCAL="local" ECHO_OPT=" -e ";; "HP-UX") LOC_XS="/etc/dt/config" LOCAL="local@none" PIDFILE="/var/dt/Xpid";; "SunOS") LOC_XS="/etc/dt/config" LOCAL="local@none" PIDFILE="/var/dt/Xpid";; *) echo "ERROR: $OS is a non-supported operating system!" exit;; esac SelectMethod
- 10-21-2005 #2Just Joined!
- Join Date
- Oct 2005
- Posts
- 2
Easy VNC Setup (Follow up)
The part i had to change was
toCode:STR=`runlevel`
Code:STR=`/sbin/runlevel`


Reply With Quote
