-
Notifications
You must be signed in to change notification settings - Fork 3
/
get.sh
executable file
·72 lines (59 loc) · 1.47 KB
/
get.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
#!/usr/bin/env bash
set -e
# init.sh (start)
PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
WORKING_DIR="$(pwd)"
# Flags
while getopts ":t:" opt; do
case $opt in
t)
CHEVERETO_TAG=$OPTARG
echo "Using tag $OPTARG" >&2
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
# Tags
CHEVERETO_SOFTWARE="chevereto"
CHEVERETO_VERSION="4"
CHEVERETO_TAG=${CHEVERETO_TAG:-${CHEVERETO_VERSION}}
CHEVERETO_PACKAGE=$CHEVERETO_TAG
CHEVERETO_API_DOWNLOAD="https://chevereto.com/api/download/"
CHEVERETO_LABEL="Chevereto V$CHEVERETO_VERSION"
# Header
cat <<EOM
__ __
____/ / ___ _ _____ _______ / /____
/ __/ _ \/ -_) |/ / -_) __/ -_) __/ _ \\
\__/_//_/\__/|___/\__/_/ \__/\__/\___/
EOM
# Ask license
echo -n "$CHEVERETO_LABEL License key (if any): 🔑"
read -s CHEVERETO_LICENSE
echo ""
# Vendor cleanup
rm -rf $WORKING_DIR/app/vendor/*
# Prepare temp dir
rm -rf .temp && mkdir .temp && cd .temp
# Download
curl -f -SOJL \
-H "License: $CHEVERETO_LICENSE" \
"${CHEVERETO_API_DOWNLOAD}${CHEVERETO_PACKAGE}"
# Extract
unzip -oq *.zip -d $WORKING_DIR
cd -
rm -rf .temp
# chown www-data
if id "www-data" &>/dev/null; then
chown -R www-data: $WORKING_DIR
else
echo '[NOTICE] www-data user not found, skipping ownership change'
fi
echo "[OK] $CHEVERETO_LABEL files provisioned!"