Cameyo allows you to execute shell scripts on your servers at different moments of a session's lifecycle.


See Session scripting (Windows) for Windows equivalent


Events and timing

The name portion of the script file determines its execution mode:

StartupBefore/StartupAfter[Sync].sh

  • StartupBefore: script will execute before the session's module (executable). For example, if the session is intended to launch /bin/mousepad, the script will launch before Mouspad executes.
  • StartupAfter: script will execute after the session's module (executable), but right before opening the session (before hiding the "Connecting" HTML screen and showing the app session to user). For example, if the session is intended to launch /bin/mousepad, the script will launch after Mouspad executes.
  • *Sync: an optional suffix which blocks the workflow until the script finishes execution.
    Example: StartupBeforeSync.sh -> session will wait for script to finish before starting the session's application.


Examples:

  • /opt/cameyo/var/scripts/StartupBefore.sh: executes before program starts.
  • /opt/cameyo/var/scripts/StartupBeforeSync.sh: executes before program starts, holds session start until script ends.
  • /opt/cameyo/var/scripts/StartupAfter.sh: executes after program has started, right before it is shown to user.
  • /opt/cameyo/users/RemoteUser1/Cameyo/StartupAfterSync.sh: executes after program has started, right before it is shown to user. Holds session start until script ends.


Be aware that on Linux files and folders are CASE SENSITIVE!
The exact writing is important



PowerTag inline scripting

In addition to the above, you can define scripts using Cameyo's PowerTags, using this syntax:

!STARTUP_[phase][_sync]_type=...inline script...

In your inline script commands, use ^| to specify new line.


Examples:

!STARTUP_BEFORE_SYNC_SH=ps axf > ~/test1.txt^|date >> ~/test2.txt

!STARTUP_BEFORE_SH=/bin/mousepad ~/mylog.log

!STARTUP_BEFORE_SYNC_SH=cp /usr/share/userdata.dat ~/userdata.dat

!STARTUP_AFTER_SH=cat ~/.myapp/settings.json > ~/mysettings.txt


File-based scripting

This can be done by creating a scripts directory under /opt/cameyo/var/ (run as sudo!) or the user's profile, and naming the script accordingly.

Example

  • Create file /opt/cameyo/var/scripts/StartupBefore.sh, with one line: /bin/mousepad.
  • Result: this script will be executed every time a session starts and run a text editor with the application.

Step-by-step

  1. Connect to your Cameyo server as admin.
  2. Open a terminal app
  3. Create the folder with the following command:
    sudo mkdir /opt/cameyo/var/scripts
  4. Within this directory, create a shell file called StartupBefore.sh.
    cd /opt/cameyo/var/scripts
    sudo nano /opt/cameyo/var/scripts/StartupBefore.sh 
  5. Save and close the file (Ctrl+S, Ctrl+X)
  6. This script will then execute for any Cameyo session starting on this server.