kopia lustrzana https://github.com/OpenDroneMap/WebODM
Persists secret_key between updates
rodzic
c0fe407157
commit
ef5336927d
|
@ -1 +1,2 @@
|
||||||
**/.git
|
**/.git
|
||||||
|
.secret_key
|
|
@ -102,4 +102,5 @@ package-lock.json
|
||||||
|
|
||||||
# Debian builds
|
# Debian builds
|
||||||
dpkg/build
|
dpkg/build
|
||||||
dpkg/deb
|
dpkg/deb
|
||||||
|
.secret_key
|
|
@ -33,6 +33,7 @@ services:
|
||||||
- WO_BROKER
|
- WO_BROKER
|
||||||
- WO_DEV
|
- WO_DEV
|
||||||
- WO_DEV_WATCH_PLUGINS
|
- WO_DEV_WATCH_PLUGINS
|
||||||
|
- WO_SECRET_KEY
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
oom_score_adj: 0
|
oom_score_adj: 0
|
||||||
broker:
|
broker:
|
||||||
|
@ -52,5 +53,6 @@ services:
|
||||||
environment:
|
environment:
|
||||||
- WO_BROKER
|
- WO_BROKER
|
||||||
- WO_DEBUG
|
- WO_DEBUG
|
||||||
|
- WO_SECRET_KEY
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
oom_score_adj: 250
|
oom_score_adj: 250
|
||||||
|
|
26
webodm.sh
26
webodm.sh
|
@ -335,13 +335,27 @@ run(){
|
||||||
eval "$1"
|
eval "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_secret(){
|
||||||
|
if [ ! -e ./.secret_key ] && [ -e /dev/random ]; then
|
||||||
|
echo "Generating secret in ./.secret_key"
|
||||||
|
export WO_SECRET_KEY=$(head -c50 < /dev/random | base64)
|
||||||
|
echo $WO_SECRET_KEY > ./.secret_key
|
||||||
|
elif [ -e ./.secret_key ]; then
|
||||||
|
export WO_SECRET_KEY=$(cat ./.secret_key)
|
||||||
|
else
|
||||||
|
export WO_SECRET_KEY=""
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
start(){
|
start(){
|
||||||
if [[ $dev_mode = true ]]; then
|
get_secret
|
||||||
echo "Starting WebODM in development mode..."
|
|
||||||
down
|
if [[ $dev_mode = true ]]; then
|
||||||
else
|
echo "Starting WebODM in development mode..."
|
||||||
echo "Starting WebODM..."
|
down
|
||||||
fi
|
else
|
||||||
|
echo "Starting WebODM..."
|
||||||
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
echo "Using the following environment:"
|
echo "Using the following environment:"
|
||||||
echo "================================"
|
echo "================================"
|
||||||
|
|
|
@ -27,18 +27,21 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
try:
|
try:
|
||||||
from .secret_key import SECRET_KEY
|
from .secret_key import SECRET_KEY
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# This will be executed the first time Django runs
|
if os.environ.get("WO_SECRET_KEY", "") != "":
|
||||||
# It generates a secret_key.py file that contains the SECRET_KEY
|
SECRET_KEY = os.environ.get("WO_SECRET_KEY")
|
||||||
from django.utils.crypto import get_random_string
|
else:
|
||||||
|
# This will be executed the first time Django runs
|
||||||
|
# It generates a secret_key.py file that contains the SECRET_KEY
|
||||||
|
from django.utils.crypto import get_random_string
|
||||||
|
|
||||||
current_dir = os.path.abspath(os.path.dirname(__file__))
|
current_dir = os.path.abspath(os.path.dirname(__file__))
|
||||||
chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'
|
chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'
|
||||||
secret = get_random_string(50, chars)
|
secret = get_random_string(50, chars)
|
||||||
with open(os.path.join(current_dir, 'secret_key.py'), 'w') as f:
|
with open(os.path.join(current_dir, 'secret_key.py'), 'w') as f:
|
||||||
f.write("SECRET_KEY='{}'".format(secret))
|
f.write("SECRET_KEY='{}'".format(secret))
|
||||||
SECRET_KEY=secret
|
SECRET_KEY=secret
|
||||||
|
|
||||||
print("Generated secret key")
|
print("Generated secret key")
|
||||||
|
|
||||||
with open(os.path.join(BASE_DIR, 'package.json')) as package_file:
|
with open(os.path.join(BASE_DIR, 'package.json')) as package_file:
|
||||||
data = json.load(package_file)
|
data = json.load(package_file)
|
||||||
|
|
Ładowanie…
Reference in New Issue