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