Find the answer to your Linux question:
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.
  1. #1
    Just 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 &#40;in fact this is a     #
    #    message to explain how to modify an existing display&#41;     #
    #  - Bug fixed with GDM&#58; it was impossible to delete a display #
    #    &#40;due to an incorrect token searched in /etc/inittab&#41;      #
    #  - govnc&#58; the -auth Xvnc option is replaced by -ac           #
    # V1.0-4&#58;                                                      #
    #  - Modification of the /etc/hosts file checking              #
    #  - Warning for the maximum font server clients               #
    # V1.0-5&#58;                                                      #
    #  - Add a signature in /etc/govnc to be sure to have the      #
    #    correct script                                            #
    # V1.0-6&#58;                                                      #
    #  - For Linux, a menu allows to run script instead of login   #
    # V1.1-0&#58;                                                      #
    #  - HP-UX is now supported                                    #
    #  - SunOS is now supported                                    #
    #  - axvnc can be run from any graphical display &#40;and not      #
    #    only display &#58;0&#41;                                          #
    #  - New version of govnc &#40;V1.1&#41;&#58; instead of using the host    #
    #    name, Xvnc uses 'localhost'                               #
    #  - Auto-application method is now allowed for any O.S. &#40;only #
    #    restriction&#58; xsetroot, xterm and files must be supported&#41; #
    #  - Modification of syntax for creating scripts &#40;\044 is \$&#41;  #
    # V1.1-1&#58;                                                      #
    #  - 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' &#40;an not 'once'&#41;    #
    #  - New version of govnc &#40;V1.2&#41;&#58; finally the hostname is      #
    #    required in /etc/govnc                                    #
    # V1.1-2&#58;                                                      #
    #  - 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 &#40;checking if    #
    #    every alias begins by localhost&#41;                          #
    #  - KDE2.2 is now supported &#40;using /etc/inittab method&#41;       #
    #  - New version of govnc &#40;V1.3&#41;&#58; with KDE22 the hostname is   #
    #    not needed &#40;localhost is used&#41;                            #
    # V1.1-3&#58;                                                      #
    #  - new method to get font path&#58; 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&#58;                                                      #
    #  - bug fixed about the SCO version test                      #
    #  - New version of RunSCriptVNC &#40;V1.2&#41;&#58; 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&#58;                                                      #
    #  - a second location &#40;/etc/opt/gnome/gdm&#41; for gdm.conf is    #
    #    now possible.                                             #
    #  - axvnc runtime option&#58;                                     #
    #      -h&#58; on-line help                                        #
    #      -nofp&#58; no font path &#40;xset is not used to get font info&#41; #
    # V1.1-6&#58;                                                      #
    #  - a logfile is used in /etc/inittab for non-login terminals #
    #  - the 'init q' command is invoked without full pathname     #
    # V1.1-7&#58;                                                      #
    #  - A new location for kdmrc is supported &#40;SuSE 7.3 & OL311&#41;  #
    #  - Delete option&#58; a list of display number is now allowed    #
    #    Note&#58; 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&#58;                                                      #
    #  - In /etc/govnc &#40;V1.5&#41; and /etc/RunScriptVNC &#40;V1.3&#41; the     #
    #    outputs are now not redirected in /tmp/axvnclog because   #
    #    this is already done in /etc/inittab.                     #
    #  - With kdm &#40;KDE or KDE2.2&#41;, the Xaccess file is checked to  #
    #    detect if VNC connections can be opened by any host       #
    # V1.2-0&#58;                                                      #
    #  - With KDE 2.2, two methods are available to get logins&#58;    #
    #       - inetd&#58; Xvnc is respawned at the connection           #
    #       - inittab&#58; multiple Xvnc daemons are run at the boot   #
    # V1.2-1&#58;                                                      #
    #  - An additional check is done to get the runlevel           #
    # V1.2-2&#58;                                                      #
    #  - KDE 3 is now supported. &#40;tested only with Suse 8.0&#41;       #
    # V1.2-3&#58;                                                      #
    #  - Use It is now supported. &#40;KDE 3&#41;                          #
    # V1.2-4&#58;                                                      #
    #  - The 1280x1024 resolution is now supported                 #
    #  - Bug fixed&#58; depending on the /etc/services contents, the   #
    #    vnc800x600 service may be added as a commented line       #
    #  - Additional check&#58; rename autologin file if exits          #
    # V1.2-5&#58;                                                      #
    #  - Bug fixed&#58; when SCRIPT_OK was 0 the Linux method failed.  #
    # V1.2-6&#58;                                                      #
    #  - Bug fixed&#58; for a 800x600/16bpp terminal, only a 8bpp      #
    #    terminal was detected &#40;now grep -w is used&#41;               #
    #  - Bug fixed&#58; it was impossible to use the auto-application  #
    #    mode.                                                     #
    # V1.2-7&#58;                                                      #
    #  - Suse 8.1 is now supported. Two modifications&#58;             #
    #      -gdm&#58; gdm.conf location is /etc/opt/gnome2/gdm/         #
    #      -kdm&#58; kdmrc location is /etc/opt/kde3/share/config/kdm/ #
    #  - The '-os' option lists the certificated Operating Systems #
    # V1.2-8&#58;                                                      #
    #  - In login mode with kdm, ALL the existing kdmrc files are  #
    #    modified to enable xdmcp                                  #
    # V1.2-9&#58;                                                      #
    #  - Grep -w is not supported by some O.S. &#40;GetBPP proc&#41;       #
    #  - Additional test to dected the syntax Enable=true or =0    #
    # V1.3-0&#58;                                                      #
    #  - 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&#58;                                                      #
    #  - The resolution is no longer checked. This allows any      #
    #    resolution to be select &#40;could be useful for status line&#41;.#
    #  - The version of the RunScriptVNC file was wrong            #
    # V1.3-2&#58;                                                      #
    #  - SCO 6.0.0 is now supported                                #
    ################################################################
    
    GetYN&#40;&#41;
    &#123;
    default=$1
    shift
    while &#58;
       do
       echo $ECHO_OPT "$* $default\b\c"
       read rep
       &#91; ! "$rep" &#93; && rep=$default
       case $rep in
          $YES&#41; return $OK;;
          $yes&#41; return $OK;;
          $NO&#41; return $FAIL;;
          $no&#41; return $FAIL;;
          *&#41; echo "Invalid response"
          esac
       done
    &#125;      
    
    AskGeometry&#40;&#41;
    &#123;
    default=$1
    shift
       echo $ECHO_OPT "$* &#91;$default&#93;&#58; \c"
       read rep
       &#91; ! "$rep" &#93; && rep=$default
    GEOMETRY=$rep
    &#125;      
    
    AskBPP&#40;&#41;
    &#123;
    default=$1
    shift
    while &#58;
       do
       echo $ECHO_OPT "$* &#91;$default&#93;&#58; \c"
       read rep
       &#91; ! "$rep" &#93; && rep=$default
       case $rep in
          8&#41; BPP="8"
             return $OK;;
          16&#41; BPP="16"
              return $OK;;
          *&#41; echo "Invalid response"
          esac
       done
    &#125;      
    
    GetCR&#40;&#41;
    &#123;
    echo $ECHO_OPT "\nPress <CR>\c"
    read t
    &#125;
    
    ComputeToken&#40;&#41;
    &#123;
    if &#91; "$1" -lt "10" &#93;; then
       TOKEN="axv"
       else
       if &#91; "$1" -lt "100" &#93;; then
          TOKEN="ax"
          else
          TOKEN="a"
          fi
       fi
    &#125;
    
    CheckInList &#40;&#41;
    &#123;
    ITEM=$1
    shift
    THELIST=$*
    if &#91; -z "$THELIST" &#93;; then
       return $FAIL
       fi
    for IDX in $THELIST
      do
      if &#91; "$IDX" = "$ITEM" &#93;; then
         return $OK
         fi
      done
    return $FAIL
    &#125;
    
    AddOneDisplay&#40;&#41;
    &#123;
    clear
    echo "                   ADDING A DISPLAY"
    echo " "
    DispFile
    echo $ECHO_OPT "Enter the display number &#40;or press <CR> to exit&#41;&#58; \c"
    read DISP
    if &#91; -z "$DISP" &#93;; then
       return 0
       fi
    CheckInList $DISP $DISPLIST
    if &#91; $? = $OK &#93;; then
       echo "This display has been already created!"
       GetCR
       return 1
       fi
    CheckInList $DISP $BUSYLIST
    if &#91; $? = $OK &#93;; then
       echo "This display number is not allowed!"
       GetCR
       return 1
       fi
    CheckInList $DISP $FREELIST
    if &#91; ! $? = $OK &#93;; then
       echo "This display number is not valid!"
       GetCR
       return 1
       fi
    QUESTION="Enter the resolution &#40;800x600, 1024x768...&#41; "
    AskGeometry "1024x768" $QUESTION
    QUESTION="Enter the number of bits/pixel &#40;8 or 16&#41; "
    AskBPP 8 $QUESTION
    if &#91; "$MANAGER" = "GDM" &#93;; then
       CreateLineInittab $DISP $GEOMETRY $BPP
       fi
    if &#91; "$MANAGER" = "KDM" &#93;; then
       CreateLineXservers $DISP $GEOMETRY $BPP
       fi
    if &#91; "$MANAGER" = "SCRIPT" &#93;; then
       echo $ECHO_OPT "Enter the associated command &#40;full pathname and options&#41;&#58; \c"
       read VNCSCRIPT
       CreateLineInittab $DISP $GEOMETRY $BPP $VNCSCRIPT
       fi
    echo $LINE >> $FILE_XS
    echo " "
    echo "OK, display '&#58;"$DISP"' added."
    MODIF="1"
    GetCR
    return 1
    &#125;
    
    AddDisplays&#40;&#41;
    &#123;
    while &#58;
       do
       AddOneDisplay
       if &#91; "$?" = "0" &#93;; then
          return
          fi
       done
    &#125;
    
    DelOneDisplay&#40;&#41;
    &#123;
    clear
    echo "                  DELETING A DISPLAY"
    echo " "
    DispFile
    echo $ECHO_OPT "Enter a display number or a list of display numbers &#40;<CR>&#58; exit&#41;&#58; \c"
    read NUM
    if &#91; -z "$NUM" &#93;; then
       return 0
       fi
    QUESTION="Are you sure ?&#58; "
    GetYN $YES $QUESTION
    if &#91; $? = $FAIL &#93;; then
       return 0
       fi
    for II in $NUM
       do
       CheckInList $II $DISPLIST
       if &#91; $? = $FAIL &#93;; then
          echo "Error, display number "$II" doesn't exist!"
          continue
          fi
       DISP="&#58;"$II  
       if &#91; "$MANAGER" = "KDM" &#93;; then
          CMD="/"$DISP"/d"
          else
          ComputeToken $II 
          CMD="/"$TOKEN$II"&#58;/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
    &#125;
    
    DelDisplays&#40;&#41;
    &#123;
    while &#58;
       do
       DelOneDisplay
       if &#91; "$?" = "0" &#93;; then
          return
          fi
       done
    &#125;
    
    ChgOneDisplay&#40;&#41;
    &#123;
    clear
    echo "                   MODIFYING A DISPLAY SETTINGS"
    echo " "
    echo "To change a display settings &#40;number of colors or resolution&#41;, please perform"
    echo "the following&#58;"
    echo "   - delete the display&#40;s&#41;"
    echo "   - EXIT and RESTART this utility"
    echo "   - add the display&#40;s&#41; 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
    &#125;
    
    
    GetGeometry &#40;&#41;
    &#123;
    set `echo $LINE`
    if &#91; "$MANAGER" = "SCRIPT" &#93;; then
       TOK=$3
       else
       if &#91; "$KDE22" = "0" &#93;; then
          TOK=$7
          else
          TOK=$3
          fi
       fi
    RES=`/usr/bin/printf '%9s' $TOK`
    return
    &#125;
    
    GetBPP &#40;&#41;
    &#123;
    if &#91; "$OS" = "Linux" &#93;; then 
       GREP="grep -w"
       else
       GREP="grep"
       fi
    BPP=`echo $LINE | $GREP 16`
    if &#91; "$BPP" &#93;; then 
       BPP="16"
       else
       BPP=`echo $LINE | $GREP 8`
       if &#91; "$BPP" &#93;; then 
          BPP=" 8"
          else
          BPP="unknown"
          fi
       fi
    &#125;
    
    GetScript &#40;&#41;
    &#123;
    set `echo $LINE`
    STR=$5".........................."
    SCRIPTNAME=`echo $STR | cut -b 1-16`
    SCRIPTNAME=$SCRIPTNAME"..."
    &#125;
    
    DispFile  &#40;&#41;
    &#123;
    echo "Contents of "$FILE_XS"&#58;"
    if &#91; "$MANAGER" = "GDM" &#93;; then
       DEB="1"
       MAXLIG="15"
       MAXCOL="3"
       fi
    if &#91; "$MANAGER" = "KDM" &#93;; then
       DEB="0"
       MAXLIG="14"
       MAXCOL="3"
       fi
    if &#91; "$MANAGER" = "SCRIPT" &#93;; then
       DEB="1"
       MAXLIG="15"
       MAXCOL="2"
       fi
    DISPLIST=""
    BUSYLIST=""
    FREELIST=""
    EOL="1"
    NB=$DEB
    NBDISP="0"
    while &#58;
       do
       if &#91; "$NB" -gt "9" &#93;; then
          TAB=""
          else  
          TAB=" "
          fi
       DISP="&#58;"$NB
       RES=""
       BPP=""
       SCRIPTNAME=""
       if &#91; "$MANAGER" = "GDM" &#93;; then
          ComputeToken $NB
          STR=$TOKEN$NB"&#58;"
          LINE=`grep "^$STR" $FILE_XS`
          if &#91; -z "$LINE" &#93;; then
             STATUS="free"
             FREELIST=$FREELIST" "$NB
             else
             LINE=`echo $LINE | grep govnc`
             if &#91; -z "$LINE" &#93;; then
                STATUS="busy"
                BUSYLIST=$BUSYLIST" "$NB
                else
                STATUS="Xvnc"
                fi
             fi
          fi
       if &#91; "$MANAGER" = "KDM" &#93;; then
          ComputeToken $NB
          STR=$TOKEN$NB"&#58;.&#58;respawn&#58;/etc/RunScriptVNC"
          LINE=`grep "^$STR" /etc/inittab`
    
          if &#91; "$LINE" &#93;; then
             STATUS="busy"
             BUSYLIST=$BUSYLIST" "$NB
             else
             STR=$DISP" &#91;Ll&#93;ocal"
             LINE=`grep "^$STR" $FILE_XS`
             if &#91; -z "$LINE" &#93;; then
                STATUS="free"
                FREELIST=$FREELIST" "$NB
                else
                LINE=`echo $LINE | grep Xvnc`
                if &#91; -z "$LINE" &#93;; then
                   STATUS="busy"                 # local X consol
                   BUSYLIST=$BUSYLIST" "$NB
                   else
                   STATUS="Xvnc"
                   fi
                fi
             fi
          fi
       
       if &#91; "$MANAGER" = "SCRIPT" &#93;; then
          LINE=""
          if &#91; "$DM" = "kdm" &#93;; then
             if &#91; "$KDE22" = "0" &#93;; then
                STR=$DISP" &#91;lL&#93;ocal"
                LINE=`grep "^$STR" $LOC_XS/Xservers`
    	    else
                ComputeToken $NB
                STR=$TOKEN$NB"&#58;.&#58;respawn&#58;/etc/govnc"
                LINE=`grep "^$STR" /etc/inittab`
    	    fi
             fi
          if &#91; "$DM" = "gdm" &#93;; then
             ComputeToken $NB
             STR=$TOKEN$NB"&#58;.&#58;respawn&#58;/etc/govnc"
             LINE=`grep "^$STR" /etc/inittab`
             fi
          if &#91; "$LINE" &#93;; then
             STATUS="busy"
             BUSYLIST=$BUSYLIST" "$NB
             else 
             ComputeToken $NB
             STR=$TOKEN$NB"&#58;.&#58;respawn&#58;/etc/RunScriptVNC"
             LINE=`grep "^$STR" $FILE_XS`
             if &#91; -z "$LINE" &#93;; then
                STATUS="free"
                FREELIST=$FREELIST" "$NB
                else
                STATUS="Xvnc"
                fi
             fi
          fi
    
       if &#91; "$STATUS" = "Xvnc" &#93;; then
          GetGeometry
          GetBPP
          if &#91; "$MANAGER" = "SCRIPT" &#93;; then
             GetScript
             fi
          DISPLIST=$DISPLIST" "$NB
          NBDISP=`expr $NBDISP + 1`
          fi
    
       echo $ECHO_OPT "$DISP$TAB \c"
       if &#91; "$STATUS" = "Xvnc" &#93;; then
          if &#91; "$MANAGER" = "SCRIPT" &#93;; then
             echo $ECHO_OPT "&#40;$RES-$BPP&#41; $SCRIPTNAME\c"
             else
             echo $ECHO_OPT "$STATUS $RES-$BPP bpp\c"
             fi 
          else
          echo $ECHO_OPT "$STATUS                 \c"
          if &#91; "$MANAGER" = "SCRIPT" &#93;; then
             echo $ECHO_OPT "             \c"
             fi 
          fi
       if &#91; "$EOL" = "$MAXCOL" &#93;; then
          echo " "
          EOL="1"
          NB=`expr $DEB + 1`
          DEB=$NB
          if &#91; "$NB" -gt "$MAXLIG" &#93;; then
             break
             fi
          else
          EOL=`expr $EOL + 1`
          echo $ECHO_OPT "  \c"    #trailer spaces
          NB=`expr $NB + $MAXLIG`
          fi
       done
    echo " "
    &#125;
    
    CreateLineInittab &#40;&#41;
    &#123;
    P1=$1
    P2=$2
    P3=$3
    shift
    shift
    shift
    P4=$*
    LOG="1>/tmp/axvnclog"$P1" 2>&1"
    ComputeToken $P1
    LINE=$TOKEN$P1"&#58;"$RUNLEVEL"&#58;"
    if &#91; -z "$P4" &#93;; then
       #no script
       LINE=$LINE"respawn&#58;"$FILE_GOVNC
       else
       LINE=$LINE"respawn&#58;"$FILE_VNCSCR
       fi
    LINE=$LINE" "$P1" "$P2" "$P3" "$P4" "$LOG
    &#125;
    
    CreateLineXservers &#40;&#41;
    &#123;
    DISPLAY="&#58;"$1
    PORT=`expr 5900 + $1`
    
    GEOMETRY=$2
    
    if &#91; "$3" = "8" &#93;; 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 "
    &#125;
    
    BackUp  &#40;&#41;
    &#123;
    SAV_FILE=$1".SAV"
    if &#91; ! -f $SAV_FILE &#93;; then
       echo "Backing up $1 into $SAV_FILE..."
       cp $1 $SAV_FILE
       sleep 1
       fi
    &#125;
    
    ManageFile &#40;&#41;
    &#123;
    MANAGER=$1
    MODIF="0"
    while &#58;
       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 &#40;A, D, M or Q&#41;&#58; \c"
       read rep
       case $rep in
         &#91;Aa&#93;&#41; AddDisplays;;
         &#91;Dd&#93;&#41; DelDisplays;;
         &#91;Mm&#93;&#41; ChgOneDisplay;;
         &#91;Qq&#93;&#41; break;; 
         *&#41; echo "Invalid choice"
            GetCR;;
         esac
       done
    
    if &#91; "$MODIF" = "0" &#93;; then
       exit
       fi
    &#125;
    
    CheckHostFile &#40;&#41;
    &#123;
    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 &#91; ! "$WORD" = "localhost" &#93;; then
         CORRECTFILE="0"
         fi
      done 
    if &#91; "$CORRECTFILE" = "0" &#93;; 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 &#40;localhost&#41;"
       echo "and one line about the Linux Ethernet interface."
       echo "Example&#58;"
       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
    &#125;
    
    
    CheckAutoLog &#40;&#41;
    &#123;
    if &#91; ! -f "$FILE_AUTOLOG" &#93;; 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'&#58;"
    if &#91; $? = $FAIL &#93;; then
       return 
       fi
    mv $FILE_AUTOLOG $FILE_AUTOLOG".SAV"
    echo "OK, this is done"
    &#125;
    
    EnableXDMCP &#40;&#41;
    &#123;
    echo " "
    NEW_LIST=""
    for ONEFILE in $FILE_GDM
       do
       echo "*** Checking XDMCP &#40;"$ONEFILE"&#41;"
       LINE=`grep "axvnc" $ONEFILE`
       if &#91; ! "$LINE" &#93;; then
          NEW_LIST=$NEW_LIST" "$ONEFILE
          echo "-> must be modified"
          else
          echo "-> xdmcp has been already enabled !"
          fi
       done
    if &#91; ! "$NEW_LIST" &#93;; 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 &#91; ! "$LINE1$LINE2" &#93;; 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&#58;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
    &#125;
    
    
    GDMStyle &#40;&#41;
    &#123;
    echo " "
    echo "/etc/inittab and "$FILE_GDM" will be modified."
    QUESTION="Please confirm&#58; "
    GetYN $YES $QUESTION
    if &#91; $? = $FAIL &#93;; then
       exit
       fi     
    
    FILE_XS="/etc/inittab"
    
    BackUp $FILE_XS
    BackUp $FILE_GDM 
    
    FILE_GOVNC="/etc/govnc"
    CREATE="0"
    if &#91; ! -f "$FILE_GOVNC" &#93;; then
       CREATE="1"
       else
       RES=`cat /etc/govnc | grep "Axel-V1.6"`
       if &#91; -z "$RES" &#93;; then
          CREATE="1"
          fi
       fi
    
    if &#91; "$CREATE" = "1" &#93;; 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?&#58; "
    GetYN $YES $QUESTION
    if &#91; $? = $OK &#93;; then
       init q
       echo "OK, command done"
       else
       echo "This modification will take effect after rebooting the Linux box"
       exit
       fi
    if &#91; "$NBDISP" -gt "3" -a "$FONTSERVER" = "1" &#93;; 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 &#40;i.e displays&#41;."
       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
    &#125;
    
    KDMStyle &#40;&#41;
    &#123;
    FILE_XS=$LOC_XS"/Xservers"
    echo $FILE_XS" will be modified."
    QUESTION="Please confirm&#58; "
    GetYN $YES $QUESTION
    if &#91; $? = $FAIL &#93;; then
       exit
       fi     
    
    if &#91; ! -f "$FILE_XS" &#93;; 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 &#91; "$PIDFILE" &#93;; then
       PIDXDM=`cat $PIDFILE`
       fi 
    
    if &#91; "$PIDXDM" &#93;; 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 ? &#58; "
       GetYN $YES $QUESTION
       if &#91; $? = $OK &#93;; then
          kill -HUP $PIDXDM
          echo "OK, signal sent"
          exit
          fi
       fi     
    
    echo " "
    if &#91; "$OS" = "SCO_SV" &#93;; 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
    &#125;
    
    CheckInet &#40;&#41;  
    &#123;
    if &#91; ! -f "$LOC_INETD" &#93;; 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 &#40;port "$PORT"&#41;&#58; \c"
    STR="vnc"$GEOMETRY"-"$BPP
    RET=`grep $STR $FILE_SERVICES`
    if &#91; ! -z "$RET" &#93;; then
       echo "OK &#40;already set&#41;"
       return
       fi
    RET=`grep $PORT $FILE_SERVICES`
    if &#91; ! -z "$RET" &#93;; then
       echo "FAILED &#40;port already in use&#41;"
       return
       fi
    MODIF="1"
    echo "OK"
    echo $ECHO_OPT $STR"\t"$PORT"/tcp" >> $FILE_SERVICES
    RET=`grep $STR $LOC_INETD`
    if &#91; ! -z "$RET" &#93;; then
       return
       fi
    if &#91; "$BPP" = "8" &#93;; then
       BPP="-depth 8 -cc 3"
       else
       BPP="-depth 16"
       fi
    
    if &#91; "$XINET" = "0" &#93;; 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 "   &#123;"  >> $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 "   &#125;"  >> $LOC_INETD
       echo " "  >> $LOC_INETD
       fi
    &#125;
    
    KDE22Style &#40;&#41;
    &#123;
    echo " "
    echo "&#40;x&#41;inetd and "$FILE_GDM" will be modified."
    QUESTION="Please confirm&#58; "
    GetYN $YES $QUESTION
    if &#91; $? = $FAIL &#93;; then
       exit
       fi     
    
    FILE_SERVICES="/etc/services"
    
    RET=`ps -ef |grep xinetd | grep -v grep`
    if &#91; ! -z "$RET" &#93;; then
       if &#91; -d "/etc/xinetd.d" &#93;; 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 &#91; ! -z "$RET" &#93;; then
          if &#91; -d "/etc/inet.d" &#93;; then
             LOC_INETD="/etc/inet.d/vnc"
             else
             LOC_INETD="/etc/inetd.conf"
             fi
          SIG="-HUP"
          XINET="0"
          else
          echo "*** ERROR&#58; no &#40;x&#41;inetd daemon running."
          exit
          fi
       fi
    set `echo $RET`
    PID=$2
    echo " "
    echo "*** Checking INET environment &#40;"$FILE_SERVICES" and "$LOC_INETD"&#41;" 
    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 &#91; "$MODIF" = "1" &#93;; then
       echo " " 
       echo "NOTE&#58; modifications will take effect either after rebooting the Linux machine"
       echo "      or sending signal "$SIG" to &#40;x&#41;inetd process."
       echo " "
       if &#91; "$PID" &#93;; then
          QUESTION="Do you want to send the signal "$SIG" to &#40;x&#41;inetd &#40;pid&#58; "$PID"&#41; ? &#58; "
          GetYN $YES $QUESTION
          if &#91; $? = $OK &#93;; then
             kill $SIG $PID
             echo "OK, signal sent"
             fi
          fi     
       fi
    CheckAutoLog
    BackUp $FILE_GDM 
    EnableXDMCP
    exit
    &#125;
    
    CreateScriptVNC &#40;&#41;
    &#123;
    FILE=$1
    echo "Creating "$FILE"..."
    if &#91; "$OS" = "SCO_SV" &#93;; 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&#58; " >> $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=\"&#58;\"\$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 &#91; \"\$3\" = \"8\" &#93;; 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 &#91; ! -z \"\$TEXT\" &#93;; 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 &#58; " >> $FILE
    echo $ECHO_OPT "   do " >> $FILE
    echo $ECHO_OPT "   REP=\`ps -ef | grep \"Xvnc \$DISPLAY\" | grep -v grep\` " >> $FILE
    echo $ECHO_OPT "   if &#91; -z \"\$REP\" &#93;; 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
    &#125;
    
    CreateGovnc &#40;&#41;
    &#123;
    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&#58; " >> $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=\"&#58;\"\$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 &#91; \"\$3\" = \"8\" &#93;; 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 &#91; "$KDE22" = "0" &#93;; 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
    &#125;
    
    CreateExampleFiles&#40;&#41;
    &#123;
    echo "Creating example files&#58;"
    CreateLineXservers "1" "800x600" "8"
    FILE="/tmp/xservers.add"
    echo "   - $FILE..."
    echo $LINE > $FILE
    
    FILE="/tmp/govnc"
    echo "   - $FILE..."
    CreateGovnc $FILE
    echo "OK"
    &#125;
    
    Banner &#40;&#41;
    &#123;
    clear
    echo "                          AXEL VNC UTILITY &#40;$VERSION&#41;"
    echo "                          -------------------------"
    echo " "
    echo " "
    &#125;
    
    ConfOpenServer &#40;&#41;
    &#123;
    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
    &#125;
    
    ConfUW &#40;&#41;
    &#123;
    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
    &#125;
    
    ConfOU8 &#40;&#41;
    &#123;
    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
    &#125;
    
    ConfHPUX &#40;&#41;
    &#123;
    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
    &#125;
    
    ConfSunOS &#40;&#41;
    &#123;
    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
    &#125;
    
    SelectMethod &#40;&#41;
    &#123;
    KDE22="0"
    if &#91; "$OS" = "Linux" &#93;; then
       DM=""
       RET=`ps -ef | grep kdm | grep -v grep`
       FILE_GDM=""
       if &#91; "$RET" &#93;; then
          DM="kdm"
    ##### KDE 2.2 #####
          if &#91; -f "/etc/kde/kdm/kdmrc" &#93;; then
             KDE22="1"
             FILE_GDM=$FILE_GDM" /etc/kde/kdm/kdmrc"
             fi
          if &#91; -f "/usr/share/config/kdm/kdmrc" &#93;; then
             KDE22="1"
             FILE_GDM=$FILE_GDM" /usr/share/config/kdm/kdmrc"
             fi
          if &#91; -f "/opt/kde2/share/config/kdm/kdmrc" &#93;; then
             KDE22="1"
             FILE_GDM=$FILE_GDM" /opt/kde2/share/config/kdm/kdmrc"
             fi
    ##### KDE 3 #####
          if &#91; -f "/opt/kde3/share/config/kdm/kdmrc" &#93;; then
             KDE22="1"
             FILE_GDM=$FILE_GDM" /opt/kde3/share/config/kdm/kdmrc"
             fi
          if &#91; -f "/usr/kde/share/config/kdm/kdmrc" &#93;; then   #Use It
             KDE22="1"
             FILE_GDM=$FILE_GDM" /usr/kde/share/config/kdm/kdmrc"
             fi
          if &#91; -f /etc/opt/kde3/share/config/kdm/kdmrc &#93;; 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 &#91; "$RET" &#93;; then
             DM="gdm"
             fi
          fi
       else
       DM="kdm"
       fi
    
    if &#91; "$SCRIPT_OK" = "1" &#93;; 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&#58;"
    echo "   - either to get a graphical login and to access a desktop &#40;KDE, GNOME, etc.&#41;"
    echo "   - or to run automatically an X software &#40;netscape, rdesktop, etc.&#41;"
    echo " "
    while &#58;
       do
       echo $ECHO_OPT "Select the method &#40;<L>ogin or <A>ny software&#41;&#58; \c"
       read rep
       &#91; ! "$rep" &#93; && rep=$default
       case $rep in
          &#91;Ll&#93;&#41; break;;
          &#91;Aa&#93;&#41; RunScriptMethod
                return;;
          *&#41; echo "Invalid response"
          esac
       done
    fi
    ### LOGIN METHOD ###
    case $OS in
       "SCO_SV"&#41;   ConfOpenServer;;
       "UnixWare"&#41; ConfUW;;
       "OpenUNIX"&#41; ConfOU8;;
       "Linux"&#41;    ConfLinux;;
       "HP-UX"&#41;    ConfHPUX;;
       "SunOS"&#41;    ConfSunOS;;
       *&#41;          echo "ERROR&#58; $OS is a non-supported operating system!"
                   exit;;
       esac
    &#125;      
    
    RunScriptMethod &#40;&#41;
    &#123;
    Banner
    FILE_XS="/etc/inittab"
    
    BackUp $FILE_XS
    
    FILE_VNCSCR="/etc/RunScriptVNC"
    CREATE="0"
    if &#91; ! -f "$FILE_VNCSCR" &#93;; then
       CREATE="1"
       else
       RES=`cat /etc/RunScriptVNC | grep "Axel-V1.6"`
       if &#91; -z "$RES" &#93;; then
          CREATE="1"
          fi
       fi
    
    if &#91; "$CREATE" = "1" &#93;; 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?&#58; "
    GetYN $YES $QUESTION
    if &#91; $? = $OK &#93;; then
       init q
       echo "OK, command done"
       else
       echo "This modification will take effect after rebooting the Unix/Linux box"
       exit
       fi
    &#125;
    
    CheckXaccess &#40;&#41;
    &#123;
    XACC=$LOC_XS"/Xaccess"
    echo " "
    echo $ECHO_OPT "*** Checking "$XACC"\c"
    if &#91; ! -f "$XACC" &#93;; then
       echo " "
       echo "*** WARNING&#58; "$XACC" not present"
       echo " "
       return
       fi
    RESTRICTION="0"
    RET=`grep "^&#91;*&#93;" $XACC`
    if &#91; -z "$RET" &#93;; then
       RESTRICTION="1"
       else
       RET2=`echo $RET | grep "any host"`
       if &#91; -z "$RET2" &#93;; then
          RESTRICTION="1"
          fi
       fi
    if &#91; "$RESTRICTION" = "1" &#93;; then
       echo " "
       echo "*** WARNING&#58; 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 ?&#58; "
       GetYN $YES $QUESTION
       if &#91; $? = $OK &#93;; then
          exit     
          fi
       echo "OK, let's go. But remind to modify Xaccess later."
       echo " "
       return
       fi
    echo " -> OK"
    echo " "
    &#125;
    
    KDE22Method &#40;&#41;
    &#123;
    STRXDMCP="Xdmcp"
    #with KDE22 no font path is needed.
    FP=""
    while &#58;
       do
       echo $ECHO_OPT "Do you want to use the <X>inet method or the [I]nittab method &#40;X/I&#41; ?&#58; \c"
       read rep
       case $rep in
          &#91;xX&#93;&#41; KDE22Style;;
          &#91;iI&#93;&#41; GDMStyle;;
          *&#41; echo "Invalid response"
          esac
       done
    &#125;      
    
    
    ConfLinux &#40;&#41;
    &#123;
    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 &#91; "$DM" = "kdm" &#93;; then
       if &#91; "$KDE22" = "1" &#93;; then
          echo "*** INFO&#58; KDE 2.2 or KDE 3 is running"
          echo " "
          echo "With KDE 2.2 or KDE 3, three operations must be performed&#58;"
          echo "  * enabling access &#40;Xaccess&#41;"
          echo "  * adding VNC terminals. Two methods can be used to run Xvnc daemons&#58;"
          echo "     1 - using &#40;x&#41;inetd &#40;a Xvnc daemon is only spawned when a VNC connection"
          echo "         is opened&#41;"
          echo "     2 - using /etc/inittab &#40;at Linux boot time one Xvnc daemon is run"
          echo "         per VNC terminal&#41;"
          echo "  * enabling XDMCP &#40;kdmrc&#41;"
          echo " "
          echo "Note&#58; with KDE 2.2 or KDE 3 no font path is needed &#40;-fp Xvnc option&#41;. "
          else
          echo "*** INFO&#58; KDE &#40;kdm&#41; is running"
          echo " "
          echo "With KDE, two operations must be performed&#58;"
          echo "  * enabling access &#40;Xaccess&#41;"
          echo "  * adding VNC terminals in the file Xservers"
          fi
       CheckXaccess
       if &#91; "$KDE22" = "1" &#93;; then
          KDE22Method
          else
          KDMStyle
          fi
       exit
       fi
    
    if &#91; "$DM" = "gdm" &#93;; then
       echo "*** INFO&#58; GNOME &#40;gdm&#41; is running"
       echo " "
       echo "With GNOME, two operations must be performed&#58;"
       echo "  * adding VNC terminals. This is done through /etc/inittab &#40;at Linux"
       echo "    boot time, one Xvnc daemon is run per VNC terminal&#41;"
       echo "  * enabling XDMCP &#40;file gdm.conf&#41;"
       echo " "
       KDE22="0"
       FILE_GDM=""
       if &#91; -f "/etc/X11/gdm/gdm.conf" &#93;; then
          FILE_GDM="/etc/X11/gdm/gdm.conf"
          fi
       if &#91; -f "/etc/opt/gnome/gdm/gdm.conf" &#93;; then
          FILE_GDM="/etc/opt/gnome/gdm/gdm.conf"
          fi
       if &#91; -f "/etc/opt/gnome2/gdm/gdm.conf" &#93;; then
          FILE_GDM="/etc/opt/gnome2/gdm/gdm.conf"
          fi
       if &#91; -z "$FILE_GDM" &#93;; then
          echo "ERROR&#58; Can not find gdm.conf. "
          echo "axvnc ended."
          exit
          fi
       STRXDMCP="xdmcp"
       CheckHostFile 
       GDMStyle
       exit
       fi
    
    echo "*** INFO&#58; gdm and kdm are not running"
    echo "You must configure manually Linux. To help you the following files are created."
    CreateExampleFiles
    echo " "
    &#125;
    
    ################
    ##### MAIN #####
    ################
    
    VERSION="V1.3-2"
    
    if &#91; "$1" = "-h" &#93;; then
       echo "Axel VNC Configurator for Unix/Linux"
       echo "Version "$VERSION
       echo "&#40;C&#41; 2002-2003 - Axel"
       echo " "
       echo "Usage&#58;"
       echo "   axvnc &#91;-nofp&#93; &#91;-h&#93;"
       echo "      -h&#58; on-line help   "
       echo "      -nofp&#58; No Font Path"
       echo "      -os&#58; display certificated O.S."
       echo " "
       echo "Note&#58; axvnc must be run from the graphical Unix/Linux console. "
       echo " "
       exit
       fi
    
    if &#91; "$1" = "-os" &#93;; then
       echo "Axel VNC Configurator for Unix/Linux"
       echo "Version "$VERSION
       echo "&#40;C&#41; 2002-2003 - Axel"
       echo " "
       echo "This utility is certified for&#58;"
       echo "    - HP-UX 11"
       echo "    - Mandrake 9.0 &#40;and old previous versions&#41;"
       echo "    - Open Unix 8.0"
       echo "    - Open Linux 3.11"
       echo "    - Red Hat 9.0 &#40;and old previous versions&#41;"
       echo "    - SCO OpenServer 5 and 6"
       echo "    - Sun OS"
       echo "    - Suse 8.1 &#40;and old previous versions&#41;"
       echo "    - United Linux 4.0"
       echo "    - UnixWare 7.11"
       echo "    - Use It 1.3"
       echo " "
       exit
       fi
    
    if &#91; "$1" = "-nofp" &#93;; then
       NOFP="1"
       else
       NOFP="0"
       fi
    
    YES="Y"
    yes="y"
    NO="N"
    no="n"
    
    &#58; $&#123;OK=0&#125;
    &#58; $&#123;FAIL=1&#125;
    
    
    FILE_AUTOLOG="/etc/sysconfig/autologin"
    
    Banner
    
    #if &#91; ! "$LOGNAME" = "root" &#93;; then
    #   echo "Please, logon as root and restart this utility."
    #   exit
    #   fi
    
    OS=`uname -s`
    
    if &#91; "$OS" = "SCO_SV" -o "$OS" = "UnixWare" -o "$OS" = "HP-UX" -o "$OS" = "SunOS" -o "$OS" = "OpenUNIX" &#93;; then
       STR=`who -r`
       if &#91; ! "$STR" &#93;; then
          echo "*** ERROR&#58; can not get runlevel"
          exit
          fi
       set `echo $STR`
       RUNLEVEL=$3
       fi
    
    if &#91; "$OS" = "Linux" &#93;; then
       ECHO_OPT=" -e "
       STR=`runlevel`
       if &#91; ! "$STR" &#93;; then
          echo "*** ERROR&#58; can not get runlevel"
          exit
          fi
       set `echo $STR`
       RUNLEVEL=$2
       fi
    
    if &#91; "$OS" = "SunOS" &#93;; then
       X11BIN="/usr/openwin/bin/"
       X11LIB="/usr/openwin/lib/"
       else
       X11BIN="/usr/bin/X11/"
       X11LIB="/usr/lib/X11/"
       fi
    
    echo "Checking system configuration&#58;"
    echo " "
    echo "  - Operating System&#58;"
    echo "    --> "$OS" &#40;runlevel "$RUNLEVEL"&#41;"
    if &#91; -z "$RUNLEVEL" &#93;; then
       echo " "
       echo "ERROR&#58; the RUNLEVEL environment variable is not set"
       echo " "
       exit
       fi
    PATHFILE="/usr/bin/"
    if &#91; "$OS" = "SCO_SV" &#93;; then
       ver=`uname -v`
       PATHFILE="/bin/"
       major=`expr substr $ver 1 1`
       minor=`expr substr $ver 5 1`
       if &#91; "$major" = "5" -a "$minor" -lt "5" &#93;; then
          echo "ERROR&#58; SCO versions lower than 5.0.5 are not supported by this utility"
          exit
          fi 
       if &#91; "$major" = "6" &#93;; then
          NOFP="1"
          fi 
       fi 
    echo " "
    echo $ECHO_OPT "  - VNC server &#40;Xvnc&#41;&#58;"
    if &#91; ! -f /usr/local/bin/Xvnc &#93;; then
       echo " "
       echo "ERROR&#58; Xvnc is not present in /usr/local/bin. "
       echo "Please copy it and restart this utility."
       echo " "
       exit
       fi
    
    if &#91; ! -x /usr/local/bin/Xvnc &#93;; then
       echo " "
       echo "ERROR&#58; 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 &#91; -z "$RET" &#93;; then
       echo " "
       else
       echo " &#40;Version 4 detected&#41;"
       VNC4=$OK
       SECURITYTYPES="-SecurityTypes None"
       fi
    echo " "
    echo "  - Misc Utilities&#58;"
    if &#91; ! -x "/bin/sed" &#93;; then
       echo " "
       echo "ERROR&#58; '/bin/sed' is not present "
       exit
       fi
    if &#91; ! -x "/usr/bin/printf" &#93;; then
       echo " "
       echo "ERROR&#58; '/usr/bin/printf' is not present "
       exit
       fi
    SCRIPT_OK="1"
    if &#91; ! -x $X11BIN"xsetroot" &#93;; then
       echo "WARNING&#58; '"$X11BIN"xsetroot' is not present "
       SCRIPT_OK="0"
       fi
    if &#91; ! -x $X11BIN"xterm" &#93;; then
       echo "WARNING&#58; '"$X11BIN"xterm' is not present "
       SCRIPT_OK="0"
       fi
    if &#91; ! -x $PATHFILE"file" &#93;; then
       echo "WARNING&#58; '"$PATHFILE"file' is not present "
       SCRIPT_OK="0"
       fi
    
    if &#91; "$SCRIPT_OK" = "1" &#93;; then
       echo "    --> OK"
       else              
       echo "    --> Auto-Application method not available"
       fi
    
    echo " "
    echo "  - X11 font&#58;"
    
    FONTSERVER="0"
    if &#91; "$NOFP" = "1" &#93;; then
       echo "    --> Font Path not used"
       else
       XSET=$X11BIN"xset"
    
       if &#91; ! -f $XSET &#93;; then
          echo " "
          echo "ERROR&#58; 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 &#91; -z "$RET" &#93;; then
          echo " "
          echo "ERROR&#58; can not execute '$XSET'  "
          echo "Please logon on the main console &#40;&#58;0&#41; 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/&#123;
    n
    &#58;x
    p
    n
    /Bug/b
    bx
    &#125;" /tmp/axfont`
       rm -f /tmp/axfont
    
       if &#91; ! -z "$FP" &#93;; then
          #OK, Check if a font server is used
          FS=`echo $FP | grep $FSNAME`
          if &#91; ! -z "$FS" &#93;; then
             FONTSERVER="1"
             fi
          else
          #the previous search fails
          FP=`$XSET 2>/dev/null | grep lib 2>/dev/null`
    
          if &#91; -z "$FP" &#93;; then
             FP=`$XSET 2>/dev/null | grep $FSNAME 2>/dev/null`
             FONTSERVER="1"
             fi
          fi
    
       if &#91; -z "$FP" &#93;; then
          echo "    --> ERROR&#58; Can not get Font Paths. Default one is used."
          else
          echo "    -->"$FP
          FP="-fp "$FP 
          fi
       fi
    GetCR
    
    case $OS in
       "SCO_SV"&#41;   LOC_XS="/usr/lib/X11/scologin"
                   LOCAL="local";;
       "UnixWare"&#41; LOC_XS="/usr/dt/config"
                   LOCAL="local@none"
                   PIDFILE="/var/dt/Xpid";;
       "OpenUNIX"&#41; LOC_XS="/usr/dt/config"
                   LOCAL="local@none"
                   PIDFILE="/usr/dt/Xpid";;
       "Linux"&#41;    if &#91; -f "/etc/X11/kdm/Xservers" &#93;; then
                      # CALDERA
                      LOC_XS="/etc/X11/kdm"
                      else
                      # OTHER LINUX&#58; RED HAT, SUSE, MANDRAKE
                      LOC_XS="/etc/X11/xdm"
                      PIDFILE="/var/run/xdm.pid"
                      fi
                   LOCAL="local"
                   ECHO_OPT=" -e ";;
       "HP-UX"&#41;    LOC_XS="/etc/dt/config"
                   LOCAL="local@none"
                   PIDFILE="/var/dt/Xpid";;
       "SunOS"&#41;    LOC_XS="/etc/dt/config"
                   LOCAL="local@none"
                   PIDFILE="/var/dt/Xpid";;
       *&#41;          echo "ERROR&#58; $OS is a non-supported operating system!"
                   exit;;
       esac
    
    SelectMethod

  2. #2
    Just Joined!
    Join Date
    Oct 2005
    Posts
    2

    Easy VNC Setup (Follow up)

    The part i had to change was

    Code:
    STR=`runlevel`
    to

    Code:
    STR=`/sbin/runlevel`

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •