Make a package that places all those files/directories (if they're all actually needed! if the instructions from paper cut tell you to just run the .app, you most likely only need the .app file, not the rest.) within a temporary directory on the target machines, then have the package run a postflight/postinstall script that opens the .app.
The only concern would be whether or not that client-local-install.app is silent or not, and whether or not that matters in your environment.
I recreated the Applescript app in Packages. However, you could use whatever package building utility is your favorite.
I update the installer version with the current long form build number of PaperCut.
I just deployed it out this week to end-users. Here's what I did using Packages.
Create a preinstall and postinstall script
Preinstall:
#!/bin/bash
#Determine current logged in user
User="$(who|awk '/console/ {print $1}')"
if [ -f /Library/LaunchAgents/com.papercut.client.agent.plist ]; then
sudo -u "$User" /bin/launchctl unload $3/Library/LaunchAgents/com.papercut.client.agent.plist
fi
ProcessName="JavaAppLauncher"
ProcessCheck="$(ps axc | grep "${ProcessName}$" | awk '{print $5}')"
if [ "$ProcessCheck" = "$ProcessName" ]; then
/usr/bin/killall JavaAppLauncher
fi
Postinstall:
#!/bin/bash
#Determine current logged in user
User="$(who|awk '/console/ {print $1}')"
if [ -f /Library/LaunchAgents/com.papercut.client.agent.plist ]; then
sudo -u "$User" /bin/launchctl unload $3/Library/LaunchAgents/com.papercut.client.agent.plist
fi
ProcessName="JavaAppLauncher"
ProcessCheck="$(ps axc | grep "${ProcessName}$" | awk '{print $5}')"
if [ "$ProcessCheck" = "$ProcessName" ]; then
/usr/bin/killall JavaAppLauncher
fi
sudo -u "$User" /bin/launchctl load /Library/LaunchAgents/com.papercut.client.agent.plist
You'll notice that I kill the process twice, once in the preinstall and again in the post install. May not be necessary to do it the second time but I just wanted to make sure that it wasn't suddenly launched again in that short time period before the postinstall ran.
Create a launchagent as per Papercut if you want to make sure the app launches every time at login:
Reference: http://www.papercut.com/kb/Main/MacClientStartupWithLaunchd
Make sure launchagent has root:wheel 644 permissions.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.papercut.client.agent</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/PCClient.app/Contents/MacOS/JavaAppLauncher</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
</plist>
Open up Packages and do the following:
Copy the PCClient.app (from the Papercut server share) to /Applications
Copy the launchagent to /Library/LaunchAgent/
Add the preinstall and postinstall scripts accordingly.
You can do this in Composer too or any other packaging tool of your choice. If you do not want it to start at login then do not use the launchagent. Also be aware that if you do use the launchagent that the user does not also happen to have PCClient.app listed under Login Items. You do not want two instances of Papercut running.
And make sure to edit the config files located in PCClient.app/Contents/Resources/config.properties and PCClient.app/Contents/Resources/config.properties.tmpl
You can open those text files with a text editor such as TextWrangler. Read through the config file and you will see what options are available. I set Silent=Y so that users do not get errors when the computer is off the network.
Hope this helps.
I just deployed it out this week to end-users. Here's what I did using Packages.
Create a preinstall and postinstall script
Preinstall:
#!/bin/bash
#Determine current logged in user
User="$(who|awk '/console/ {print $1}')"
if [ -f /Library/LaunchAgents/com.papercut.client.agent.plist ]; then
sudo -u "$User" /bin/launchctl unload $3/Library/LaunchAgents/com.papercut.client.agent.plist
fi
ProcessName="JavaAppLauncher"
ProcessCheck="$(ps axc | grep "${ProcessName}$" | awk '{print $5}')"
if [ "$ProcessCheck" = "$ProcessName" ]; then
/usr/bin/killall JavaAppLauncher
fi
Postinstall:
#!/bin/bash
#Determine current logged in user
User="$(who|awk '/console/ {print $1}')"
if [ -f /Library/LaunchAgents/com.papercut.client.agent.plist ]; then
sudo -u "$User" /bin/launchctl unload $3/Library/LaunchAgents/com.papercut.client.agent.plist
fi
ProcessName="JavaAppLauncher"
ProcessCheck="$(ps axc | grep "${ProcessName}$" | awk '{print $5}')"
if [ "$ProcessCheck" = "$ProcessName" ]; then
/usr/bin/killall JavaAppLauncher
fi
sudo -u "$User" /bin/launchctl load /Library/LaunchAgents/com.papercut.client.agent.plist
You'll notice that I kill the process twice, once in the preinstall and again in the post install. May not be necessary to do it the second time but I just wanted to make sure that it wasn't suddenly launched again in that short time period before the postinstall ran.
Create a launchagent as per Papercut if you want to make sure the app launches every time at login:
Reference: http://www.papercut.com/kb/Main/MacClientStartupWithLaunchd
Make sure launchagent has root:wheel 644 permissions.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.papercut.client.agent</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/PCClient.app/Contents/MacOS/JavaAppLauncher</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
</plist>
Open up Packages and do the following:
Copy the PCClient.app (from the Papercut server share) to /Applications
Copy the launchagent to /Library/LaunchAgent/
Add the preinstall and postinstall scripts accordingly.
You can do this in Composer too or any other packaging tool of your choice. If you do not want it to start at login then do not use the launchagent. Also be aware that if you do use the launchagent that the user does not also happen to have PCClient.app listed under Login Items. You do not want two instances of Papercut running.
And make sure to edit the config files located in PCClient.app/Contents/Resources/config.properties and PCClient.app/Contents/Resources/config.properties.tmpl
You can open those text files with a text editor such as TextWrangler. Read through the config file and you will see what options are available. I set Silent=Y so that users do not get errors when the computer is off the network.
Hope this helps.
Hello, nice script. But are you sure with the postinstall script, you kill agin the process ? if I use your script I have a java error. Mac OS 10.14.6 client PCClient V21. Thanks for your response at advance