Feature #4717 - Script execution on server event

View: New views
5 Messages — Rating Filter:   Alert me  

Feature #4717 - Script execution on server event

by Alexander Todorov :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,
I've found this issue which is not yet supported by FreeNX. My setup is
dependent on UserScriptAfterSessionClose and I'd like to contribute a patch to
make script execution possible (at least in some events).

Is there any documentation about the inner workings of freenx? Can you tell me
which bash script is executed first, which second, etc. so I can figure out
where to stuff my code? Any pointers are welcome.

Thanks,
Alexander.
________________________________________________________________
     Were you helped on this list with your FreeNX problem?
    Then please write up the solution in the FreeNX Wiki/FAQ:

http://openfacts2.berlios.de/wikien/index.php/BerliosProject:FreeNX_-_FAQ
 
         Don't forget to check the NX Knowledge Base:
                 http://www.nomachine.com/kb/ 

________________________________________________________________
       FreeNX-kNX mailing list --- FreeNX-kNX@...
      https://mail.kde.org/mailman/listinfo/freenx-knx
________________________________________________________________

Re: Feature #4717 - Script execution on server event

by Alexander Todorov :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm replying to myself :)

>
> Is there any documentation about the inner workings of freenx? Can you tell me
> which bash script is executed first, which second, etc. so I can figure out
> where to stuff my code? Any pointers are welcome.
>

I've changed the node.conf and nxnode::node_terminate_session() to execute a
script after the session is terminated. This works pretty well for me and is
only executed on terminate, not on suspend or when the nxclient is killed (or
power failure) for instance. See svn diff output below. Comments are welcome.


Index: node.conf.sample
===================================================================
--- node.conf.sample    (revision 631)
+++ node.conf.sample    (working copy)
@@ -648,3 +648,6 @@
 #
 # If nxviewer cannot be found this is set automatically to "1".
 #ENABLE_EXTERNAL_NXVIEWER="0"
+
+# Execute a script after session is terminated
+#USER_SCRIPT_AFTER_SESSION_CLOSE=""
Index: nxnode
===================================================================
--- nxnode      (revision 631)
+++ nxnode      (working copy)
@@ -156,6 +156,9 @@

        [ "$SESSION_LOG_CLEAN" = "0" -a "$2" = "failed" ] && mv
"$USER_FAKE_HOME/.nx/C-$1/" "$USER_FAKE_HOME/.nx/F-C-$1"
        [ "$SESSION_LOG_CLEAN" = "0" -a "$2" != "failed" ] && mv
"$USER_FAKE_HOME/.nx/C-$1/" "$USER_FAKE_HOME/.nx/T-C-$1"
+
+       # execute script after session is terminated
+       [ ! -z "$USER_SCRIPT_AFTER_SESSION_CLOSE" ] &&
"$USER_SCRIPT_AFTER_SESSION_CLOSE"
 }

 #



For USER_SCRIPT_AFTER_SESSION_START I'm not quite sure though.
nxnode::startsession()  looks like the proper place for me but the script was
executed after session start and after resume. The NoMachine NX server has
different variables for those two actions. I'd have to figure out on which line
to put my changes, currently they are just before the last wait in the
startsession() function and don't work quite well.

--
Alexander.

________________________________________________________________
     Were you helped on this list with your FreeNX problem?
    Then please write up the solution in the FreeNX Wiki/FAQ:

http://openfacts2.berlios.de/wikien/index.php/BerliosProject:FreeNX_-_FAQ
 
         Don't forget to check the NX Knowledge Base:
                 http://www.nomachine.com/kb/ 

________________________________________________________________
       FreeNX-kNX mailing list --- FreeNX-kNX@...
      https://mail.kde.org/mailman/listinfo/freenx-knx
________________________________________________________________

Re: Feature #4717 - Script execution on server event

by vsp_123 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This is very helpful.

Thanks,
Prakash

On Oct 27, 2009, at 5:36 AM, Alexander Todorov wrote:

> Hi all,
> I've found this issue which is not yet supported by FreeNX. My setup  
> is
> dependent on UserScriptAfterSessionClose and I'd like to contribute  
> a patch to
> make script execution possible (at least in some events).
>
> Is there any documentation about the inner workings of freenx? Can  
> you tell me
> which bash script is executed first, which second, etc. so I can  
> figure out
> where to stuff my code? Any pointers are welcome.
>
> Thanks,
> Alexander.
________________________________________________________________
     Were you helped on this list with your FreeNX problem?
    Then please write up the solution in the FreeNX Wiki/FAQ:

http://openfacts2.berlios.de/wikien/index.php/BerliosProject:FreeNX_-_FAQ
 
         Don't forget to check the NX Knowledge Base:
                 http://www.nomachine.com/kb/ 

________________________________________________________________
       FreeNX-kNX mailing list --- FreeNX-kNX@...
      https://mail.kde.org/mailman/listinfo/freenx-knx
