@@ -20,18 +20,18 @@ launch_agent_plist_name='com.erikng.nudge.plist'
20
20
# Base paths
21
21
launch_agent_base_path=' Library/LaunchAgents/'
22
22
23
- # Fail the install if the admin forgets to change their paths and they don't exist.
24
- if [ ! -e " $3 /${launch_agent_base_path}${launch_agent_plist_name} " ]; then
25
- echo " LaunchAgent missing, exiting"
26
- exit 1
27
- fi
23
+ # Load agent if installing to a running system
24
+ if [[ $3 == " /" ]] ; then
25
+ # Fail the install if the admin forgets to change their paths and they don't exist.
26
+ if [ ! -e " $3 /${launch_agent_base_path}${launch_agent_plist_name} .plist" ]; then
27
+ echo " LaunchAgent missing, exiting"
28
+ exit 1
29
+ fi
28
30
29
- # Make the Log path 777 to cheat - do this before loading LaunchAgent
30
- /bin/mkdir -p " $3 /Library/nudge/Logs"
31
- /bin/chmod -R 777 " $3 /Library/nudge/Logs"
31
+ # Make the Log path 777 to cheat - do this before loading LaunchAgent
32
+ /bin/mkdir -p " $3 /Library/nudge/Logs"
33
+ /bin/chmod -R 777 " $3 /Library/nudge/Logs"
32
34
33
- # Load agent if installing to a running system
34
- if [ " $3 " == " /" ] ; then
35
35
# Current console user information
36
36
console_user=$( /usr/bin/stat -f " %Su" /dev/console)
37
37
console_user_uid=$( /usr/bin/id -u " $console_user " )
@@ -48,9 +48,9 @@ if [ "$3" == "/" ] ; then
48
48
/bin/launchctl asuser " ${console_user_uid} " /bin/launchctl list | /usr/bin/grep ' nudge'
49
49
# Unload the agent so it can be triggered on re-install
50
50
if [[ $? -eq 0 ]]; then
51
- /bin/launchctl asuser " ${console_user_uid} " /bin/launchctl unload " $3 / ${launch_agent_base_path}$ {launch_agent_plist_name}"
51
+ /bin/launchctl asuser " ${console_user_uid} " /bin/launchctl unload " ${launch_agent_plist_name} "
52
52
fi
53
53
# Load the launch agent
54
- /bin/launchctl asuser " ${console_user_uid} " /bin/launchctl load " $3 / ${launch_agent_base_path}${launch_agent_plist_name} "
54
+ /bin/launchctl asuser " ${console_user_uid} " /bin/launchctl load " $3 ${launch_agent_base_path}${launch_agent_plist_name} .plist "
55
55
fi
56
56
fi
0 commit comments