-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathinstall.sh
executable file
·50 lines (44 loc) · 1.52 KB
/
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
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env bash
USER=$(logname)
HOME=$(eval echo "~$USER")
echo "USER=$USER"
echo "HOME=$HOME"
echo "Creating $HOME/.macmounter"
mkdir -p "$HOME/.macmounter"
if [ ! -d "$HOME/.macmounter" ]; then
echo "Error creating .macmounter folder."
else
chown $USER "$HOME/.macmounter"
fi
cp ./sample/example.conf "$HOME/.macmounter"
chown $USER "$HOME/.macmounter/example.conf"
echo "Creating $HOME/Library/Application Support/macmounter"
mkdir -p "$HOME/Library/Application Support/macmounter"
if [ ! -d "$HOME/Library/Application Support/macmounter" ]; then
echo "Error creating application folder."
else
chown $USER "$HOME/Library/Application Support/macmounter"
fi
if [ ! -d /usr/local/bin/ ]; then
echo "Creating /usr/local/bin ..."
mkdir -p /usr/local/bin/
fi
echo "Installing scripts in /usr/local/bin"
cp ./scripts/macmounter.py /usr/local/bin
if [ ! -f /usr/local/bin/macmounter.py ]; then
echo "Error installing script."
fi
echo "Installing launcher in $HOME/Library/LaunchAgents"
cp ./launch/com.irouble.macmounter.plist "$HOME/Library/LaunchAgents"
if [ ! -f "$HOME/Library/LaunchAgents/com.irouble.macmounter.plist" ]; then
echo "Error installing launcher."
else
sudo -u $USER launchctl list | grep macmounter
if [ $? -eq 0 ]; then
echo "Stopping service"
sudo -u $USER launchctl unload "$HOME/Library/LaunchAgents/com.irouble.macmounter.plist"
fi
sleep 2
echo "Starting service"
sudo -u $USER launchctl load -w "$HOME/Library/LaunchAgents/com.irouble.macmounter.plist"
fi