The key benefit of HackyInstaller's CLI is that it facilitates the development of scripts for installation and updating of sensors. For example, suppose you wanted to automatically check for updates and download new versions of your sensors once a week. You could write a simple batch script containing "java -jar hackyInstaller.jar -UpdateAllSensors", and set it to execute once a week on your computer (using cron jobs on unix or "scheduled tasks" on Windows).
As a more complicated example, assume that you are a system administrator who needs to set up sensors on a large number of accounts. You have a file containing the user accounts and the associated hackystat user keys, and have written a script to login to each of the accounts in turn. What remains to be done is to invoke a script to set up an Emacs, Vim, and CLI sensor in each of the accounts, or update them to the most recent version on the server if they already exist. Example 2.13, “Simple script to install and update Hackystat sensors automatically” illustrates a Unix script to accomplish this task.
Example 2.13. Simple script to install and update Hackystat sensors automatically
#!/bin/csh # AutoInstallHackySensors.sh # Author : Mike Paulding # Collaborative Software Development Laboratory # University of Hawaii # AutoInstallHackySensors.sh is a sample unix script to install and/or update Vim, Emacs, and CLI sensors. # The script takes exactly one argument, which is the Hackystat key of the user. It must be provided # or the script will terminate with an error. # The script defines important two variables # - installerPath: the path to the hackyInstaller.jar file # - hackystatHost: the hackystat server containing the user accounts and the sensors to be downloaded. # If the Hackystat key is not provided, terminate the script. Unrecoverable. if ($#argv != 1) then echo "AutoInstallHackySensors requires exactly one argument, which is the Hackystat key of the user." exit 1 endif # The Hackystat key is supplied to the script as an argument. set hackystatKey = $1 # Define the path to the hackyInstaller.jar file. set installerPath = /usr/local/install/hackystat # Define the URL for the Hackystat host. set hackystatHost = "http://care.cs.umd.edu:8080" # Step 1 - Set up the .hackystat directory and verify host and key. java -jar $installerPath/hackyInstaller.jar -SetHostAndKey $hackystatHost $hackystatKey # Step 2 - Set paths. In this case, only the Emacs sensor requires a path specification. echo "Informing HackyInstaller of location of .emacs file." java -jar $installerPath/hackyInstaller.jar -SetPath .EMACS_FILE_DIR $HOME # Step 3 - Set properties. Only the Vim data file needs to be set for this script. java -jar $installerPath/hackyInstaller.jar -SetProperty HACKYSTAT_VIM_SENSOR_DATA_FILE $HOME/.hackystat/vim/HS_VIM_DATA.dat # Step 4 - Install/Update sensors. We do this for Vim, Emacs, and CLI java -jar $installerPath/hackyInstaller.jar -InstallOrUpdateSensor Emacs java -jar $installerPath/hackyInstaller.jar -InstallOrUpdateSensor Vim java -jar $installerPath/hackyInstaller.jar -InstallOrUpdateSensor Cli
A better version of this script might perform error checking by testing that the last line of output from each HackyInstaller invocation is "Success", and send email to the administrator if other results were found. Note that HackyInstaller logs its progress in a file in the users' $HOME/.hackystat/logs directory, so if problems are discovered, the administrator can access this file to learn what went wrong.