forked from malfunkt/arpfox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·60 lines (49 loc) · 1.32 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
51
52
53
54
55
56
57
58
59
60
#!/bin/sh
WORK_DIR=/tmp
BIN_DIR=/usr/local/bin
arch() {
ARCH=$(uname -m)
case $ARCH in
x86_64) ARCH=amd64;;
esac
}
os() {
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
}
download() {
LATEST_RELEASE_JSON="https://api.github.com/repos/malfunkt/arpfox/releases/latest"
DOWNLOAD_URL=$(curl --silent -L $LATEST_RELEASE_JSON | grep browser_download_url | sed s/'^.*: "'//g | sed s/'"$'//g | grep "$OS.*$ARCH")
if [ -z "$DOWNLOAD_URL" ]; then
curl --silent -L $LATEST_RELEASE_JSON;
echo "Github API is not working right now. Please try again later.";
exit 1
fi;
BASENAME=$(basename $DOWNLOAD_URL)
wget $DOWNLOAD_URL -O $WORK_DIR/$BASENAME
case $BASENAME in
*.bz2)
bzip2 -d $WORK_DIR/$BASENAME
FILENAME=$WORK_DIR/arpfox_${OS}_${ARCH}
;;
*.gz)
gzip -dfv $WORK_DIR/$BASENAME
FILENAME=$WORK_DIR/arpfox_${OS}_${ARCH}
;;
*.zip)
unzip -d $WORK_DIR -o $WORK_DIR/$BASENAME
FILENAME=$WORK_DIR/arpfox_${OS}_${ARCH}.exe
;;
*)
echo "Don't know how to handle downloaded file $BASENAME" && exit 1
;;
esac
if [ -z "$FILENAME" ]; then
echo "Could not install." && exit 1
fi;
echo "This script needs root privileges in order to install into $BIN_DIR."
sudo install -c -m 0755 $FILENAME $BIN_DIR/arpfox
rm $FILENAME
}
arch
os
download