-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
37 lines (30 loc) · 833 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
32
33
34
35
36
37
#!/bin/bash
unm=$(logname)
uid=$(id -u $unm)
src=$(dirname "$0")
usr="/Users/$unm"
lib="$usr/Library"
plf="$lib/LaunchAgents/com.luxafor.flag.plist"
# Header
echo -e "\nInstalling..."
# Install agent
mkdir -p "$lib/LaunchAgents"
cp "$src/com.luxafor.flag.plist" "$lib/LaunchAgents" 2>/dev/null
sed -i "" "s/<UID>/$unm/g" "$plf"
chown root "$plf"
chgrp wheel "$plf"
chmod 644 "$plf"
echo "-> $plf"
# Install script
mkdir -p "$lib/Scripts"
cp "$src/flag.py" "$lib/Scripts" 2>/dev/null
echo "-> $lib/Scripts/flag.py"
# Install hook
defaults write com.apple.loginwindow LogoutHook "$usr/.logouthook"
echo -e $"#!/bin/bash\n\n/usr/bin/python3 $lib/Scripts/flag.py logout" > "$usr/.logouthook"
chmod +x "$usr/.logouthook"
echo "-> $usr/.logouthook"
# Launch agent
launchctl bootstrap gui/"${uid}" "$plf"
# Footer
echo "All done!"