Modules

Revised: 2009-06-06 james

Modules

Xhooks Module List.

Modules are located in /Library/Xhooks/Modules.  Everything, even "xhooks" is a module.  The only stuff outside of the Modules directory are the hook preferences that allow Xhooks to tie into startup, login, logout, etc, and the other things outside of the Modules directory are preferences (/Library/Preferences/Xhooks), helper scripts in /usr/local/bin, helper Utilities in /Library/Xhooks/Utilities.

Note, if you have installed the xhooks_on_10.5.T overload, which replaces the file /System/Library/LaunchDaemons/com.apple.loginwindow.plist, then you must have /Library/Xhooks/Modules/xhooks/bin/startupearly.hook and that script must work!  If not then the system wont boot.  This is a total hack so that Xhooks can run scripts before the loginwindow appears.  We are aware that another way to do this is to create a Loginwindow Agent but we haven't done that yet.

################################################################

This file was mostly written by Ben Martin and is kinda a description (or guess) as to what each script does.  Most of the scripts were written by James Reynolds and there is documentation about 3 to 5 years old somewhere on the web, but being so old, it probably is of little use.


edu.utah.scl.availability
    Reports to a webapp if a machine is in use or not.  This module is probably of no use to the community because it is too specific to the University of Utah SCL group.

    - availability_lib.pl
        - This script is a library file used by other scripts within this module
        - This script looks like it checks for and reports availibility of a system (whether or not it is has a user logged into it and using it.
        - I think this script is used for the availibility reporting for the lab.

    - LID_availability.pl
        - This is a login script that uses the lib referenced above for this module to report un - availibility

    - LOD_availability.pl
        - This script reports that it is availible.

    - SLD_availability.pl
        - Reports that this computer is availible.

edu.utah.scl.certs

    - PMD_buildKeychains.sh
        - This script automates customizing X509Anchors and X509Certificates.
        - To add certs, create an overload (xhooks_prefs.T or whatever) and put the certs you want added in this directory:
            /Library/Preferences/Xhooks/edu.utah.scl.certs/certificates
        - In 10.5 only use the certificates folder.  In 10.4 there was a difference between anchors and certificates but don't ask me what they were.  This script might not work in 10.4 anymore.

edu.utah.scl.configure

    - PMD_crontab.pl
        - creates /etc/crontab based on a file that contains cron lines for each ip.  The file that it gets this from is /Library/Preferences/Xhooks/edu.utah.scl.cron_config.  This file can be deployed as part of a transcript, or using the Xhooks "commented out command file", and there is an example of one at "xhooks (radmind server)/command/xhooks/cron_setting.conf"
        - This should be moved to command file variables.

    - PMD_etc_hostconfig.pl
        - this script modifies /etc/hostconfig based on the settings in the HOSTCONFIG array
        - In 10.5 Apple barely uses /etc/hostconfig, but some 3rd parties still do.
        - Command file example:

            # HOSTCONFIG += MYSQLCOM=-YES-

    - PMD_set_proxy.pl
        - Sets the network settings on the computer for proxy
        - This is mainly if you ignore your network settings file: /Library/Preferences/SystemConfiguration/preferences.plist
        - On 10.4 it uses ncutil (which is not included with 10.5--on 10.5 it uses networksetup which is part of the OS).
        - Command file example:

            # HTTP_PROXY_SERVER = proxy.example.com
            # HTTP_PROXY_PORT = 8118
            # HTTPS_PROXY_SERVER = proxy.example.com
            # HTTPS_PROXY_PORT = 8118
            # PROXY_HOST_EXCEPTIONS += www.allowed.example.com
            # PROXY_HOST_EXCEPTIONS += www.allowed2.example.com
            # PROXY_PASSIVE_FTP = on

    - PMD_shadow_classic.pl
        - For 10.4 only obvioulsy...  Creates a shadow file dmg for use with classic
        - It has been updated for Xhooks but never been tested

    - PMD_superDefaults.pl
        - Modifies plist files based off the @SUPER_DEFAULTS array
        - For usage instructions run "sudo /usr/local/bin/superDefaults.pl" with no parameters
        - Command file example:

            # SUPER_DEFAULTS += /Users/template/Library/Preferences/com.apple.Safari.plist --add -d ShowFavoritesBar -b 1
            # SUPER_DEFAULTS += /System/Library/LaunchDaemons/com.apple.AppleFileServer.plist --delete Disabled

    - PMD_turn_on_appletalk.pl
        - Turns on AppleTalk
        - This is mainly if you ignore your network settings file: /Library/Preferences/SystemConfiguration/preferences.plist

    - SED_system_login_items_plist.pl
        - This script modifies/creates the file /Library/Preferences/com.apple.SystemLoginItems.plist
        - The Wacom Tablet driver and Timbuktu use this file.  There may be others that I don't know about.
        - Command file example:

            # SYSTEM_LOGIN_ITEMS += /Library/StartupItems/Tablet/TabletDriver.app
            # SYSTEM_LOGIN_ITEMS += /Applications/Timbuktu Pro.app/Contents/SharedSupport/Timbuktu Host.app

    - SEE_2_save_serial_number.pl
        - Saves the serial number to /var/log/serial_number.  This is mainly so a hard disk has a record of what machine it was in last just in case there needs to be an audit or something.

    - SEL_9_set_computer_name.pl
        - Sets the computer name
        - Either use the COMPUTER_NAME variable or the short hostname will be used (mac1.example.com would be "mac1").
        - There is a bug somewhere because we have computers that don't always get their name set.
        - Command file example:

            # COMPUTER_NAME = Neato_computer

    - SLD_launchcache.pl
        - Rebuilds LaunchServices DB.  This script hasn't been updated for 10.5 (lsregister is in a different path and the command syntax is different)

    - SLD_periodic.pl
        - Runs the periodic scripts
        - This only exists because we delete the period scripts (because we don't want them running while radmind runs)

    - SLD_prebinding.pl
        - Updates prebinding
        - This was important on 10.4, we haven't even looked at it for 10.5

edu.utah.scl.debug
    - basic_debug.pl
        - Used to make sure that the basic Xhooks functionality works.

edu.utah.scl.desktop
    - SED_desktop_picture.pl
        - This script sets the desktop image based on the DESKTOP_IMAGE_LOCATION variable.
        - This script picks the resolution of the image based on the DISPLAY_RESOLUTION variable.
        - You will know that it works if the desktop image is set correctly.
        - This requires that you put desktop images in the pref locations:
            /Library/Preferences/Xhooks/edu.utah.scl.desktop/dated
            /Library/Preferences/Xhooks/edu.utah.scl.desktop/default
        - Dated folders can be named something like "03.01-05.31" for a time range or a specific date "4.01" (if you have special desktop images for special days LOL.
        - Name the file after the resolution, like "1024_768.jpg".

edu.utah.scl.display
    - display_conf.pl
        - This contains the default values for the screen resolution on different machines.  This list will need to be updated as Apple releases new hardware.  It is probably out of date already as we speak.

    - LID_resolution.pl
        - Sets the resolution @ login time

    - load_launchagent.pl
        - This is requied on 10.5 to set the resolution at startup.

    - LOD_resolution.pl
        - Sets the resolution @ logout time

    - SED_resolution.pl
        - Sets the resolution at startupon 10.4

    - set_display.pl
        - Sets the resolution at startupon 10.5

edu.utah.scl.firewall
    - SLD_firewall.sh
        - Runs ipfw with the rules listed in the FIREWALL_RULES array.
        - Command file example:

            # FIREWALL_RULES += add allow ip from 12.34.56.78/24 to any
            # FIREWALL_RULES += add reset tcp from any to any 3283 in

edu.utah.scl.hard_disk
    - PMD_ignore_hd_perms.pl
        - Activates/deactivates permissions on extra hard disks
        - This may need to be debugged if disktool -l changes with an os update
        - Command file example:

            # DEACTIVATE_VOLUME_PERMISSIONS += Data
            # ACTIVATE_VOLUME_PERMISSIONS += 10.6 Beta

    - SED_hard_disk_name.pl
        - Sets the hard disk name
        - Command file example:

            #  HARD_DISK_NAME = Mac OS X

edu.utah.scl.home_folder
    - assimilateUser.pl
        - Moves home user into place, fixes perms.  Maybe some other things ...

    - create_cached_home_folders.pl
        - Creates the cached home folders that are moved into place by assimilateUser.pl above

    - create_lost_and_found.pl
        - Creates a lost and found for users items after they log out ... could be improved

    - homes_create.pl

    - lib/home_folder_lib.pl

    - lib/lostAndFoundReadme

    - LID_byhost.pl
        - Fixes the ByHost folder at login (this has never really been tested by us, it is just there because we know this is needed if using network homes).

    - LIL_1_assimilate.pl
        - Calls the assimilateUser.pl script if certain criteria is met
            - It will run if the user logging in has a home folder that matches the LOGIN_HOME_DIR variable (the only way this would happen is if you map directory services to the variable)
            - Otherwise it will run if the variable CREATE_UNMANAGED_HOME_FOLDER_IF_MISSING is set to "True" AND the home folder is missing the file ~/.username (which is created by assimilateUser.pl).
                - The old home folder will have "_backup" added to it.  Mac OS X ***always*** creates a home folder so this is the only way for the script to know that the home hasn't been created before.
                - This is so that users can get a managed home folder but not have it managed from then on. This way they get prefs and other files that are managed.  There is no way to update this managed home folder yet and is a problem we need to fix.
        - Command file example:

            # LOGIN_HOME_DIR = /Users/Authenticated User
            # CREATE_UNMANAGED_HOME_FOLDER_IF_MISSING = True

    - PMD_home_folder.pl
        - makes an empty home directory so that os x doesn't try and do one at login (if the home directory is missing)0
        
    - LIL_1b_users_shared_symlink.pl
        - Creates a symbolic link from ~/Shared to /Users/Shared
        - This is probably only interesting to the University of Utah SCL group because we do crazy stuff like this.

    - LOL_1_lost_and_found.pl
        - Calls /Library/Xhooks/Modules/edu.utah.scl.home_folder/create_lost_and_found.pl

    - PMD_fix_byhost_prefs.pl
        - Fixes the ByHost preferences in several areas:
            - /Users/ADMIN_USER_NAME/Library/Preferences/ByHost
            - /var/root/Library/Preferences/ByHost
            - TEMPLATE_HOME_DIR/Library/Preferences/ByHost
        - Command file example:

            # ADMIN_USER_NAME = mac
            # TEMPLATE_HOME_DIR = /Users/template

    - PMD_manage_loginitems_prefs.pl
        - Writes the login items plist (the Login Startup Items that are configured from the System Preferences Account pane)
        - Should be updated to use perlPlist.pl
        - Command file example:

            # TEMPLATE_USER_LOGINWINDOW_PLIST += /Library/Xhooks/Utilities/Helpers/LogoutMenu.app 0
            # TEMPLATE_USER_LOGINWINDOW_PLIST += /Library/Xhooks/Utilities/Helpers/Launch Presentation 0
            # TEMPLATE_USER_LOGINWINDOW_PLIST += /Applications/SMART Board Software/SMARTBoardService.app 0
            # TEMPLATE_USER_LOGINWINDOW_PLIST += /Applications/Staff Utilities/Quicksilver/Quicksilver.app 0
            # TEMPLATE_USER_LOGINWINDOW_PLIST += /Library/Xhooks/Utilities/Helpers/Launch QuickTime Broadcaster.app 0


    - PMD_manage_system_menubar_prefs.pl
        - Manages the system menubar plist
        - Should be updated to use perlPlist.pl
        - Command file example:

            # SYSTEM_MENUBAR_ITEMS += /System/Library/CoreServices/Menu Extras/Volume.menu
            # SYSTEM_MENUBAR_ITEMS += /System/Library/CoreServices/Menu Extras/Clock.menu
            # SYSTEM_MENUBAR_ITEMS += /System/Library/CoreServices/Menu Extras/AirPort.menu
            # SYSTEM_MENUBAR_ITEMS += /System/Library/CoreServices/Menu Extras/Battery.menu
            # SYSTEM_MENUBAR_ITEMS += /System/Library/CoreServices/Menu Extras/RemoteDesktop.menu


    - PME_1_merge_stupid_template_folders.pl
        - Only of interest to the University of Utah SCL group to fix that fact we decided to move our template home folder after we created 100's of overloads with an old location and we didn't want to fix them all before moving to the new template location.

    - PML_1_home_folder.pl
        - Changes permissions for the home folders so that if the admins get lazy creating their overloads and don't get the permissions right, then this step hopefully catches it.
        - Creates a transcript folder of the home foler that is used to create the lost and found
        - Creates cached home folders

    - SEE_3_cleanOutVolumes.pl
        - This is one I wrote :)
        - Basically it cleans out the /Volumes directory in case anyone puts anything in here.  But it does not clean or remove anything if it is actually a volume
    - set_homepage.pl
        - This sets the home page for Safari and FireFox programatically based off of a setting that is stored in the command file

edu.utah.scl.kiosk

    - edu.utah.scl.kiosk_browser_window.plist

    - edu.utah.scl.kiosk_cleanup.plist

    - edu.utah.scl.presentation_launcher.plist

    - kiosk_browser_window.pl

    - kiosk_cleanup.pl

    - LID_kiosk_hack_dock.pl
        - Removes and restores the dock for kiosks by renaming it.  Currently the setting that activates this is if INTERNET_KIOSK is "True".  We could probably make it work better.

    - LOD_kiosk_hack_dock.pl
        - Unhacks the dock.

    - logoutnow.scpt

    - newPresentation.pl
        - This app watches a watchfolder ("/Volumes/Shared/new") for powerpoint presentation movies (?) that are saved to play when opened and when they are there it gets the new presentation and plays it (moves it to "/Volumes/Shared/current") and tosses the old one (moves it to "/Volumes/Shared/old" with a date/time stamp).

edu.utah.scl.local_mcx
    - local_machine.plist
        - This is the plist file that is put on a box.  Basically the purpose of it is to standarize the "generateduid" value, which we set to:
            001fCA70-5EE5-B12D-CA70-EA75B12DC1A0
            - Put the above generateduid in the groupmembers array in any local mcx settings you deploy.  For example, you can create *any* local mcx file and then just make sure you add the following and it will magically work when you put it on a box.  Obviously we need to explain this better and we will on June 17th, 2009 at the University of Utah Mac Managers meeting.  The video should be posted to http://data.scl.utah.edu or something.  Maybe we will just update this doc.  (I, James Reynolds, would explain it but Ben Martin did the work and I don't know all the details)

                <key>groupmembers</key>
                <array>
                    <string>001fCA70-5EE5-B12D-CA70-EA75B12DC1A0</string>
                </array>

            - See "xhooks (radmind server)/command/xhooks/local_mcx" for examples.

    - PMD_update_local_machine_en_address.pl
        - This updates the above file with the ethernet address of the actual box and saves the above file to the correct location to get local mcx working.

edu.utah.scl.login
    - LIE_2_allowed.pl
        - Checks to make sure login name is allowed and if not kills loginwindow (stopping login)
    - login_denied.sh
        - executed by LIE_2_allowed.pl when we want to stop a login.
    - play_login_sounds.pl
        - Plays login sounds from the items in the dated folder (this is for fun, like playing sound effects for Halloween...)

edu.utah.scl.loginpanel
    - SED_loginwindow_plist.pl
        - Creates/updates /Library/Preferences/com.apple.lloginwindow.plist
        - Required
    - SEL_1_loginpanel_graphic.pl
        - This script changes the loginwindow to show the status of maintenance and a customized graphic (displaying the os version or a dated graphic for holidays etc.)
    - SEL_1_loginpanel_unid.pl
        - Replaces "Username" with "uNID" for the loginwindow

edu.utah.scl.logout
    - LOD_eject.sh
        - This script attempts to eject all disks not listed in $ejectexclude on run
        - We've never actually used this yet.  It comes from umich I think.

    - LOD_flush_lookupd.sh
        - Runs this command "/usr/sbin/lookupd -flushcache"
        - Needs to be updated for 10.5 with dscacheutil
        - Can't get more basic than this script........

    - LOD_killsumapps.pl
        - This script calls the script defined by $killsumapps_script

    - LOD_unload_launchagents.pl
    - LOE_2_clean_volumes.sh
        - Deletes "/Volumes/._*", which once upon a time (probably Dec 2007, some version of 10.4) caused problems.

edu.utah.scl.logoutsaver
    - logoutsaver.pl
        - This was written before all the Xhooks variable stuff, so this actually has it's own plist file at /Library/Preferences/Xhooks/edu.utah.scl.logoutsaver.  It reads that plist to find the "idleTime", "playMusic",
        - Put slides in "/Library/Preferences/Xhooks/edu.utah.scl.logoutsaver.slides".


edu.utah.scl.nightly
    - LOL_2_nightly.pl
    - nightly.pl
    - PMD_create_nightly_launchd.pl
        - This creates the launchd plist file that actually runs radmind (at night, or whenever you want really).
        - See "xhooks (radmind server)/command/xhooks/radmind_reboot.conf" for full syntax examples and explaination.
        - Simplified command file example:

            # (10.0.0.1)    NIGHTLY_RADMIND_REBOOT = 0    2    M    0  6 TWHFSU
            # (10.0.0.2)    NIGHTLY_RADMIND_REBOOT = 15    2    M    15 6 TWHFSU
            # (10.0.0.3-4)    NIGHTLY_RADMIND_REBOOT = 15    2    M    0  6 TWHFSU
            # (10.0.0.5-6)    NIGHTLY_RADMIND_REBOOT = 15    2    M    15 6 TWHFSU

edu.utah.scl.printers
    - reset_printing_system.pl
        - Sets up printers based on the variable PRINTERS and a printerDefinitions.txt file.
        - /Library/Preferences/Xhooks/edu.utah.scl.printers/10.5/printerDefinitions.txt is a list of lpadmin commands to run.
        - See "xhooks (radmind server)/command/xhooks/printerDefinitions_10.5.conf" for example.
        - the flags are lpadmin flags, so type `man lpadmin` to figure it out.
        - The printerDefinitions.txt file needs to be totally redone so it is easier to read and write.
        - The ppd files must be included in some overload as well.  Note, ppd files are modified for each printer based on what the printer has (RAM, trays, etc), and stock unmodified ppd files are regularly updated by the OS.  The OS does not update your ppd files so you may want to recreate them periodically.
        - Command file example:

            # PRINTERS += HP_Color
            # PRINTERS += HP_BW

edu.utah.scl.radmind

edu.utah.scl.replicate

edu.utah.scl.report

edu.utah.scl.secure

edu.utah.scl.status

edu.utah.scl.tech

edu.utah.scl.volume

edu.utah.scl.watchfolder
    - killsumapps.pl
        - This has got a bunch of Panther and Jaguar stuff in it ... so i am supposing it is no longer used and quite old
        - but it appears that it kills apps that are not on the list (probably for use on kiosk machines)
        - kills apps at logout, used to prevent nohup executables...
    - watchFolder.pl
        - watchFolder.pl is executed by launchd if the launchdaemon is in place.  The launchdaemon watches /private I think.
        - It launches a tmp_script.pl if it exists (it would exist if it was copied there by ARD--this was a workaround to ARD 1, which didn't have send unix command).  This functionality can probably be removed, but it might be useful for perl scripts since send unix command is shell.
        - Will run maintenance and a few other things.

edu.utah.scl.webcam

edu.utah.scl.xgrid

xhooks
    - bin/networktest.pl
        - this looks like a script that checks to see if network is up or down.  It does it in a really bizarre way to me using ifconfig???  But other than that it is pretty straight forward
        - it seems like the functionality of this script is pretty important ... but it could probably be rewritten in a more elegant fashion
        - It is used by many scripts that run at startup that require network