Posted on 08-28-2015 02:35 AM
Hi all,
Hoping someone can help me here. We're going to be deploying crashplan ProE out to our org soon.
In the installer script on the local machine there is a variable for %CP_USERNAME% (or similar) which needs to be the individuals email address.
Is there anyway to pipe the casper $EMAIL variable into the Crashplan username variable?
We do not have AD/LDAP to perform this function unfortunately.
Once again, thank you all in advance.
Solved! Go to Solution.
Posted on 08-28-2015 04:57 AM
Yes, this could be done using one of the following methods:
#!/bin/bash
###########################################################################################################
################## IMPORTANT - ENTER JSS INFORMATION IN "apiQuery" FUNCTION BEFORE USING ##################
###########################################################################################################
# Set field seperator to newline
IFS=$'
'
# Function for querying the JSS API
# Parameters:
# (1) URL Suffix for the page that needs to be queried.
# (2) Value that you are searching for within the JSS API.
apiQuery() {
# Set full URL path to JSS hostname. Example:
# jssURL="https://mycompany.mydomain.com:8443"
jssURL=""
# Set JSS API username. Example:
# jssUser="CasperAPI"
jssUser=""
# Set JSS API password. Example:
# jssPW="password"
jssPW=""
# If requesting JSON response
if [ "$1" == "json" ]; then
# Get data from JSS and return the JSON response. Add the "-k" switch to the "curl" command if SSL Cert is not trusted.
curl "$jssURL/JSSResource/$2" -H 'Accept: application/json' --user "$jssUser:$jssPW" --silent | python -m json.tool
# If not requesting the JSON response
else
# Get data from JSS and return the XML response. Add the "-k" switch to the "curl" command if SSL Cert is not trusted.
curl -k "$jssURL/JSSResource/$1" --user "$jssUser:$jssPW" --silent | awk -F "<$2>|</$2>" '{ print $2 }'
fi
}
###########################################################################################################
############################ OPTION 1 - GET EMAIL ADDRESS FROM COMPUTER RECORD ############################
###########################################################################################################
# Get hardware UUID/UDID of system
hwUDID=`system_profiler SPHardwareDataType | awk '/Hardware UUID/{ print $3 }'`
# Get assigned user's email address from the JSS computer record
assignedUserEmail=`apiQuery "computers/udid/$hwUDID/subset/location" email_address`
###########################################################################################################
############################## OPTION 2 - GET EMAIL ADDRESS FROM USER RECORD ##############################
###########################################################################################################
# Get currently logged in user
targetUser=`python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "
");'`
# Get currently logged in user's email address from the JSS user record
currentUserEmail=`apiQuery "users/name/$targetUser" email`
# Output information
echo "Assigned User Email Address: $assignedUserEmail"
echo "Current User Email Address: $currentUserEmail"
I hope this helps!
Posted on 08-28-2015 07:05 AM
The following white paper might help: Administering CrashPlan PROe with the Casper Suite
Basically, just use the code in the user info script (/Library/Application Support/CrashPlan/.custom/userInfo.sh) and set the "CP_USER_NAME" variable to the result of the command.
I created my installation package manually using Composer, and just put my custom.properties, userInfo.sh, and CrashPlan installer in /Library/Application Support/CrashPlan/.custom. In addition, I have a post-install script that runs the actual installer and removes the .custom directory once complete. The final piece of the puzzle is a custom script that is used in my deployment policies, which checks to ensure that requirements are met (i.e. the logged in user is the person that the machine is assigned to). If all of the requirements are met, it triggers the policy which actually installs the custom package.
Posted on 08-28-2015 04:57 AM
Yes, this could be done using one of the following methods:
#!/bin/bash
###########################################################################################################
################## IMPORTANT - ENTER JSS INFORMATION IN "apiQuery" FUNCTION BEFORE USING ##################
###########################################################################################################
# Set field seperator to newline
IFS=$'
'
# Function for querying the JSS API
# Parameters:
# (1) URL Suffix for the page that needs to be queried.
# (2) Value that you are searching for within the JSS API.
apiQuery() {
# Set full URL path to JSS hostname. Example:
# jssURL="https://mycompany.mydomain.com:8443"
jssURL=""
# Set JSS API username. Example:
# jssUser="CasperAPI"
jssUser=""
# Set JSS API password. Example:
# jssPW="password"
jssPW=""
# If requesting JSON response
if [ "$1" == "json" ]; then
# Get data from JSS and return the JSON response. Add the "-k" switch to the "curl" command if SSL Cert is not trusted.
curl "$jssURL/JSSResource/$2" -H 'Accept: application/json' --user "$jssUser:$jssPW" --silent | python -m json.tool
# If not requesting the JSON response
else
# Get data from JSS and return the XML response. Add the "-k" switch to the "curl" command if SSL Cert is not trusted.
curl -k "$jssURL/JSSResource/$1" --user "$jssUser:$jssPW" --silent | awk -F "<$2>|</$2>" '{ print $2 }'
fi
}
###########################################################################################################
############################ OPTION 1 - GET EMAIL ADDRESS FROM COMPUTER RECORD ############################
###########################################################################################################
# Get hardware UUID/UDID of system
hwUDID=`system_profiler SPHardwareDataType | awk '/Hardware UUID/{ print $3 }'`
# Get assigned user's email address from the JSS computer record
assignedUserEmail=`apiQuery "computers/udid/$hwUDID/subset/location" email_address`
###########################################################################################################
############################## OPTION 2 - GET EMAIL ADDRESS FROM USER RECORD ##############################
###########################################################################################################
# Get currently logged in user
targetUser=`python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "
");'`
# Get currently logged in user's email address from the JSS user record
currentUserEmail=`apiQuery "users/name/$targetUser" email`
# Output information
echo "Assigned User Email Address: $assignedUserEmail"
echo "Current User Email Address: $currentUserEmail"
I hope this helps!
Posted on 08-28-2015 05:30 AM
You sir are a star, BUT how do i then get that information into the installer script that lives in the crashplan DMG on the local machine ?
Posted on 08-28-2015 07:05 AM
The following white paper might help: Administering CrashPlan PROe with the Casper Suite
Basically, just use the code in the user info script (/Library/Application Support/CrashPlan/.custom/userInfo.sh) and set the "CP_USER_NAME" variable to the result of the command.
I created my installation package manually using Composer, and just put my custom.properties, userInfo.sh, and CrashPlan installer in /Library/Application Support/CrashPlan/.custom. In addition, I have a post-install script that runs the actual installer and removes the .custom directory once complete. The final piece of the puzzle is a custom script that is used in my deployment policies, which checks to ensure that requirements are met (i.e. the logged in user is the person that the machine is assigned to). If all of the requirements are met, it triggers the policy which actually installs the custom package.
Posted on 08-28-2015 11:34 AM
A massive thank you again, you've been a great help !!