Papercut Client 15.0 - automate installation over existing older installs

jevans76
New Contributor

I'm looking to automate upgrading our fleet of OSX clients to the latest version of Papercut MF Client 15.0.

The "Mac" folder the OSX client software is found in on the Papercut Server looks like this

d8dbbebf558749ada7875f9d210e1c2a

As per Papercut's recommended install instructions, the best way to install the client is to run:

client-local-install.app

Examining "client-local-install.app" shows it contains a script that sets permissions correctly, etc in order for the app to run for all users on the target client once installed, so I definitely want to leverage this method if possible via Casper.

My questions is, is anyone out there using this method to automate their PCClient installs using Casper?

If so, can you please tell me how you are doing this? The manual process on the client would be to connect to a network share hosting the above file structure and run the client-local-install.app file.

How do I go about automating this same process in Casper? Do all of the files in that structure need to be uploaded to the JSS repository? The flat structure of the JSS repository would make that very messy, not being able to place them all in a sub folder for organisation and ease of navigation.

Thanks very much.

4 REPLIES 4

nkalister
Valued Contributor

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.

willpolley
New Contributor III

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.

bpavlov
Honored Contributor

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.

Cyberbof
New Contributor II

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