-
Notifications
You must be signed in to change notification settings - Fork 2
/
install.sh
executable file
·134 lines (117 loc) · 5 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/bash
source "system/lib.sh"
# Check for access to control docker
SUDO=''
if (( $EUID != 0 )); then
SUDO='sudo '
fi
echo -e "$TEXT_BOLD $TEXT_WHITE $TEXT_BG_GREEN
##############################################################################
# TechupBusiness/MultiProject for docker single server installations #
# Script to check and prepare your environment ... #
##############################################################################
NOTES:
- This script is not touching (starting/stopping) your existing projects
(but the reverse-proxy = accessibility online).
- If you don't enter values for your configuration, it will use the default values (if exist).
$TEXT_CLEAR
"
#################
# Checking for some applications
#################
echo "Checking if docker is installed..."
command -v docker >/dev/null 2>&1 || {
echo >&2 "Docker is missing!"
read -p " Do you want to install it now? (y/n): " INSTALL_DOCKER
if [[ $INSTALL_DOCKER == "y" ]]; then
requireCommand "wget"
requireCommand "sh"
wget -qO- https://get.docker.com/ | sh
echo "DONE - installed docker"
else
echo >&2 "Please install docker manually (https://docs.docker.com/install/) and then try again to run ./install.sh"
exit 1
fi
}
echo "Checking if docker-compose is installed..."
command -v docker-compose >/dev/null 2>&1 || {
echo >&2 "Docker-compose is missing!"
read -p " Do you want to install it now? (y/n): " INSTALL_DOCKER_COMPOSE
if [[ $INSTALL_DOCKER_COMPOSE == "y" ]]; then
requireCommand "curl"
requireCommand "git"
requireCommand "grep"
requireCommand "tail"
requireCommand "sh"
# Install docker-compose
COMPOSE_VERSION=`git ls-remote https://github.com/docker/compose | grep refs/tags | grep -oP "[0-9]+\.[0-9][0-9]+\.[0-9]+$" | tail -n 1`
$SUDO sh -c "curl -L https://github.com/docker/compose/releases/download/${COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose"
$SUDO chmod +x /usr/local/bin/docker-compose
#$SUDO curl -L "https://github.com/docker/compose/releases/download/<VERSION>/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
echo "DONE - docker-compose installed"
else
echo >&2 "Error: Please install docker-compose manually (https://docs.docker.com/compose/install/) and try again to run ./install.sh"
exit 1
fi
}
echo "Checking if docker-compose autocomplete is installed..."
if [[ ! -f /etc/bash_completion.d/docker-compose ]]; then
requireCommand "curl"
requireCommand "grep"
requireCommand "sh"
COMPOSE_VERSION=$(docker-compose --version | grep -oP "[0-9]+\.[0-9][0-9]+\.[0-9]+")
$SUDO sh -c "curl -L https://raw.githubusercontent.com/docker/compose/${COMPOSE_VERSION}/contrib/completion/bash/docker-compose -o /etc/bash_completion.d/docker-compose"
else
echo "SKIPPED - docker-compose autocomplete already installed in ~/.bashrc"
fi
echo "Checking if multiproject autocomplete is installed..."
AUTOCOMPLETE_INSTALLED=$(grep -wq "^source $PWD/system/autocomplete.sh" ~/.bashrc && echo "true" || echo "false")
if [[ "$AUTOCOMPLETE_INSTALLED" == "false" ]]; then
{
echo ""
echo "# techupbusiness/multiproject: Autocomplete installed (should be located in $PWD)"
echo "source $PWD/system/autocomplete.sh"
echo ""
} >> ~/.bashrc
echo "DONE - multiproject autocomplete installed in ~/.bashrc"
else
echo "SKIPPED - multiproject autocomplete already installed in ~/.bashrc"
fi
echo "Checking if htpasswd is installed..."
command -v htpasswd >/dev/null 2>&1 || {
echo >&2 "htpasswd (apache2-utils) is missing to create basic authentication logins!"
read -p " Do you want to install it now using apt? (y/n): " INSTALL_HTPASSWD
# TODO remove apt dependency
if [[ $INSTALL_HTPASSWD == "y" ]]; then
requireCommand "apt-get"
$SUDO apt-get update
$SUDO apt-get -y install apache2-utils
echo "DONE - apache2-utils installed"
else
echo >&2 "Error: please install htpasswd (contained in apache2-utils) manually."
fi
}
echo "Checking if command scripts can be executed..."
for SCRIPT in *.sh; do
if [[ ! -x "$SCRIPT" ]]; then
chmod +x "$SCRIPT"
echo "Made $SCRIPT executable"
fi
done
echo "DONE - checked command scripts"
for service in system/services/*; do
if [[ -d "$service" ]]; then
serviceName=$(basename "$service")
editEnv "system/services/$serviceName/template.env" "system/configuration/.env" "interactive" "$serviceName"
runScript "system/services/$serviceName" "Setup" "multiproject-system" "$serviceName"
fi
done
echo -e "
$TEXT_BOLD $TEXT_WHITE $TEXT_BG_GREEN
--------------------
Run to start all your configured multiproject system services (reverse-proxy, backup, image-update watcher, system-mailer):
> ./admin.sh up -d
Run afterwards to add your first application:
> ./project.sh <name>
$TEXT_CLEAR
"