-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·59 lines (48 loc) · 1.12 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
#!/bin/bash
set -e
# Handle release argument
if [ -z "$1" ]; then
RELEASE="latest"
else
RELEASE="tag/$1"
fi
# Setup temp dir and cleanup
TEMP_DIR="$(mktemp -d)"
trap 'rm -rf "$TEMP_DIR"' EXIT
# Internal variables
PROJECT_REPO="https://github.com/mishamyrt/runon"
DIST_URL="$PROJECT_REPO/releases/$RELEASE/download/runon.zip"
DIST_FILE="$TEMP_DIR/runon.zip"
INSTALLATION_DIR="/usr/local/bin"
APP_FILE_NAME="runon"
APP_FILE_PATH="$INSTALLATION_DIR/$APP_FILE_NAME"
colored_print() {
echo -e "\033[${2}m${1}\033[0m"
}
grey() {
colored_print "$1" "30"
}
green() {
colored_print "$1" "32"
}
get_dist() {
curl -sL "$DIST_URL" -o "$DIST_FILE"
unzip "$DIST_FILE" -d "$TEMP_DIR" > /dev/null
}
install_dist() {
sudo rm -f "$APP_FILE_PATH"
sudo cp "$TEMP_DIR/$APP_FILE_NAME" "$APP_FILE_PATH"
}
install() {
echo "Installing runon $RELEASE"
previous_version="$(runon --version || echo "")"
if [ -n "$previous_version" ]; then
grey "Overwriting previous version: $previous_version"
fi
grey "Downloading distribution..."
get_dist
grey "Installing..."
install_dist
green "Successfully installed $(runon --version)"
}
install