Making script more flexible
* all postgres settings from user entry (user,pass,db_name) * tool root as variable * tool media folder as variable * data base creation as own step
This commit is contained in:
108
seqs/mayan-edms.sh
Executable file → Normal file
108
seqs/mayan-edms.sh
Executable file → Normal file
@@ -1,6 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
toolName="Mayan EDMS"
|
toolName="Mayan EDMS"
|
||||||
|
toolRoot="/opt/mayan-edms"
|
||||||
|
toolMediaFolder="/opt/mayan-edms/media"
|
||||||
|
|
||||||
step_1_info() { echo "Install libreoffice without gui"; }
|
step_1_info() { echo "Install libreoffice without gui"; }
|
||||||
step_1() {
|
step_1() {
|
||||||
@@ -18,67 +20,92 @@ step_2() {
|
|||||||
|
|
||||||
step_3_info() { echo "Create virtual environment"; }
|
step_3_info() { echo "Create virtual environment"; }
|
||||||
step_3() {
|
step_3() {
|
||||||
exe adduser mayan --disabled-password --disabled-login --no-create-home --gecos ""
|
exe adduser mayan --disabled-password --disabled-login --no-create-home --gecos -G users""
|
||||||
exe mkdir -p /opt
|
exe mkdir -p ${toolRoot}
|
||||||
exe virtualenv /opt/mayan-edms
|
exe virtualenv ${toolRoot}
|
||||||
saveReturn $?
|
saveReturn $?
|
||||||
endReturn
|
endReturn
|
||||||
exe chown -R mayan:mayan /opt/mayan-edms
|
exe chown -R mayan:mayan ${toolRoot}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
postgresDb=""
|
||||||
|
postgresUser=""
|
||||||
postgresPass=""
|
postgresPass=""
|
||||||
step_4_info() { echo "Install $toolName"; }
|
step_4_info() { echo "Create postgres database for $toolName"; }
|
||||||
|
step_4_alias() { ALIAS="createdb"; }
|
||||||
step_4() {
|
step_4() {
|
||||||
exe sudo -u mayan /opt/mayan-edms/bin/pip install --no-cache-dir --no-use-pep517 mayan-edms
|
{
|
||||||
saveReturn $?
|
exe read -p "Enter postgres user name: " postgresDb
|
||||||
endReturn
|
endCheckEmpty postgresDb "database"
|
||||||
exe sudo -u mayan /opt/mayan-edms/bin/pip install --no-cache-dir --no-use-pep517 psycopg2==2.7.3.2 redis==2.10.6
|
exe read -p "Enter postgres user name: " postgresUser
|
||||||
saveReturn $?
|
endCheckEmpty postgresUser "user name"
|
||||||
endReturn
|
exe read -p "Enter postgres password: " postgresPass
|
||||||
|
|
||||||
#read -p "Enter postgres user name: " postgresUser
|
|
||||||
#endCheckEmpty postgresUser "user name"
|
|
||||||
read -p "Enter postgres password: " postgresPass
|
|
||||||
endCheckEmpty postgresPass "password"
|
endCheckEmpty postgresPass "password"
|
||||||
|
|
||||||
exe sudo -u postgres psql -c "CREATE USER mayan WITH password '${postgresPass}';"
|
exe sudo -u postgres psql -c "CREATE USER ${postgresUser} WITH password '${postgresPass}';"
|
||||||
exe sudo -u postgres createdb -O mayan mayan
|
# -O owner : Specifies the database user who will own the new database.
|
||||||
|
exe sudo -u postgres createdb -O ${postgresUser} ${postgresDb}
|
||||||
exe sudo -u mayan MAYAN_DATABASE_ENGINE=django.db.backends.postgresql MAYAN_DATABASE_NAME=mayan \
|
|
||||||
MAYAN_DATABASE_PASSWORD="${postgresPass}" MAYAN_DATABASE_USER=mayan \
|
|
||||||
MAYAN_DATABASE_HOST=127.0.0.1 MAYAN_MEDIA_ROOT=/opt/mayan-edms/media \
|
|
||||||
/opt/mayan-edms/bin/mayan-edms.py initialsetup
|
|
||||||
|
|
||||||
exe sudo -u mayan MAYAN_MEDIA_ROOT=/opt/mayan-edms/media \
|
|
||||||
/opt/mayan-edms/bin/mayan-edms.py collectstatic --noinput
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
step_5_info() { echo "Install $toolName"; }
|
||||||
|
step_5() {
|
||||||
|
exe sudo -u mayan ${toolRoot}/bin/pip install --no-cache-dir --no-use-pep517 mayan-edms
|
||||||
|
saveReturn $?
|
||||||
|
endReturn
|
||||||
|
exe sudo -u mayan ${toolRoot}/bin/pip install --no-cache-dir --no-use-pep517 psycopg2==2.7.3.2 redis==2.10.6
|
||||||
|
saveReturn $?
|
||||||
|
endReturn
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
exe sudo -u mayan MAYAN_MEDIA_ROOT=${toolMediaFolder} \
|
||||||
|
${toolRoot}/bin/mayan-edms.py collectstatic --noinput
|
||||||
|
}
|
||||||
|
|
||||||
|
step_6_info() { echo "$toolName configuration file"; }
|
||||||
|
step_6() {
|
||||||
|
addConf "$supervisorFile" "$supervisorFileLoc"
|
||||||
|
|
||||||
|
exe echo "maxmemory-policy allkeys-lru" >> "$redisConfLoc"
|
||||||
|
exe echo "save \"\"" >> "$redisConfLoc"
|
||||||
|
exe echo "databases 1" >> "$redisConfLoc"
|
||||||
|
exe systemctl restart redis
|
||||||
|
|
||||||
|
exe systemctl enable supervisor
|
||||||
|
exe systemctl restart supervisor
|
||||||
|
}
|
||||||
|
|
||||||
|
redisConfLoc="/etc/redis/redis.conf"
|
||||||
|
supervisorFileLoc="/etc/supervisor/conf.d/mayan.conf"
|
||||||
supervisorFile="\
|
supervisorFile="\
|
||||||
[supervisord]
|
[supervisord]
|
||||||
environment=
|
environment=
|
||||||
MAYAN_ALLOWED_HOSTS='[\"*\"]', # Allow access to other network hosts other than localhost
|
MAYAN_ALLOWED_HOSTS='[\"*\"]', # Allow access to other network hosts other than localhost
|
||||||
MAYAN_CELERY_RESULT_BACKEND=\"redis://127.0.0.1:6379/0\",
|
MAYAN_CELERY_RESULT_BACKEND=\"redis://127.0.0.1:6379/0\",
|
||||||
MAYAN_BROKER_URL=\"redis://127.0.0.1:6379/0\",
|
MAYAN_BROKER_URL=\"redis://127.0.0.1:6379/0\",
|
||||||
PYTHONPATH=/opt/mayan-edms/lib/python2.7/site-packages:/opt/mayan-edms/data,
|
PYTHONPATH=${toolRoot}/lib/python2.7/site-packages:${toolRoot}/data,
|
||||||
MAYAN_MEDIA_ROOT=/opt/mayan-edms/media,
|
MAYAN_MEDIA_ROOT=${toolMediaFolder},
|
||||||
MAYAN_DATABASE_ENGINE=django.db.backends.postgresql,
|
MAYAN_DATABASE_ENGINE=django.db.backends.postgresql,
|
||||||
MAYAN_DATABASE_HOST=127.0.0.1,
|
MAYAN_DATABASE_HOST=127.0.0.1,
|
||||||
MAYAN_DATABASE_NAME=mayan,
|
MAYAN_DATABASE_NAME=${postgresDb},
|
||||||
MAYAN_DATABASE_PASSWORD=\"${postgresPass}\",
|
MAYAN_DATABASE_PASSWORD=\"${postgresPass}\",
|
||||||
MAYAN_DATABASE_USER=mayan,
|
MAYAN_DATABASE_USER=${postgresUser},
|
||||||
MAYAN_DATABASE_CONN_MAX_AGE=60,
|
MAYAN_DATABASE_CONN_MAX_AGE=60,
|
||||||
DJANGO_SETTINGS_MODULE=mayan.settings.production
|
DJANGO_SETTINGS_MODULE=mayan.settings.production
|
||||||
|
|
||||||
[program:mayan-gunicorn]
|
[program:mayan-gunicorn]
|
||||||
autorestart = true
|
autorestart = true
|
||||||
autostart = true
|
autostart = true
|
||||||
command = /opt/mayan-edms/bin/gunicorn -w 2 mayan.wsgi --max-requests 500 --max-requests-jitter 50 --worker-class gevent --bind 0.0.0.0:8000 --timeout 120
|
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
|
user = mayan
|
||||||
|
|
||||||
[program:mayan-worker-fast]
|
[program:mayan-worker-fast]
|
||||||
autorestart = true
|
autorestart = true
|
||||||
autostart = true
|
autostart = true
|
||||||
command = nice -n 1 /opt/mayan-edms/bin/mayan-edms.py celery worker -Ofair -l ERROR -Q converter,sources_fast -n mayan-worker-fast.%%h --concurrency=1
|
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
|
killasgroup = true
|
||||||
numprocs = 1
|
numprocs = 1
|
||||||
priority = 998
|
priority = 998
|
||||||
@@ -89,7 +116,7 @@ user = mayan
|
|||||||
[program:mayan-worker-medium]
|
[program:mayan-worker-medium]
|
||||||
autorestart = true
|
autorestart = true
|
||||||
autostart = true
|
autostart = true
|
||||||
command = nice -n 18 /opt/mayan-edms/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
|
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
|
killasgroup = true
|
||||||
numprocs = 1
|
numprocs = 1
|
||||||
priority = 998
|
priority = 998
|
||||||
@@ -100,7 +127,7 @@ user = mayan
|
|||||||
[program:mayan-worker-slow]
|
[program:mayan-worker-slow]
|
||||||
autorestart = true
|
autorestart = true
|
||||||
autostart = true
|
autostart = true
|
||||||
command = nice -n 19 /opt/mayan-edms/bin/mayan-edms.py celery worker -Ofair -l ERROR -Q mailing,tools,statistics,parsing,ocr -n mayan-worker-slow.%%h --concurrency=1
|
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
|
killasgroup = true
|
||||||
numprocs = 1
|
numprocs = 1
|
||||||
priority = 998
|
priority = 998
|
||||||
@@ -111,7 +138,7 @@ user = mayan
|
|||||||
[program:mayan-celery-beat]
|
[program:mayan-celery-beat]
|
||||||
autorestart = true
|
autorestart = true
|
||||||
autostart = true
|
autostart = true
|
||||||
command = nice -n 1 /opt/mayan-edms/bin/mayan-edms.py celery beat --pidfile= -l ERROR
|
command = nice -n 1 ${toolRoot}/bin/mayan-edms.py celery beat --pidfile= -l ERROR
|
||||||
killasgroup = true
|
killasgroup = true
|
||||||
numprocs = 1
|
numprocs = 1
|
||||||
priority = 998
|
priority = 998
|
||||||
@@ -119,17 +146,4 @@ startsecs = 10
|
|||||||
stopwaitsecs = 1
|
stopwaitsecs = 1
|
||||||
user = mayan"
|
user = mayan"
|
||||||
|
|
||||||
step_5_info() { echo "$toolName configuration file"; }
|
|
||||||
step_5() {
|
|
||||||
addConf "$supervisorFile" "/etc/supervisor/conf.d/mayan.conf"
|
|
||||||
|
|
||||||
exe echo "maxmemory-policy allkeys-lru" >> /etc/redis/redis.conf
|
|
||||||
exe echo "save \"\"" >> /etc/redis/redis.conf
|
|
||||||
exe echo "databases 1" >> /etc/redis/redis.conf
|
|
||||||
exe systemctl restart redis
|
|
||||||
|
|
||||||
exe systemctl enable supervisor
|
|
||||||
exe systemctl restart supervisor
|
|
||||||
}
|
|
||||||
|
|
||||||
. sequencer.sh
|
. sequencer.sh
|
||||||
|
Reference in New Issue
Block a user