Autoload Scripts
While we try to take care of most installations and configurations out of the box, we understand that there are instances where users prefer to personalize their setup with additional installation and configurations. Therefore, in addition to the predefined entrypoint scripts, we offer the ability to add users defined entrypoint scripts to tailor the workspace experience.
TIP
Before creating additional entrypoint scripts, check whether the objective you intend to achieve is already covered by a built-in configuration template or an installable feature. Many common customizations are handled automatically through these mechanisms.
Startup scripts are defined at two levels:
- Entrypoint: loaded once during the initial startup process, read more.
- Session: loaded for every new shell session, read more.
Entrypoint
On startup, the predefined entrypoint scripts stored in /usr/libexec/workspace/startup.d/* are executed in lexicographical order to initialize the workspace environment.
To add additional functionality during startup, place executable scripts in ~/.ws/startup.d/ (i.e. /home/kloud/.ws/startup.d). The directories are created automatically on startup.
These scripts are executed as follows:
- Only scripts with an executable file permission (i.e.
+x) are considered. - Executed in lexicographical order.
- Scripts are executed as the
klouduser.
Available Languages
Feel free to write your entrypoint scripts in the language of your choice, considering it is installed in the workspace.
By default, the workspace supports the following languages (defined using shebangs):
- Ansible:
#!/usr/bin/env -S ansible-playbook - Bash:
#!/usr/bin/env bash - Go:
//usr/bin/env go run $0 $@; exit $? - Node.js:
#!/usr/bin/env node - POSIX:
#!/bin/sh - Python:
#!/usr/bin/env python - zsh:
#!/usr/bin/env zsh
Helper Functions
You are welcome to utilize the log command of ws-cli to generate messages that align with the format of our logging system. Refer to the specific documentation for ws-cli for more details.
Session
Similar to entrypoint scripts, the workspace will load startup scripts for every new shell session. On shell startup, the predefined scripts stored in /usr/lib/ohmyzsh/custom/* are executed in lexicographical order.
To add additional functionality during startup, place .zsh files in ~/.ws/session.d/ (i.e. /home/kloud/.ws/session.d). The directories are created automatically on startup.
These scripts are executed as follows:
- Both executable and not executable scripts are considered.
- Only
.zshare considered. - Executed in lexicographical order.
- Scripts are executed as the
klouduser. - Scripts are executed using
source, therefore any functions,aliass orexports will be available during the current session.