-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinstall.sh
118 lines (95 loc) · 2.08 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/bash
set -e
INSTALL_DIR="/usr/local/bin/"
FILENAME=""
RELEASE="0.1.3"
flags() {
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-d | --install-dir)
INSTALL_DIR="$2"
shift
shift
;;
-r | --release)
RELEASE="$2"
shift
shift
;;
*)
echo "Unrecognized argument $key"
exit 1
;;
esac
done
}
filename() {
local OS
OS=$(uname -s)
CPU=$(uname -m)
echo "[DENOMON]"
echo "Thanks for using denomon."
echo ""
echo "> Instaling version $RELEASE"
echo ""
if [ "$OS" == "Linux" ]; then
FILENAME="denomon_${RELEASE}_${OS}_${CPU}"
elif [ "$OS" == "Darwin" ]; then
FILENAME="denomon_${RELEASE}_${OS}_${CPU}"
else
echo "OS $OS is not supported."
echo "If you think that's a bug - please file an issue to https://github.com/muhibbudins/denomon/issues"
exit 1
fi
}
download() {
echo ""
if [ "$RELEASE" == "latest" ]; then
URL=https://github.com/muhibbudins/denomon/releases/latest/download/$FILENAME.tar.gz
else
URL=https://github.com/muhibbudins/denomon/releases/download/v$RELEASE/$FILENAME.tar.gz
fi
DOWNLOAD_DIR=$(mktemp -d)
echo "Downloading $URL"
mkdir -p $INSTALL_DIR &>/dev/null
curl -L $URL -o $DOWNLOAD_DIR/$FILENAME.tar.gz
if [ 0 -ne $? ]; then
echo "Download failed. Check that the release/filename are correct."
exit 1
fi;
echo ""
echo "Installing denomon"
echo ""
tar -xzvf $DOWNLOAD_DIR/$FILENAME.tar.gz -C $DOWNLOAD_DIR
mv $DOWNLOAD_DIR/denomon $INSTALL_DIR/denomon
chmod u+x $INSTALL_DIR/denomon
echo ""
echo "Successfully installing denomon"
echo ""
echo "`denomon --help`"
echo ""
}
check() {
echo "Checking dependencies for the installation script:"
echo ""
if hash curl 2>/dev/null; then
echo "> curl is available"
else
echo "> curl is missing!"
SHOULD_EXIT="true"
fi
if hash tar 2>/dev/null; then
echo "> tar is available"
else
echo "> tar is missing!"
SHOULD_EXIT="true"
fi
if [ "$SHOULD_EXIT" = "true" ]; then
exit 1
fi
}
flags "$@"
filename
check
download