forked from damieng/setledsmac
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathinstall.sh
executable file
·31 lines (22 loc) · 844 Bytes
/
install.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
#!/bin/bash
set -euo pipefail
if (( $EUID != 0 )); then
echo "Error: Please run with sudo"
exit 1
fi
BINARY="$(stat -f "%N" ${1})"
if [[ ! -f "${BINARY}" ]]; then
echo "Error: No file found at ${BINARY}"
exit 1
fi
echo "Making sure the file is executable .. "
chmod +x "${BINARY}"
echo "Installing launch agent .. "
sed -e "s|%%BINARYPATH%%|${BINARY}|g" com.rajiteh.setleds.plist.template > /Library/LaunchDaemons/com.rajiteh.setleds.plist
echo "Setting launch agent permissions .. "
chown root:wheel /Library/LaunchDaemons/com.rajiteh.setleds.plist
echo "Enabling the launch configuration .. "
launchctl load -w /Library/LaunchDaemons/com.rajiteh.setleds.plist
echo "Starting the job .. "
launchctl start /Library/LaunchDaemons/com.rajiteh.setleds.plist || :
echo "All done! Numlock functionality should now be restored."