[FreeNX-kNX] Feature #4717 - Script execution on server event

Alexander Todorov alexx.todorov at gmail.com
Tue Oct 27 10:51:54 UTC 2009


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.




More information about the FreeNX-kNX mailing list