-
Notifications
You must be signed in to change notification settings - Fork 134
/
install.sh
executable file
·62 lines (54 loc) · 1.61 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
#! /bin/bash
exec_curl(){
echo "Found docgen latest version: $VERSION"
echo "Download may take few minutes depending on your internet speed"
echo "Downloading docgen to $2"
curl -L --silent --connect-timeout 30 --retry-delay 5 --retry 5 -o "$2" "$1"
}
OS=`uname`
ARCH=`uname -m`
VERSION=$1
URL=https://github.com/thedevsaddam/docgen
TARGET=/usr/local/bin/docgen
MESSAGE_START="Installing docgen"
MESSAGE_END="Installation complete"
if [ "$VERSION" == "" ]; then
LATEST_RELEASE=$(curl -L -s -H 'Accept: application/json' $URL/releases/latest)
VERSION=$(echo $LATEST_RELEASE | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/')
fi
if [ "$OS" == "Darwin" ]; then
if [ "$ARCH" == "x86_64" ]; then
exec_curl $URL/releases/download/$VERSION/darwin_amd64 $TARGET
echo "$MESSAGE_START"
chmod +x $TARGET
echo "$MESSAGE_END"
docgen
fi
if [ "$ARCH" == "arm64" ] || [ "$ARCH" == "aarch64" ]; then
exec_curl $URL/releases/download/$VERSION/darwin_arm64 $TARGET
echo "$MESSAGE_START"
chmod +x $TARGET
echo "$MESSAGE_END"
docgen
fi
elif [ "$OS" == "Linux" ]; then
if [ "$ARCH" == "x86_64" ]; then
exec_curl $URL/releases/download/$VERSION/linux_amd64 $TARGET
echo "$MESSAGE_START"
chmod +x $TARGET
echo "$MESSAGE_END"
docgen
fi
if [ "$ARCH" == "arm64" ] || [ "$ARCH" == "aarch64" ]; then
exec_curl $URL/releases/download/$VERSION/linux_arm64 $TARGET
echo "$MESSAGE_START"
chmod +x $TARGET
echo "$MESSAGE_END"
docgen
fi
if [ "$ARCH" == "i368" ]; then
exec_curl $URL/releases/download/$VERSION/linux_386 $TARGET
chmod +x $TARGET
docgen
fi
fi