________________________________________________________________

Re: Feature #4717 - Script execution on server event

by ChrisB-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



Alexander Todorov <alexx.todorov@...> wrote on 27/10/2009 10:51:54:

> I'm replying to myself :)
>
> >
> > Is there any documentation about the inner workings of freenx? Can
> you tell me
> > which bash script is executed first, which second, etc. so I can figure out
> > where to stuff my code? Any pointers are welcome.
> >
>
> I've changed the node.conf and nxnode::node_terminate_session() to execute a
> script after the session is terminated. This works pretty well for me and is
> only executed on terminate, not on suspend or when the nxclient is killed (or
> power failure) for instance. See svn diff output below. Comments are welcome.
>
>
> Index: node.conf.sample
> ===================================================================
> --- node.conf.sample    (revision 631)
> +++ node.conf.sample    (working copy)
> @@ -648,3 +648,6 @@
>  #
>  # If nxviewer cannot be found this is set automatically to "1".
>  #ENABLE_EXTERNAL_NXVIEWER="0"
> +
> +# Execute a script after session is terminated
> +#USER_SCRIPT_AFTER_SESSION_CLOSE=""
> Index: nxnode
> ===================================================================
> --- nxnode      (revision 631)
> +++ nxnode      (working copy)
> @@ -156,6 +156,9 @@
>
>         [ "$SESSION_LOG_CLEAN" = "0" -a "$2" = "failed" ] && mv
> "$USER_FAKE_HOME/.nx/C-$1/" "$USER_FAKE_HOME/.nx/F-C-$1"
>         [ "$SESSION_LOG_CLEAN" = "0" -a "$2" != "failed" ] && mv
> "$USER_FAKE_HOME/.nx/C-$1/" "$USER_FAKE_HOME/.nx/T-C-$1"
> +
> +       # execute script after session is terminated
> +       [ ! -z "$USER_SCRIPT_AFTER_SESSION_CLOSE" ] &&
> "$USER_SCRIPT_AFTER_SESSION_CLOSE"
>  }
>
>  #
>
>
>
> For USER_SCRIPT_AFTER_SESSION_START I'm not quite sure though.
> nxnode::startsession()  looks like the proper place for me but the script was
> executed after session start and after resume. The NoMachine NX server has
> different variables for those two actions. I'd have to figure out onwhich line
> to put my changes, currently they are just before the last wait in the
> startsession() function and don't work quite well.



Do you want this before or after starting the X window system ??

Look for "node_start_applications".

startsession()  does the resume too, ( as startsession "restore" ), but then it knows it's doing a resume . . .


>
> --
> Alexander.
>
> ________________________________________________________________
>      Were you helped on this list with your FreeNX problem?
>     Then please write up the solution in the FreeNX Wiki/FAQ:
>
>
http://openfacts2.berlios.de/wikien/index.php/BerliosProject:FreeNX_-_FAQ
>  
>          Don't forget to check the NX Knowledge Base:
>                  
http://www.nomachine.com/kb/
>
> ________________________________________________________________
>        FreeNX-kNX mailing list --- FreeNX-kNX@...
>      
https://mail.kde.org/mailman/listinfo/freenx-knx
> ________________________________________________________________

________________________________________________________________
     Were you helped on this list with your FreeNX problem?
    Then please write up the solution in the FreeNX Wiki/FAQ:

http://openfacts2.berlios.de/wikien/index.php/BerliosProject:FreeNX_-_FAQ
 
         Don't forget to check the NX Knowledge Base:
                 http://www.nomachine.com/kb/ 

________________________________________________________________
       FreeNX-kNX mailing list --- FreeNX-kNX@...
      https://mail.kde.org/mailman/listinfo/freenx-knx
________________________________________________________________

Re: Feature #4717 - Script execution on server event

by Alexander Todorov :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

chris@... wrote:
>
> Do you want this before or after starting the X window system ??
>

I have no idea. I personally need only USER_SCRIPT_AFTER_SESSION_CLOSE but the
feature request lists after session start as well. NoMachine NX server has
several more events, I'm not sure if we want those implemented. I've tried a
quick hack but it didn't work quite well.

What do folks think. Is it worth to implement all user script events which are
in the NoMachine node.cfg or just leave the after session start/close ones?

Thanks,
Alexander.
________________________________________________________________
     Were you helped on this list with your FreeNX problem?
    Then please write up the solution in the FreeNX Wiki/FAQ:

http://openfacts2.berlios.de/wikien/index.php/BerliosProject:FreeNX_-_FAQ
 
         Don't forget to check the NX Knowledge Base:
                 http://www.nomachine.com/kb/ 

________________________________________________________________
       FreeNX-kNX mailing list --- FreeNX-kNX@...
      https://mail.kde.org/mailman/listinfo/freenx-knx
________________________________________________________________