Trying to package some scripts into an application

Hola Amigos-

Well, to give you a quick background I work for a school district and I am one of the network admins for our 1:1 program. I have 6,000 Macbooks in my deployment, all in the high schools. To make a long story short, Administrators are looking at ways to track down and build up evidence against students that are doing things that violate our AUP. Things like trying to hack the web filter, and stuff like that. A lot of times though the kids will delete any and all evidence on their macbook, or if they suspect being watched on ARD Admin they shut their lid. So, they found this application which is like $30 or something per a license and it takes timed screen shots. Well, I can already take screen shots from the command line and launchd can already regulate how often my script runs. The school administrators want a way to build evidence against kids who are abusing their Macbooks and causing problems. My department is way under staffed so we can’t sit there and play net nanny all day every day, and with all the state edu budget cuts we aren’t going to hire someone to do it either.

Here is my conundrum, because I am not a software developer I am not sure how to put this all together in a nice and neat bundled package. Plus I want the installer of this app to be able to set some custom parameters in my script and then have it spit out a new PKG file with those parameters now hard coded in.

here is my shell script:

[code]#!/bin/bash

#set variables for file name and save path

thedate=/bin/date -u
name=/bin/ls ‘l /dev/console | cut ‘d " " ‘f 4
path=“/private/var/hadmin/Desktop/screenshots”

#execute screen shot

/usr/sbin/screencapture -x $path/“$thedate $name sreen.png”

echo “screen captured”

exit 0[/code]
Now, in this script I have the path to save the file hard coded as the local admin’s desktop on our student machines. However, not every machine is the same, some of them have different images and/or accounts so I want the installer of this app to be able to set the directory path. I also want them to set the frequency launchd runs this, every 5 minutes, 15 minutes, and so fort as each case will be different. I asked on a different forum and was directed here for help. You can check out the original thread on OSXhints.com here: http://forums.macosxhints.com/showthread.php?t=104482. I had some one help me with creating apple scripts that do this and saving them as applications.

-- get the input information for the script
set theName to text returned of (display dialog "Enter a base name for the images" default answer "ScreenImage" buttons {"Cancel", "Continue"} default button 2 with icon note)
set imageFolderPath to choose folder with prompt "Please choose the folder where you want the images saved."
set posix_imageFolderPath to POSIX path of imageFolderPath

-- write the script
set scriptLocationPath to (path to desktop folder as text) & "screenCapture.sh"
set scriptText to "#!/bin/bash

thedate=`/bin/date -u`
name=\"" & theName & "\"
path=\"" & posix_imageFolderPath & "\"

#execute screen shot
/usr/sbin/screencapture -x $path/\"$thedate $name.png\"

echo \"screen captured\"
exit 0"
writeTo(scriptText, scriptLocationPath, false, string)

-- make the script executable
do shell script "chmod a+x " & quoted form of POSIX path of scriptLocationPath


(*================== SUBROUTINES ==================*)
on writeTo(this_data, target_file, append_data, mode) -- append_data is true or false, mode is string etc. (no quotes around either)
    try
        set target_file to target_file as Unicode text
        if target_file does not contain ":" then set target_file to POSIX file target_file as Unicode text
        set the open_target_file to open for access file target_file with write permission
        if append_data is false then set eof of the open_target_file to 0
        write this_data to the open_target_file starting at eof as mode
        close access the open_target_file
        return true
    on error
        try
            close access file open_target_file
        end try
        return false
    end try
end writeTo

This works and it allows me to enter text. However, I want it to modify the contents of my installer so it can be customized. As of right now I can just push this out as a Composer snap shot via Casper Suite and it works, but I would like to actually package this up in an actual installer package that someone can install over ARD Admin for example. I would also like to have an uninstaller too. I was looking at different ways of coding this to make it happen, but like I said I am not a software developer so I am kind of new to wrapping all these things up into a nice neat package.

Thanks in advance for any help anyone can give.

Suppose you had the following script and you wanted to create an installer application to run this code.

display dialog "hi"
tell application "Finder"
	make new Finder window at front
end tell

First you copy/paste the above code into a text file on your desktop called “installerCode.txt”. Then this script will read that text file and create an installer application called “installer.app” on your desktop which runs that code.

set installerCodePath to (path to desktop folder as text) & "installerCode.txt"
set installerPath to (path to desktop folder as text) & "installer.app"

do shell script "osacompile -o " & quoted form of POSIX path of installerPath & " < " & quoted form of POSIX path of installerCodePath

So in the script you posted, you showed how to write a text file. You use that knowledge to write a text file with the installer code that you want into the “installerCode.txt” file. Then you use the code above to create an installer application. This would allow you to create various installer.app’s for your different situations.