Chapter 5: Scripting
58 Complete example of a Lua script
tt6194:/$ lua c /sdcard/test1.lua 1234
1:3560946965
tt6194:/$
where 1:3560946965 is the checksum. Note that any changes in the
script file - including subtle changes like extra spaces and different line
endings - will change the checksum. Also a different code word will give
a different checksum.
If the script file does not begin with an empty comment line, the TCU
will refuse to calculate a checksum.
3. This checksum is inserted on the empty comment line in the script:
--1:3560946965
-- This is our first test script
print("Hello world")
4. The final step is to instruct the TCU only to execute scripts with a
matching checksum. This is done by configuring the code word into the
TCU:
luaconf c <current code word> <new code word>
The default code word is empty so in this example (where we chose the
code word 1234) this command will set up the script lock:
tt6194:/$ luaconf c "" 1234
tt6194:/$
Note that the "" in the command indicates an empty string
corresponding to an empty code word.
Now the Terminal Control Unit will only accept scripts that have a
checksum that matches the stored code word. If the checksum does not
match, the execution will abort with a warning: Cannot validate script.
To unlock the Terminal Control Unit running a script
If the TCU has to be unlocked at some point, use the luaconf command
to set the code word back to an empty string. Without a code word
configured, the TCU will execute any script with or without a checksum.
Note that this re-configuration can only be done if the current code word is
known:
tt6194:/$ luaconf c 1234 ""
tt6194:/$