-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathuploadPackageJCDS.sh
64 lines (63 loc) · 2.43 KB
/
uploadPackageJCDS.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/sh
####################################################################################################
#
# THIS SCRIPT IS NOT AN OFFICIAL PRODUCT OF JAMF SOFTWARE
# AS SUCH IT IS PROVIDED WITHOUT WARRANTY OR SUPPORT
#
# BY USING THIS SCRIPT, YOU AGREE THAT JAMF SOFTWARE
# IS UNDER NO OBLIGATION TO SUPPORT, DEBUG, OR OTHERWISE
# MAINTAIN THIS SCRIPT
#
####################################################################################################
#
# DESCRIPTION
# This can upload a file to the JCDS thru the API
# Credit go to Jamf Nation User: Yamashiro for inspiration
####################################################################################################
#
# DEFINE VARIABLES & READ IN PARAMETERS
#
####################################################################################################
read -p "Jamf Pro URL: " server
read -p "Jamf Pro Username: " username
read -s -p "Jamf Pro Password: " password
echo ""
read -p "File Name (including file type): " filename
read -p "Full path to file (/tmp/mypackage.pkg): " path
####################################################################################################
#
# SCRIPT CONTENTS - DO NOT MODIFY BELOW THIS LINE
#
####################################################################################################
# Courtesy of github dot com slash zdorow
echo "Testing connection to Jamf Pro..."
test=$(curl --fail -ksu "$username":"$password" "$server"/JSSResource/users -X GET)
status=$?
if [ $status -eq 6 ]; then
echo ""
echo "The Jamf Pro URL is incorrect. Please edit the URL and try again."
echo "If the error persists please check permissions and internet connection"
echo ""
exit 99
elif [ $status -eq 22 ]; then
echo ""
echo "Username and/or password is incorrect. Please edit and try again."
echo "If the error persists please check permissions and internet connection"
echo ""
exit 99
elif [ $status -eq 0 ]; then
echo ""
echo "Connection test successful! "
echo ""
else
echo ""
echo "Something went really wrong,"
echo "Lets try this again."
exit 99
fi
####################################################################################################
#
# MAIN PROCESS
#
####################################################################################################
curl -u "$username":"$password" -X POST "$server"/dbfileupload -H 'DESTINATION: 0' -H 'OBJECT_ID: -1' -H 'FILE_TYPE: 0' -H 'FILE_NAME: '$filename'' -T "$path"