Skip to content
This repository was archived by the owner on Feb 8, 2023. It is now read-only.

Commit 479bce7

Browse files
committed
fix postinstall
1 parent a449f67 commit 479bce7

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

scripts/postinstall

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@ launch_agent_plist_name='com.erikng.nudge.plist'
2020
# Base paths
2121
launch_agent_base_path='Library/LaunchAgents/'
2222

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
2830

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"
3234

33-
# Load agent if installing to a running system
34-
if [ "$3" == "/" ] ; then
3535
# Current console user information
3636
console_user=$(/usr/bin/stat -f "%Su" /dev/console)
3737
console_user_uid=$(/usr/bin/id -u "$console_user")
@@ -48,9 +48,9 @@ if [ "$3" == "/" ] ; then
4848
/bin/launchctl asuser "${console_user_uid}" /bin/launchctl list | /usr/bin/grep 'nudge'
4949
# Unload the agent so it can be triggered on re-install
5050
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}"
5252
fi
5353
# 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"
5555
fi
5656
fi

0 commit comments

Comments
 (0)