This repository has been archived by the owner on Dec 9, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathbootstrap.sh
executable file
·49 lines (40 loc) · 1.79 KB
/
bootstrap.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
#!/bin/bash
# Force users to login before seeing any pins.
if [ "${ALLOW_NEW_REGISTRATIONS}" = "" ]; then
ALLOW_NEW_REGISTRATIONS=true
fi
if [[ "$(docker images -q pinry/pinry 2> /dev/null)" == "" ]]; then
echo "No docker image found, building..." && ./build_docker.sh
fi
echo "=================================================================================="
echo "Note: Please copy this key and keep it in a secure place."
echo "Then you should manually edit your pinry/local_settings.py"
echo "and replace SECRET_KEY with new secret-key if you had previously generated a"
echo "pinry/local_settings.py."
echo "If no previous pinry/local_settings.py generated, you can have a look and edit it."
echo "If you want to use docker-compose, just edit docker-compose.yml and use 'docker-compose up'"
SECRET_KEY=$(sudo docker run pinry/pinry /scripts/gen_key.sh)
echo ""
echo "Your secret-key is(also saved/overwritten your pinry/production_secret_key.txt):"
echo ""
echo ${SECRET_KEY}
echo "=================================================================================="
# Create local_settings.py
if [ ! -f ./pinry/local_settings.py ];
then
cp ./pinry/local_settings.example.py ./pinry/local_settings.py
sed -i "s/secret\_key\_place\_holder/${SECRET_KEY}/" ./pinry/local_settings.py
# Force users to login before seeing any pins.
if [ "${PRIVATE}" = "true" ]; then
sed -i "s/PUBLIC = True/PUBLIC = False/" ./pinry/local_settings.py
fi
# Enable people from creating new accounts.
if [ "${ALLOW_NEW_REGISTRATIONS}" = "true" ]; then
sed -i "s/ALLOW_NEW_REGISTRATIONS = False/ALLOW_NEW_REGISTRATIONS = True/" ./pinry/local_settings.py
fi
fi
# Copy to docker-compose.yml
if [ ! -f ./docker-compose.yml ];
then
cp ./docker-compose.example.yml ./docker-compose.yml
fi