-
Notifications
You must be signed in to change notification settings - Fork 52
/
start.sh
executable file
·69 lines (57 loc) · 1.74 KB
/
start.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
#!/bin/bash
#
# Script to start your Portainer
#
# Uses the admin password specified in the .env file
# 1. Check if .env file exists
if [ -e .env ]; then
source .env
else
echo "Please set up your .env file before starting your enviornment."
exit 1
fi
# 2. Passowrd for Admin User
# 2.1 Check if a password was set up in the .env file
if [ -z "$ADMIN_PASSWORD" ]; then
echo "You must set up a password in your '.env' file."
exit 1
fi
# 2.2 Check if passowrd was the same as sample file
if [ $ADMIN_PASSWORD = "your_admin_password" ]; then
echo
echo "#-----------------------------------------------------------"
echo "#"
echo "# CAREFUL!"
echo "#"
echo "# You are using the same passowrd of our sample."
echo "# Please change it AS SOON AS POSSÍBLE!"
echo "#"
echo "#-----------------------------------------------------------"
echo
fi
# 2.3 Generate the encrypted password
ENCRYPTED_PASSWORD=$(docker run --rm httpd:2.4-alpine htpasswd -nbB admin $ADMIN_PASSWORD | cut -d ":" -f 2)
# 2.4 Delete old ENCRYPTED_PASSWORD
if [[ $(uname) == "Darwin" ]]
then
sed -i '' '/ENCRYPTED_PASSWORD/d' .env
else
sed -i '/ENCRYPTED_PASSWORD/d' .env
fi
# 2.4 Send passowrd to .env file
echo "ENCRYPTED_PASSWORD='$ENCRYPTED_PASSWORD'" >> .env
# 3. Start Portainer container
docker-compose -f docker-compose-with-password.yml up -d
# Final message
echo
echo "#-----------------------------------------------------------"
echo "#"
echo "# The WebProxy take a few moments to get the SSL Certificates"
echo "#"
echo "# Please check your browser to see if it is running, use your"
echo "# domain(s): "
echo "# $DOMAINS"
echo "#"
echo "#-----------------------------------------------------------"
echo
exit 0