refactoring changes from sequpgrade (endReturn, ...) and some modernizations

This commit is contained in:
2023-01-03 15:49:08 +01:00
parent 215135e8aa
commit 3c22d5729f
69 changed files with 553 additions and 654 deletions

View File

@@ -54,7 +54,7 @@ step_2() {
graphviz libfuse2 libjpeg-dev libmagic1 libpq-dev libpng-dev libtiff-dev libldap2-dev libsasl2-dev \
poppler-utils postgresql python3-dev python3-pip python3-venv python3-virtualenv \
redis-server sane-utils supervisor tesseract-ocr tesseract-ocr-deu zlib1g-dev -y
endReturn -o $? "Binary dependencies installation failed"
endReturn "Binary dependencies installation failed"
exe systemctl enable supervisor
exe systemctl stop supervisor
@@ -65,7 +65,7 @@ step_3() {
exe adduser --disabled-password --disabled-login --no-create-home --gecos "" mayan
exe usermod -a -G users mayan
exe python3 -m venv ${toolRoot}
endReturn -o $? "Creating virtual environment failed"
endReturn "Creating virtual environment failed"
exe chown -R mayan:mayan ${toolRoot}
}
@@ -74,7 +74,7 @@ step_4_alias() { echo "createdb"; }
step_4() {
readDatabaseInfos
exe cd ~postgres
exe cd ~postgres
exe sudo -u postgres psql -c "CREATE USER ${postgresUser} WITH password '${postgresPass}';"
# -O owner : Specifies the database user who will own the new database.
exe sudo -u postgres createdb -O ${postgresUser} ${postgresDb}
@@ -86,9 +86,9 @@ step_5() {
step upgradepip
exe sudo -u mayan ${toolRoot}/bin/pip install --no-cache-dir mayan-edms=="${toolVersion}"
endReturn -o $? "pip install for $toolName failed"
endReturn "pip install for $toolName failed"
exe sudo -u mayan ${toolRoot}/bin/pip install --no-cache-dir psycopg2==2.8.4 redis==3.4.1
endReturn -o $?
endReturn
}
step_6_info() { echo "Supervisord configuration for $toolName"; }
@@ -133,10 +133,10 @@ step_10() {
step upgradepip
exe curl -o "$uninstallRemovalsLoc" https://gitlab.com/mayan-edms/mayan-edms/raw/master/removals.txt
exe sudo -u mayan ${toolRoot}/bin/pip uninstall -r "$uninstallRemovalsLoc"
endReturn -o $?
endReturn
exe systemctl stop supervisor
exe sudo -u mayan ${toolRoot}/bin/pip install --no-cache-dir mayan-edms=="${toolVersion}"
endReturn -o $?
endReturn
toolScript performupgrade
#toolScript preparestatic --noinput # only < 3.4
case "${1:-}" in
@@ -158,7 +158,7 @@ step_13() {
if dry; then
echo " dryrun"
else
read command
read command
fi
else
command="$@"
@@ -178,7 +178,7 @@ step_20_alias() { echo "backupdb"; }
step_20() {
local DELYEAR=$(($(date +%Y)-2))
if [ ! -s ~/.pgpass ] ; then
echo " [I] For unattended backup please define ~/.pgpass containing credentials for user mayan"
info "For unattended backup please define ~/.pgpass containing credentials for user mayan"
echo " e.g. localhost:5432:mayan:mayan:pass4mayan"
echo "Backup custom pg format with standard user / database: mayan / mayan"
fi
@@ -191,7 +191,7 @@ toolDbBackupFolder=${toolMediaFolder}/backupdb
step_22_info() { echo "Postgres database restore"; }
step_22_alias() { echo "restoredb"; }
step_22() {
echo " [I] Postgres database restore procedure"
info "Postgres database restore procedure"
echo "1. Create a empty postgres database first (step 4)"
echo "2. psql -h <host> -U <database user> -d <database name> -W -f <sql dump file>"
echo " e.g. psql -h 127.0.0.1 -U mayan -d mayan -W -f 2018-06-07_18-10-56.sql"