-
Notifications
You must be signed in to change notification settings - Fork 4
/
cb_install.sh
executable file
·75 lines (61 loc) · 2.05 KB
/
cb_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
#!/bin/bash
#########################################################################
# Title: Cloudbox Install Script #
# Author(s): desimaniac #
# URL: https://github.com/cloudbox/cb #
# -- #
# Part of the Cloudbox project: https://cloudbox.works #
#########################################################################
# GNU General Public License v3.0 #
#########################################################################
## Variables
VERBOSE=false
CB_REPO="https://github.com/Cloudbox/cb.git"
CB_PATH="/srv/git/cb"
CB_INSTALL_SCRIPT="$CB_PATH/cb_install.sh"
SCRIPT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$(basename "${BASH_SOURCE[0]}")"
$VERBOSE && echo "Script Path: " $SCRIPT_PATH
run_cmd () {
if $VERBOSE; then
printf '%s\n' "+ $*" >&2;
"$@"
else
"$@" > /dev/null 2>&1
fi
}
while getopts 'v' f; do
case $f in
v) VERBOSE=true;;
esac
done
$VERBOSE || exec >/dev/null
# Install git
run_cmd apt-get install -y git
# Remove existing repo folder
if [ -d "$CB_PATH" ]; then
run_cmd rm -rf $CB_PATH;
fi
# Clone CB repo
run_cmd mkdir -p /srv/git
run_cmd git clone --branch develop "${CB_REPO}" "$CB_PATH"
# Set chmod +x on script files
run_cmd chmod +x $CB_PATH/*.sh
$VERBOSE && echo "Script Path: "$SCRIPT_PATH
$VERBOSE && echo "CB Install Path: "$CB_INSTALL_SCRIPT
## Create script symlinks in /usr/local/bin
shopt -s nullglob
for i in "$CB_PATH"/*.sh; do
if [ ! -f "/usr/local/bin/$(basename "${i%.*}")" ]; then
run_cmd ln -s "${i}" "/usr/local/bin/$(basename "${i%.*}")"
fi
done
shopt -u nullglob
# Relaunch script from new location
if [ "$SCRIPT_PATH" != "$CB_INSTALL_SCRIPT" ]; then
bash -H "$CB_INSTALL_SCRIPT" "$@"
exit $?
fi
# Install Cloudbox Dependencies
run_cmd bash -H $CB_PATH/cb_dep.sh "$@"
# Clone Cloudbox Repo
run_cmd bash -H $CB_PATH/cb_repo.sh "$@"