-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLAB_Set_Lab_wakeorpoweron_settings.sh
More file actions
executable file
·114 lines (84 loc) · 3.16 KB
/
LAB_Set_Lab_wakeorpoweron_settings.sh
File metadata and controls
executable file
·114 lines (84 loc) · 3.16 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/bin/zsh --no-rcs
# Jason Filice
# jfilice@csumb.edu
# Technology Support Services in IT
# California State University, Monterey Bay
# https://csumb.edu/it
# Sets automatic repeating wake/power on schedule for Labs
#
# Postponed script execution in DeployStudio. Commands must run as root.
# Change History:
# 2015/06/29: Creation.
#
SCRIPTNAME=`/usr/bin/basename "$0"`
SCRIPTPATH=`/usr/bin/dirname "$0"`
echo "***Begin $SCRIPTNAME script***"
/bin/date
# Jamf JSS Parameters 1 through 3 are predefined as mount point, computer name, and username
pathToScript=$0
mountPoint=$1
computerName=$2
userName=$3
shift 3
# Shift off the $1 $2 $3 parameters passed by the JSS so that parameter 4 is now $1
# set default values for PMSET
PMSETrepeatTYPE="wakeorpoweron"
PMSETrepeatWEEKDAYS="MTWRFSU"
PMSETrepeatTIME="07:00:00"
echo "Sets automatic repeating wake/power on schedule for Labs."
echo 'Script accepts 3 parameters for "type" "weekdays" "time"'
echo ' or accepts 1 parameter "cancel" (case-insensitive)'
echo ' or without passed parameters, uses hard-coded values from script:'
echo "type=$PMSETrepeatTYPE"
echo "weekdays=$PMSETrepeatWEEKDAYS"
echo "time=$PMSETrepeatTIME"
echo ""
echo "Displaying scheduled startup/wake and shutdown/sleep events..."
/usr/bin/pmset -g sched
# pmset allows you to schedule system sleep, shutdown, wakeup and/or power
# on. "schedule" is for setting up one-time power events, and "repeat" is
# for setting up daily/weekly power on and power off events. Note that you
# may only have one pair of repeating events scheduled - a "power on" event
# and a "power off" event. For sleep cycling applications, pmset can sched-
# ule a "relative" wakeup to occur in seconds from the end of system sleep,
# but this event cannot be cancelled and is inherently imprecise.
# Syntax:
# pmset repeat cancel
# pmset repeat type weekdays time
#
# type - one of sleep, wake, poweron, shutdown, wakeorpoweron
# weekdays - a subset of MTWRFSU ("M" and "MTWRF" are valid strings)
# time - HH:mm:ss
# If exists parameter $1 and is "cancel" case-insensitive
# http://wiki.bash-hackers.org/syntax/ccmd/conditional_expression
if [[ $1 =~ [Cc][Aa][Nn][Cc][Ee][Ll] ]]
then
echo 'Canceling all repeating scheduled power events...'
# /usr/bin/pmset repeat cancel
elif [ $# -ge 3 ]
then
# 'at least 3 parameters'
PMSETrepeatTYPE=${1}
PMSETrepeatWEEKDAYS=${2}
PMSETrepeatTIME=${3}
echo "Setting values to the first 3 passed parameter values..."
echo "type=$PMSETrepeatTYPE"
echo "weekdays=$PMSETrepeatWEEKDAYS"
echo "time=$PMSETrepeatTIME"
# /usr/bin/pmset repeat ${PMSETrepeatTYPE} ${PMSETrepeatWEEKDAYS} ${PMSETrepeatTIME}
else
echo "Insufficient parameters passed to script."
echo 'Setting to values to hard-coded values from script...'
echo "type=$PMSETrepeatTYPE"
echo "weekdays=$PMSETrepeatWEEKDAYS"
echo "time=$PMSETrepeatTIME"
# /usr/bin/pmset repeat ${PMSETrepeatTYPE} ${PMSETrepeatWEEKDAYS} ${PMSETrepeatTIME}
fi
# /usr/bin/pmset repeat wakeorpoweron MTWRFSU 07:00:00
# /usr/bin/pmset
# /usr/bin/pmset
echo "Displaying scheduled startup/wake and shutdown/sleep events..."
/usr/bin/pmset -g sched
echo "***End $SCRIPTNAME script***"
/bin/date
exit 0