-
Notifications
You must be signed in to change notification settings - Fork 4
ULS Script writer's beginning guide
Writing ULS scripts is as same as writing Shell scripts. When you need to use ULS's built-in variables, use the keywords instead.
For example, if a ULS can only run as ROOT, you can use this:
if [[ sys.root == "false" ]]; then
print("This script can only be run as ROOT")
exit
fi
When using ULS's keywords,You don't need to add DOUBLE QUOTES,ULS will add them automatically. For example, sys.root
will be converted into:
"true"
or "false"
when the script is executed.
Like Shell scripts, ULS scripts hava 2 ways to be executed:
uls [ULS Script's Path]
./[ULS Script's Name]
Execution permission & interpreter declaration not needed when using the first way.
If you want to use the second way:
- Add interpreter declaration in the top of the script:
#!/usr/bin/uls
- Add execution permission to the script:
chmod +x [ULS Script's Name]
Stay simple is important. If you provide a One-Key command to users, they will be happy.
wget [ULS Script's URL] && uls [ULS Script's Filename]
For example:
wget https://raw.githubusercontent.com/CYRO4S/ULS-Scripts/master/sysinfo.uls && uls sysinfo.uls
ULS may not installed on users' machine. You can create a Shell script to get installing, downloading & executing all together.
Let's create a shell script:
#!/bin/bash
wget https://raw.githubusercontent.com/CYRO4S/Universal-Linux-Script/master/uls_install.sh && bash uls_install.sh
wget [ULS Script's URL] && uls [ULS Script's Filename]
Then provide this command to users:
wget [Shell script's URL] && bash [Shell script's Filename]