Page 1 of 3 123 LastLast
Results 1 to 10 of 25

Thread: how can i get a command to execute after X but before GDM?

  1. #1
    Join Date
    Nov 2006
    Beans
    184

    x11vnc issues

    GO TO PAGE 3.

    IGNORE BELOW
    ------------------------------
    ORIGINAL POST


    i need to start up a VNC server on this machine... i have a working command that supports encryption and authorization, but i must login to the machine locally first THEN run the command, then use VNC.

    how do i make an /etc/init.d/ start up entry so that my command will be executed just after X gets loaded (but before GDM)


    --- thanks!
    Last edited by Darth_tater; August 16th, 2009 at 08:26 PM.

  2. #2
    Join Date
    Oct 2005
    Beans
    142
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    Re: how can i get a command to execute after X but before GDM?

    As far as creating your init script you would write it and then place it into /etc/init.d and the symbolically link it to the proper runlevels (/etc/rc2.d, /etc/rc4.d, /etc/rc5.d...) using a number that would put it in the propper order.

    In other words, after you write and oplace your script in init.d you would link it thusly:
    Code:
    cd /etc/rc2.d
    ln -s ../init.d/script S21script
    "S21" would be replaced with the proper lettering for the order you want to achieve -- they're started alphabetically.

    However, I don't believe that you can do that. In Ubuntu, as I understand it, the XServer is started by GDM -- I could be wrong as I've not actually dug into it, but experientially that seems to be it.

    Sorry I couldn't help any more, but you didn't actually say what you were wanting to do. If you can provide more information I may be able to help more.


    Xan

  3. #3
    Join Date
    Nov 2006
    Beans
    184

    Re: how can i get a command to execute after X but before GDM?

    Well, I want to have a VNC server running on this machine. As it is, x11VNC is set up to work on display :0.

    The problem is, that I have no way of launching this command unless I login physically at the machine or over SSH. This machine needs to be FULLY accessible via remote for VNC… SSH wont always be an option to get VNC up and running.

    My only option is to have the VNC server start up before the user sees the GDM login screen… that way, a user can login and use the box on display 0 locally and/or remotely. Thus, I NEED the command to be executed before the user sees the GDM login screen. 99.9% of the time, this machine will be accessed remotely, the only time it will be accessed locally is if there is some serious problem...

     Hopefully that will help clear up any confusion… I wrote my first post in a hurry.
    Last edited by Darth_tater; July 10th, 2008 at 11:44 PM. Reason: typos

  4. #4
    Join Date
    Oct 2005
    Beans
    142
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    Re: how can i get a command to execute after X but before GDM?

    Ok, I have an idea, but it will require some tweaking and reading. I use an open source solution called Synergy (great program!) that allows you to use the same keyboard and mouse on two computers without a KVM and it has to be started by the display manager (GDM).

    http://synergy2.sourceforge.net/index.html

    I believe you can use the same method that I do for Synergy to start your VNC server.

    There is a config file, /etc/gdm/PreSession/Default, that GDM runs before login. If you have it run your script (just put it at the top or bottom of the file) if should start VNC as soon as GDM loads.

    One thing you want to make sure of is that if you restart gdm it doesn't get started twice, so make sure to kill it before you start it and sleep for a second or two.

    Let me know if you need clarification or further help,

    Xan

  5. #5
    Join Date
    Dec 2006
    Beans
    810

    Re: how can i get a command to execute after X but before GDM?

    Quote Originally Posted by Darth_tater View Post
    i need to start up a VNC server on this machine... i have a working command that supports encryption and authorization, but i must login to the machine locally first THEN run the command, then use VNC.

    how do i make an /etc/init.d/ start up entry so that my command will be executed just after X gets loaded (but before GDM)
    Have a look here

    http://www.karlrunge.com/x11vnc/faq....isplay-manager

    under the description "Continuously".
    Last edited by krunge; January 28th, 2009 at 01:54 AM.

  6. #6
    Join Date
    Nov 2006
    Beans
    184

    Re: how can i get a command to execute after X but before GDM?

    Nope... something isn’t working. The VNC server will not start by its self… I am not sure why.

    Once the computer gets to GDM and I cannot connect via VNC, I start up my ssh client and run the following command
    sudo x11vnc -display :0 -bg -usepw -auth /var/lib/gdm/:0.Xauth -forever
    I can then login over VNC. as soon as i login, my connection is killed off, and i have to restart the connection. As soon as i restart the connection (and server via SSH) i can use my desktop as i normally would.
    Last edited by Darth_tater; July 11th, 2008 at 05:12 AM. Reason: typos

  7. #7
    Join Date
    Nov 2006
    Beans
    184

    Re: how can i get a command to execute after X but before GDM?

    Quote Originally Posted by UbuntuUser3859 View Post
    .

    There is a config file, /etc/gdm/PreSession/Default, that GDM runs before login. If you have it run your script (just put it at the top or bottom of the file) if should start VNC as soon as GDM loads.

    Xan

    are the commands in that file executed with root powers? if not, the sudo appended to my command wont work...and the vnc xerver will fail to start.

    that could explain why it isin't starting.

  8. #8
    Join Date
    Oct 2005
    Beans
    142
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    Re: how can i get a command to execute after X but before GDM?

    I'm not entirely sure what permissions the commands are issued as. I know that anything post-login is run as the logging in user.

    The link that Krunge posted seems to have a great deal of information for your software along the same lines as I mentioned, I would look there.


    Xan

  9. #9
    Join Date
    Nov 2006
    Beans
    184

    Re: how can i get a command to execute after X but before GDM?

    Thanks for all your help, but I still haven’t managed to get it fully working.
    I still have to start the session manually (over SSH), but I am no longer kicked out when I login… I can keep my current session running!
    I guess the next thing for me to do would be to look at how init.d works…. That should solve my problem.

    This is what my /etc/gdm/Init/Default file looks like :

    Code:
    #!/bin/sh
    # Stolen from the debian kdm setup, aren't I sneaky
    # Plus a lot of fun stuff added
    #  -George
    
    PATH=/usr/bin:$PATH
    OLD_IFS=$IFS
    
    gdmwhich () {
      COMMAND="$1"
      OUTPUT=
      IFS=:
      for dir in $PATH
      do
        if test -x "$dir/$COMMAND" ; then
          if test "x$OUTPUT" = "x" ; then
            OUTPUT="$dir/$COMMAND"
          fi
        fi
      done
      IFS=$OLD_IFS 
      echo "$OUTPUT"
    }
    
    sysresources=/etc/X11/Xresources
    
    # merge in defaults
    if [ -f "$sysresources" ]; then
        xrdb -merge "$sysresources"
    fi
    
    sysmodmap=/etc/X11/Xmodmap
    
    XMODMAP=`gdmwhich xmodmap`
    if [ x$XMODMAP != x ] ; then
      if [ x$GDM_PARENT_DISPLAY = x ]; then
        if [ -f $sysmodmap ]; then
          $XMODMAP $sysmodmap
        fi
      else
        ( DISPLAY=$GDM_PARENT_DISPLAY XAUTHORITY=$GDM_PARENT_XAUTHORITY $XMODMAP -pke ) | $XMODMAP -
      fi
    
      #
      # Switch Sun's Alt and Meta mod mappings
      #
    
      UNAME=`gdmwhich uname`
      PROCESSOR=`$UNAME -p`
      if [ x$PROCESSOR = xsparc ]; then
        if $XMODMAP | /usr/bin/grep mod4 | /usr/bin/grep Alt > /dev/null 2>/dev/null
        then
          $XMODMAP -e "clear Mod1" \
                   -e "clear Mod4" \
                   -e "add Mod1 = Alt_L" \
                   -e "add Mod1 = Alt_R" \
                   -e "add Mod4 = Meta_L" \
                   -e "add Mod4 = Meta_R"
        fi
      fi
    fi
    
    SETXKBMAP=`gdmwhich setxkbmap`
    if [ x$SETXKBMAP != x ] ; then
      # FIXME: is this all right?  Is this completely on crack?
      # What this does is move the xkb configuration from the GDM_PARENT_DISPLAY
      # FIXME: This should be done in code.  Or there must be an easier way ...
      if [ -n "$GDM_PARENT_DISPLAY" ]; then
        XKBSETUP=`( DISPLAY=$GDM_PARENT_DISPLAY XAUTHORITY=$GDM_PARENT_XAUTHORITY $SETXKBMAP -v )`
        if [ -n "$XKBSETUP" ]; then
          XKBKEYMAP=`echo "$XKBSETUP" | grep '^keymap' | awk '{ print $2 }'`
          XKBTYPES=`echo "$XKBSETUP" | grep '^types' | awk '{ print $2 }'`
          XKBCOMPAT=`echo "$XKBSETUP" | grep '^compat' | awk '{ print $2 }'`
          XKBSYMBOLS=`echo "$XKBSETUP" | grep '^symbols' | awk '{ print $2 }'`
          XKBGEOMETRY=`echo "$XKBSETUP" | grep '^geometry' | awk '{ print $2 }'`
          if [ -n "$XKBKEYMAP" ]; then
            $SETXKBMAP -keymap "$XKBKEYMAP"
          elif [ -n "$XKBTYPES" -a -n "$XKBCOMPAT" -a -n "$XKBSYMBOLS" -a -n "$XKBGEOMETRY" ]; then
            $SETXKBMAP -types "$XKBTYPES" -compat "$XKBCOMPAT" -symbols "$XKBSYMBOLS" -geometry "$XKBGEOMETRY"
          elif [ -n "$XKBTYPES" -a -n "$XKBCOMPAT" -a -n "$XKBSYMBOLS" ]; then
            $SETXKBMAP -types "$XKBTYPES" -compat "$XKBCOMPAT" -symbols "$XKBSYMBOLS"
          elif [ -n "$XKBSYMBOLS" ]; then
            $SETXKBMAP -symbols "$XKBSYMBOLS"
          fi
        fi
      fi
    fi
    # launch X11VNC
    sudo /usr/bin/x11vnc -display :0 -bg -usepw -auth /var/lib/gdm/:0.Xauth -o /var/log/x11vnc.log -q  
    exit 0
    Ths is what my /etc/gdm/PreSession/Default file looks like:

    Code:
    #!/bin/sh
    #
    # Note that output goes into the .xsession-errors file for easy debugging
    #
    PATH="/usr/bin:$PATH:/bin:/usr/bin"
    OLD_IFS=$IFS
    
    gdmwhich () {
      COMMAND="$1"
      OUTPUT=
      IFS=:
      for dir in $PATH
      do
        if test -x "$dir/$COMMAND" ; then
          if test "x$OUTPUT" = "x" ; then
            OUTPUT="$dir/$COMMAND"
          fi
        fi
      done
      IFS=$OLD_IFS 
      echo "$OUTPUT"
    }
    
    # Set background color
    XSETROOT=`gdmwhich xsetroot`
    if [ "x$XSETROOT" != "x" ] ; then
    
    	CHECKBACKCOLOR="OK"
    	if [ "x$GDM_GREETER_TYPE" = "xTHEMED" ]; then
    		BACKCOLOR=`gdmflexiserver --command="GET_CONFIG greeter/GraphicalThemedColor $DISPLAY"`
    
    		CHECKBACKCOLOR=`echo $BACKCOLOR | sed 's/^\([^ ]*\) .*$/\1/'`
    		if [ "x$CHECKBACKCOLOR" = "xOK" ]; then
    			BACKCOLOR=`echo $BACKCOLOR | sed 's/^.* \(.*\)$/\1/'`
    		else
    			BACKCOLOR=""
    		fi
    	fi
    
    	# If we tried to load the themed backgroundcolor, but failed, then try loading plain color
    	if [ "x$CHECKBACKCOLOR" != "xOK" ] || [ "x$GDM_GREETER_TYPE" = "xPLAIN" ]; then
    
    		# Background type can be 0=None, 1=Image & Color, 2=Color, or 3=Image 
    		BACKTYPE=`gdmflexiserver --command="GET_CONFIG greeter/BackgroundType $DISPLAY"`
    
    		# Skip if background type does not include a color
    		if [ "x$BACKTYPE" = "xOK 1" ] || [ "x$BACKTYPE" = "xOK 2" ]; then
    			BACKCOLOR=`gdmflexiserver --command="GET_CONFIG greeter/BackgroundColor $DISPLAY"`
    
    			CHECKBACKCOLOR=`echo $BACKCOLOR | sed 's/^\([^ ]*\) .*$/\1/'`
    			if [ "x$CHECKBACKCOLOR" = "xOK" ]; then
    				BACKCOLOR=`echo $BACKCOLOR | sed 's/^.* \(.*\)$/\1/'`
    			else
    				BACKCOLOR=""
    			fi
    		fi
    	fi
    
    	# Default value
     	if [ "x$BACKCOLOR" = "x" ]; then
     		BACKCOLOR="#76848F"
     	fi
    
    	"$XSETROOT" -cursor_name left_ptr -solid "$BACKCOLOR"
    fi
    
    # launch x11
    sudo /usr/bin/x11vnc -display :0 -bg -usepw -auth /var/lib/gdm/:0.Xauth -o /var/log/x11vnc.log -q   
    exit 0
    Any ideas why the command isint launching?

  10. #10
    Join Date
    Oct 2005
    Beans
    142
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    Re: how can i get a command to execute after X but before GDM?

    Don't use the sudo command in the script. If it's ran as root it's not needed and otherwise the user has to enter a password.
    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

Page 1 of 3 123 LastLast

Bookmarks

Posting Permissions

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