-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·49 lines (42 loc) · 1.57 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
#!/bin/sh
_OSTYPE="$(uname -s)"
CPUTYPE="$(uname -m)"
if [ $# != 1 ]; then
echo "Bad arguments. Use install or uninstall."
exit 1
fi
echo "Make sure you ran this script with sudo."
if [ $1 != "install" ] && [ $1 != "uninstall" ]; then
echo "Invalid command"
exit 1
fi
if [ $_OSTYPE = "Darwin" ] && [ $1 = "install" ]; then
echo "Installing aft for macOS"
if [ $CPUTYPE = "arm64" ]; then
URL="https://github.com/dd-dreams/aft/releases/latest/download/aft-macos-aarch64.gz"
else
URL="https://github.com/dd-dreams/aft/releases/latest/download/aft-macos-x86_64.gz"
fi
# Other Unix types might work, but this script currently doesn't support them.
elif [ $_OSTYPE = "Linux" ] || [ "$(echo $_OSTYPE | grep '.*BSD')" ] && [ $1 = "install" ]; then
if [ $CPUTYPE = "arm64" ]; then
echo "Incompatible architecture"
exit 1
fi
echo "Installing aft for Linux/BSD"
URL="https://github.com/dd-dreams/aft/releases/latest/download/aft-linux-x86_64.gz"
elif [ $1 = "install" ]; then
echo "Incompatible OS"
exit 1
elif [ $1 = "uninstall" ]; then
rm /usr/local/bin/aft > /dev/null 2>&1 && echo "aft uninstalled" || echo "aft not installed"
rm /etc/systemd/system/aft-relay.service > /dev/null 2>&1
exit 0
fi
curl -L $URL > /tmp/aft.gz
gzip -dcN /tmp/aft.gz > /usr/local/bin/aft
chmod +x /usr/local/bin/aft
if [ $_OSTYPE = "Linux" ] && [ "$(ps 1 | grep 'systemd')" ]; then
curl https://raw.githubusercontent.com/dd-dreams/aft/master/aft-relay.service > /etc/systemd/system/aft-relay.service
systemctl daemon-reload
fi