-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathinstall-cli.sh
executable file
·54 lines (42 loc) · 1.2 KB
/
install-cli.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
#!/usr/bin/env bash
DIST=$(cat /etc/*release | grep "^ID=" | cut -d '=' -f 2)
# Require sudo or root privilege
if [ $EUID != 0 ]; then
sudo "$0" "$@"
exit $?
fi
TEMP_PATH=/tmp
DEV_INSTALL=0
apt update
apt install -y gnupg build-essential devscripts debhelper jq
if [ -f ./target/release.tar.gz ]; then
# For development/testing purpose
TEMP_PATH=$(pwd)/target
DEV_INSTALL=1
pushd $TEMP_PATH
echo "Extracting ... "
rm -rf irgsh-go && tar -xf release.tar.gz
echo "Extracting [OK]"
echo
echo "Installing files ... "
cp -v $TEMP_PATH/irgsh-go/usr/bin/irgsh-cli /usr/bin/irgsh-cli
else
# Download and extract
pushd $TEMP_PATH
DOWNLOAD_URL=$(curl -ksL "https://api.github.com/repos/BlankOn/irgsh-go/releases/latest" | jq -r '.assets | .[] | select(.name == "irgsh-cli")| .browser_download_url')
echo "Downloading ... "
echo "$DOWNLOAD_URL"
rm -f $TEMP_PATH/irgsh-cli && curl -L -f -o ./irgsh-cli $DOWNLOAD_URL
if test $? -gt 0; then
echo "Downloding [FAILED]"
exit 1
fi
echo "Downloding [OK]"
echo
echo "Installing file ... "
cp -v $TEMP_PATH/irgsh-cli /usr/bin/irgsh-cli
ln -sf /usr/bin/irgsh-cli /usr/bin/irgsh
chmod +x /usr/bin/irgsh-cli
fi
popd >/dev/null
echo "Happy hacking!"