1
0
mirror of https://github.com/Mailu/Mailu.git synced 2025-01-26 03:52:50 +02:00

Initialize the databae properly

This commit is contained in:
Pierre Jaury 2016-02-21 16:47:30 +01:00
parent 946054240d
commit 8e38535710
3 changed files with 14 additions and 9 deletions

6
admin/initdb.py Normal file
View File

@ -0,0 +1,6 @@
from freeposte import db
# Initialize the database
db.create_all()
db.session.commit()

View File

@ -1,10 +1,5 @@
from freeposte import app, db
# Initialize the database if required (first launch)
db.create_all()
db.session.commit()
if __name__ == '__main__':
app.run(debug=True)

View File

@ -27,22 +27,26 @@ mkdir -p \
/data/ssl
# Create the main database if necessary
[ -f /data/freeposte.db ] || sqlite3 /data/freeposte.db .databases > /dev/null
if [ ! -f /data/freeposte.db ]; then
echo 'Initializing the database...'
cd /admin && python initdb.py
fi
# Fixing permissions
chown mail:www-data /data/freeposte.db
chown www-data:mail /data/freeposte.db
chmod 664 /data/freeposte.db
chown -R mail:mail /data/mail
chown -R www-data:www-data /data/webmail /data/logs/webmail
# Copy the system snakeoil certificate if none is provided
if [ ! -f /data/ssl/cert.pem ]; then
cat <<< EOF
cat << EOF
No TLS certificate is installed, a snakeoil ceritifcate is thus
being configured. You MUST NOT run a production server with this
certificate, as the private key is known publicly.
You have been warned.
EOF
EOF
cp /etc/ssl/private/ssl-cert-snakeoil.key /data/ssl/key.pem
cp /etc/ssl/certs/ssl-cert-snakeoil.pem /data/ssl/cert.pem
fi