Skip to content

Commit 46ad5b8

Browse files
Merge pull request #64 from root3nl/development
v2.4
2 parents fbbc307 + 87b202a commit 46ad5b8

38 files changed

Lines changed: 2005 additions & 223 deletions
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/zsh
2+
3+
# Support App Extension - Battery Condition
4+
#
5+
#
6+
# Copyright 2022 Root3 B.V. All rights reserved.
7+
#
8+
# Support App Extension to get the battery condition and publish to
9+
# Extension B.
10+
#
11+
# REQUIREMENTS:
12+
# - Jamf Pro Binary
13+
#
14+
# THE SOFTWARE IS PROVIDED BY ROOT3 B.V. "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
17+
# EVENT SHALL ROOT3 B.V. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18+
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
19+
# IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20+
21+
# --------------------- do not edit below this line ----------------------
22+
23+
# Support App preference plist
24+
preference_file_location="/Library/Preferences/nl.root3.support.plist"
25+
26+
# Start spinning indicator
27+
defaults write "${preference_file_location}" ExtensionLoadingB -bool true
28+
29+
# Replace value with placeholder while loading
30+
defaults write "${preference_file_location}" ExtensionValueB -string "KeyPlaceholder"
31+
32+
# Keep loading effect active for 0.5 seconds
33+
sleep 0.5
34+
35+
# Get the battery condition
36+
battery_condition=$(system_profiler SPPowerDataType | sed -n -e 's/^.*Condition: //p')
37+
38+
# Write output to Support App preference plist
39+
defaults write "${preference_file_location}" ExtensionValueB -string "${battery_condition}"
40+
41+
# Stop spinning indicator
42+
defaults write "${preference_file_location}" ExtensionLoadingB -bool false
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/zsh
2+
3+
# Support App Extension - Jamf Pro Last Check-In Time
4+
#
5+
#
6+
# Copyright 2022 Root3 B.V. All rights reserved.
7+
#
8+
# Support App Extension to get the Jamf Pro Last Check-In Time and publish to
9+
# Extension A.
10+
#
11+
# REQUIREMENTS:
12+
# - Jamf Pro Binary
13+
#
14+
# THE SOFTWARE IS PROVIDED BY ROOT3 B.V. "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
17+
# EVENT SHALL ROOT3 B.V. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18+
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
19+
# IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20+
21+
# ------------------ edit the variables below this line ------------------
22+
23+
# Enable 24 hour clock format. 12 hour clock enabled by default
24+
twenty_four_hour_format="true"
25+
26+
# --------------------- do not edit below this line ----------------------
27+
28+
# Support App preference plist
29+
preference_file_location="/Library/Preferences/nl.root3.support.plist"
30+
31+
# Start spinning indicator
32+
defaults write "${preference_file_location}" ExtensionLoadingA -bool true
33+
34+
# Replace value with placeholder while loading
35+
defaults write "${preference_file_location}" ExtensionValueA -string "KeyPlaceholder"
36+
37+
# Keep loading effect active for 0.5 seconds
38+
sleep 0.5
39+
40+
# Get last Jamf Pro check-in time from jamf.log
41+
last_check_in_time=$(grep "Checking for policies triggered by \"recurring check-in\"" "/private/var/log/jamf.log" | tail -n 1 | awk '{ print $2,$3,$4 }')
42+
43+
# Convert last Jamf Pro check-in time to epoch
44+
last_check_in_time_epoch=$(date -j -f "%b %d %T" "${last_check_in_time}" +"%s")
45+
46+
# Convert last Jamf Pro epoch to something easier to read
47+
if [[ "${twenty_four_hour_format}" == "true" ]]; then
48+
# Outputs 24 hour clock format
49+
last_check_in_time_human_reable=$(date -r "${last_check_in_time_epoch}" "+%A %H:%M")
50+
else
51+
# Outputs 12 hour clock format
52+
last_check_in_time_human_reable=$(date -r "${last_check_in_time_epoch}" "+%A %I:%M %p")
53+
fi
54+
55+
# Write output to Support App preference plist
56+
defaults write "${preference_file_location}" ExtensionValueA -string "${last_check_in_time_human_reable}"
57+
58+
# Stop spinning indicator
59+
defaults write "${preference_file_location}" ExtensionLoadingA -bool false
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/zsh
2+
3+
# Support App Extension - SAP Privileges Change Permissions
4+
#
5+
#
6+
# Copyright 2022 Root3 B.V. All rights reserved.
7+
#
8+
# Support App Extension to change user permissions with SAP Privileges.
9+
#
10+
# REQUIREMENTS:
11+
# - Jamf Pro Binary
12+
# - SAP Privileges: https://github.com/SAP/macOS-enterprise-privileges
13+
#
14+
# THE SOFTWARE IS PROVIDED BY ROOT3 B.V. "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
17+
# EVENT SHALL ROOT3 B.V. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18+
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
19+
# IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20+
21+
# --------------------- do not edit below this line ----------------------
22+
23+
# Support App preference plist
24+
preference_file_location="/Library/Preferences/nl.root3.support.plist"
25+
26+
# SAP Privileges CLI
27+
sap_privileges_cli="/Applications/Privileges.app/Contents/Resources/PrivilegesCLI"
28+
29+
# Start spinning indicator
30+
defaults write "${preference_file_location}" ExtensionLoadingB -bool true
31+
32+
# Replace value with placeholder while loading
33+
defaults write "${preference_file_location}" ExtensionValueB -string "KeyPlaceholder"
34+
35+
# Get the username of the currently logged in user
36+
username=$(scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }')
37+
38+
# Check if user is administrator
39+
is_admin=$(dsmemberutil checkmembership -U "${username}" -G admin)
40+
41+
# Change permissions
42+
if [[ ${is_admin} != *not* ]]; then
43+
sudo -u ${username} ${sap_privileges_cli} --remove
44+
else
45+
sudo -u ${username} ${sap_privileges_cli} --add
46+
fi
47+
48+
# Run Support App Extension to report new permission status
49+
"/usr/local/bin/sap_privileges_status.zsh"
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/zsh
2+
3+
# Support App Extension - User Permissions
4+
#
5+
#
6+
# Copyright 2022 Root3 B.V. All rights reserved.
7+
#
8+
# Support App Extension to get the current user permission schema.
9+
#
10+
# REQUIREMENTS:
11+
# - Jamf Pro Binary
12+
#
13+
# THE SOFTWARE IS PROVIDED BY ROOT3 B.V. "AS IS", WITHOUT WARRANTY OF ANY KIND,
14+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
16+
# EVENT SHALL ROOT3 B.V. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17+
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
18+
# IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19+
20+
# --------------------- do not edit below this line ----------------------
21+
22+
# Support App preference plist
23+
preference_file_location="/Library/Preferences/nl.root3.support.plist"
24+
25+
# Start spinning indicator
26+
defaults write "${preference_file_location}" ExtensionLoadingB -bool true
27+
28+
# Replace value with placeholder while loading
29+
defaults write "${preference_file_location}" ExtensionValueB -string "KeyPlaceholder"
30+
31+
# Keep loading effect active for 0.5 seconds
32+
sleep 0.5
33+
34+
# Get the username of the currently logged in user
35+
username=$(scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }')
36+
37+
# Check if user is administrator
38+
is_admin=$(dsmemberutil checkmembership -U "${username}" -G admin)
39+
40+
# Change permissions
41+
if [[ ${is_admin} != *not* ]]; then
42+
defaults write "${preference_file_location}" ExtensionValueB -string "Administrator"
43+
else
44+
defaults write "${preference_file_location}" ExtensionValueB -string "Standard User"
45+
fi
46+
47+
# Stop spinning indicator
48+
defaults write "${preference_file_location}" ExtensionLoadingB -bool false

0 commit comments

Comments
 (0)