Rework usage of mayan-edms.py
This commit is contained in:
@@ -5,17 +5,12 @@ toolVersion="3.2.3"
|
||||
toolRoot="/opt/mayan-edms"
|
||||
toolMediaFolder="/opt/mayan-edms/media"
|
||||
|
||||
# Needs readDatabaseInfos() to execute some commands
|
||||
toolScript="sudo -u mayan MAYAN_DATABASE_ENGINE=django.db.backends.postgresql MAYAN_DATABASE_NAME=${postgresDb} \
|
||||
MAYAN_DATABASE_PASSWORD=\"${postgresPass}\" MAYAN_DATABASE_USER=${postgresUser} \
|
||||
MAYAN_DATABASE_HOST=127.0.0.1 MAYAN_MEDIA_ROOT=${toolMediaFolder} \
|
||||
${toolRoot}/bin/mayan-edms.py"
|
||||
|
||||
# Needed for different steps
|
||||
postgresDb=""
|
||||
postgresUser=""
|
||||
postgresPass=""
|
||||
|
||||
|
||||
step_1_info() { echo "Install libreoffice without gui"; }
|
||||
step_1() {
|
||||
exe apt update
|
||||
@@ -59,21 +54,22 @@ step_5() {
|
||||
saveReturn $?
|
||||
endReturn
|
||||
|
||||
readDatabaseInfos
|
||||
|
||||
exe sudo -u mayan MAYAN_DATABASE_ENGINE=django.db.backends.postgresql MAYAN_DATABASE_NAME=${postgresDb} \
|
||||
MAYAN_DATABASE_PASSWORD="${postgresPass}" MAYAN_DATABASE_USER=${postgresUser} \
|
||||
MAYAN_DATABASE_HOST=127.0.0.1 MAYAN_MEDIA_ROOT=${toolMediaFolder} \
|
||||
${toolRoot}/bin/mayan-edms.py initialsetup
|
||||
toolScript initialsetup
|
||||
|
||||
exe sudo -u mayan MAYAN_MEDIA_ROOT=${toolMediaFolder} \
|
||||
${toolRoot}/bin/mayan-edms.py collectstatic --noinput
|
||||
}
|
||||
|
||||
step_6_info() { echo "$toolName configuration file"; }
|
||||
step_6_info() { echo "Supervisord configuration for $toolName"; }
|
||||
step_6() {
|
||||
readDatabaseInfos
|
||||
addConf -c "$supervisorFile" "$supervisorFileLoc"
|
||||
addConf -c "" "$supervisordConfLoc"
|
||||
toolScript "platformtemplate supervisord > ${supervisordConfLoc}"
|
||||
echo "Wrap you password in \", if it contains a \"=\" character, in the file ${supervisordConfLoc}"
|
||||
}
|
||||
supervisordConfLoc="/etc/supervisor/conf.d/mayan.conf"
|
||||
|
||||
step_7_info() { echo "$toolName configuration file"; }
|
||||
step_7() {
|
||||
addConf -a "$redisConf" "$redisConfLoc"
|
||||
|
||||
exe systemctl restart redis
|
||||
@@ -87,72 +83,6 @@ redisConf="\
|
||||
maxmemory-policy allkeys-lru
|
||||
save \"\"
|
||||
databases 1"
|
||||
supervisorFileLoc="/etc/supervisor/conf.d/mayan.conf"
|
||||
supervisorFile="\
|
||||
[supervisord]
|
||||
environment=
|
||||
MAYAN_ALLOWED_HOSTS='[\"*\"]', # Allow access to other network hosts other than localhost
|
||||
MAYAN_CELERY_RESULT_BACKEND=\"redis://127.0.0.1:6379/0\",
|
||||
MAYAN_BROKER_URL=\"redis://127.0.0.1:6379/0\",
|
||||
PYTHONPATH=${toolRoot}/lib/python2.7/site-packages:${toolRoot}/data,
|
||||
MAYAN_MEDIA_ROOT=${toolMediaFolder},
|
||||
MAYAN_DATABASE_ENGINE=django.db.backends.postgresql,
|
||||
MAYAN_DATABASE_HOST=127.0.0.1,
|
||||
MAYAN_DATABASE_NAME=${postgresDb},
|
||||
MAYAN_DATABASE_PASSWORD=\"${postgresPass}\",
|
||||
MAYAN_DATABASE_USER=${postgresUser},
|
||||
MAYAN_DATABASE_CONN_MAX_AGE=60,
|
||||
DJANGO_SETTINGS_MODULE=mayan.settings.production
|
||||
|
||||
[program:mayan-gunicorn]
|
||||
autorestart = true
|
||||
autostart = true
|
||||
command = ${toolRoot}/bin/gunicorn -w 2 mayan.wsgi --max-requests 500 --max-requests-jitter 50 --worker-class gevent --bind 0.0.0.0:8000 --timeout 120
|
||||
user = mayan
|
||||
|
||||
[program:mayan-worker-fast]
|
||||
autorestart = true
|
||||
autostart = true
|
||||
command = nice -n 1 ${toolRoot}/bin/mayan-edms.py celery worker -Ofair -l ERROR -Q converter,sources_fast -n mayan-worker-fast.%%h --concurrency=1
|
||||
killasgroup = true
|
||||
numprocs = 1
|
||||
priority = 998
|
||||
startsecs = 10
|
||||
stopwaitsecs = 1
|
||||
user = mayan
|
||||
|
||||
[program:mayan-worker-medium]
|
||||
autorestart = true
|
||||
autostart = true
|
||||
command = nice -n 18 ${toolRoot}/bin/mayan-edms.py celery worker -Ofair -l ERROR -Q checkouts_periodic,documents_periodic,indexing,metadata,sources,sources_periodic,uploads,documents -n mayan-worker-medium.%%h --concurrency=1
|
||||
killasgroup = true
|
||||
numprocs = 1
|
||||
priority = 998
|
||||
startsecs = 10
|
||||
stopwaitsecs = 1
|
||||
user = mayan
|
||||
|
||||
[program:mayan-worker-slow]
|
||||
autorestart = true
|
||||
autostart = true
|
||||
command = nice -n 19 ${toolRoot}/bin/mayan-edms.py celery worker -Ofair -l ERROR -Q mailing,tools,statistics,parsing,ocr -n mayan-worker-slow.%%h --concurrency=1
|
||||
killasgroup = true
|
||||
numprocs = 1
|
||||
priority = 998
|
||||
startsecs = 10
|
||||
stopwaitsecs = 1
|
||||
user = mayan
|
||||
|
||||
[program:mayan-celery-beat]
|
||||
autorestart = true
|
||||
autostart = true
|
||||
command = nice -n 1 ${toolRoot}/bin/mayan-edms.py celery beat --pidfile= -l ERROR
|
||||
killasgroup = true
|
||||
numprocs = 1
|
||||
priority = 998
|
||||
startsecs = 10
|
||||
stopwaitsecs = 1
|
||||
user = mayan"
|
||||
|
||||
step_10_info() { echo "Update $toolName"; }
|
||||
step_10_alias() { ALIAS="update"; }
|
||||
@@ -164,19 +94,17 @@ step_10() {
|
||||
exe sudo -u mayan ${toolRoot}/bin/pip install --no-cache-dir mayan-edms==$toolVersion
|
||||
saveReturn $?
|
||||
endReturn
|
||||
readDatabaseInfos
|
||||
$toolScript performupgrade
|
||||
$toolScript preparestatic --noinput
|
||||
toolScript performupgrade
|
||||
toolScript preparestatic --noinput
|
||||
}
|
||||
uninstallRemovalsLoc="/tmp/removals.txt"
|
||||
|
||||
step_11_info() { echo "New supervisord configuration for $toolName"; }
|
||||
step_11() {
|
||||
addConf -c "" "$supervisordConfLoc"
|
||||
readDatabaseInfos
|
||||
$toolScript platformtemplate supervisord > "${supervisordConfLoc}.new"
|
||||
|
||||
step_13_info() { echo "$toolName management script"; }
|
||||
step_13() {
|
||||
read -p "Command (empty for help): " command
|
||||
toolScript "$command"
|
||||
}
|
||||
supervisordConfLoc="/etc/supervisor/conf.d/mayan.conf"
|
||||
|
||||
step_20_info() { echo "Backup postgres database to media folder"; }
|
||||
step_20_alias() { ALIAS="backupdb"; }
|
||||
@@ -217,6 +145,18 @@ readDatabaseInfos() {
|
||||
read -s -p "Enter postgres password: " postgresPass
|
||||
endCheckEmpty postgresPass "password"
|
||||
fi
|
||||
echo
|
||||
}
|
||||
|
||||
# Needs readDatabaseInfos() to execute some commands
|
||||
toolScript() {
|
||||
if [ ! -z "$1" ] ; then
|
||||
readDatabaseInfos
|
||||
fi
|
||||
exep "sudo -u mayan MAYAN_DATABASE_ENGINE=django.db.backends.postgresql MAYAN_DATABASE_NAME=${postgresDb} \
|
||||
MAYAN_DATABASE_PASSWORD=\"${postgresPass}\" MAYAN_DATABASE_USER=${postgresUser} \
|
||||
MAYAN_DATABASE_HOST=127.0.0.1 MAYAN_MEDIA_ROOT=${toolMediaFolder} \
|
||||
${toolRoot}/bin/mayan-edms.py $*"
|
||||
}
|
||||
|
||||
VERSION_SEQREV=4
|
||||
|
Reference in New Issue
Block a user