Bump to revision 3

addConf with mandatory paramter; suppots appending
This commit is contained in:
2019-05-17 11:59:51 +01:00
parent 34966ddf79
commit ab10ef6504
11 changed files with 103 additions and 53 deletions

View File

@@ -41,7 +41,7 @@ step_11() {
} }
# Sequence Revision # Sequence Revision
VERSION_SEQREV=2 VERSION_SEQREV=3
# Workaround when called from different directory # Workaround when called from different directory
# Not needed when path to sequencer is absolut # Not needed when path to sequencer is absolut

View File

@@ -139,7 +139,7 @@ step_20() {
} }
# Sequence Revision # Sequence Revision
VERSION_SEQREV=2 VERSION_SEQREV=3
# Workaround when called from different directory # Workaround when called from different directory
# Not needed when path to sequencer is absolut # Not needed when path to sequencer is absolut

View File

@@ -46,7 +46,7 @@ step_3() {
step_4_info() { echo "Create systemd service"; } step_4_info() { echo "Create systemd service"; }
step_4() { step_4() {
addConf "$toolServiceContent" "$toolServiceFile" addConf -c "$toolServiceContent" "$toolServiceFile"
if [ $? -eq 0 ] ; then if [ $? -eq 0 ] ; then
exe systemctl daemon reload exe systemctl daemon reload
@@ -85,7 +85,7 @@ step_5() {
local udevFile="/etc/udev/rules.d/99-kodi.rules" local udevFile="/etc/udev/rules.d/99-kodi.rules"
local inputRule="KERNEL==\"tty[0-9]*\", GROUP=\"tty\", MODE=\"0660\"" local inputRule="KERNEL==\"tty[0-9]*\", GROUP=\"tty\", MODE=\"0660\""
addConf "$inputRule" "$udevFile" addConf -c "$inputRule" "$udevFile"
} }
step_6_info() { echo "Increase raspberry pi GPU memory to 320"; } step_6_info() { echo "Increase raspberry pi GPU memory to 320"; }
@@ -127,5 +127,5 @@ step_7() {
esac esac
} }
VERSION_SEQREV=2 VERSION_SEQREV=3
. sequencer.sh . sequencer.sh

View File

@@ -135,7 +135,7 @@ step_42() {
} }
# Sequence Revision # Sequence Revision
VERSION_SEQREV=2 VERSION_SEQREV=3
# Workaround when called from different directory # Workaround when called from different directory
# Not needed when path to sequencer is absolut # Not needed when path to sequencer is absolut

View File

@@ -4,6 +4,11 @@ toolName="Mayan EDMS"
toolRoot="/opt/mayan-edms" toolRoot="/opt/mayan-edms"
toolMediaFolder="/opt/mayan-edms/media" toolMediaFolder="/opt/mayan-edms/media"
# Needed for different steps
postgresDb=""
postgresUser=""
postgresPass=""
step_1_info() { echo "Install libreoffice without gui"; } step_1_info() { echo "Install libreoffice without gui"; }
step_1() { step_1() {
exe apt update exe apt update
@@ -28,18 +33,10 @@ step_3() {
exe chown -R mayan:mayan ${toolRoot} exe chown -R mayan:mayan ${toolRoot}
} }
postgresDb=""
postgresUser=""
postgresPass=""
step_4_info() { echo "Create postgres database for $toolName"; } step_4_info() { echo "Create postgres database for $toolName"; }
step_4_alias() { ALIAS="createdb"; } step_4_alias() { ALIAS="createdb"; }
step_4() { step_4() {
exe read -p "Enter postgres database name: " postgresDb readDatabaseInfos
endCheckEmpty postgresDb "database"
exe read -p "Enter postgres user name: " postgresUser
endCheckEmpty postgresUser "user name"
exe read -p "Enter postgres password: " postgresPass
endCheckEmpty postgresPass "password"
exe sudo -u postgres psql -c "CREATE USER ${postgresUser} WITH password '${postgresPass}';" exe sudo -u postgres psql -c "CREATE USER ${postgresUser} WITH password '${postgresPass}';"
# -O owner : Specifies the database user who will own the new database. # -O owner : Specifies the database user who will own the new database.
@@ -55,6 +52,8 @@ step_5() {
saveReturn $? saveReturn $?
endReturn endReturn
readDatabaseInfos
exe sudo -u mayan MAYAN_DATABASE_ENGINE=django.db.backends.postgresql MAYAN_DATABASE_NAME=${postgresDb} \ 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_PASSWORD="${postgresPass}" MAYAN_DATABASE_USER=${postgresUser} \
MAYAN_DATABASE_HOST=127.0.0.1 MAYAN_MEDIA_ROOT=${toolMediaFolder} \ MAYAN_DATABASE_HOST=127.0.0.1 MAYAN_MEDIA_ROOT=${toolMediaFolder} \
@@ -66,11 +65,10 @@ step_5() {
step_6_info() { echo "$toolName configuration file"; } step_6_info() { echo "$toolName configuration file"; }
step_6() { step_6() {
addConf "$supervisorFile" "$supervisorFileLoc" readDatabaseInfos
addConf -c "$supervisorFile" "$supervisorFileLoc"
addConf -a "$redisConf" "$redisConfLoc"
exe echo "maxmemory-policy allkeys-lru" >> "$redisConfLoc"
exe echo "save \"\"" >> "$redisConfLoc"
exe echo "databases 1" >> "$redisConfLoc"
exe systemctl restart redis exe systemctl restart redis
exe systemctl enable supervisor exe systemctl enable supervisor
@@ -78,6 +76,10 @@ step_6() {
} }
redisConfLoc="/etc/redis/redis.conf" redisConfLoc="/etc/redis/redis.conf"
redisConf="\
maxmemory-policy allkeys-lru
save \"\"
databases 1"
supervisorFileLoc="/etc/supervisor/conf.d/mayan.conf" supervisorFileLoc="/etc/supervisor/conf.d/mayan.conf"
supervisorFile="\ supervisorFile="\
[supervisord] [supervisord]
@@ -159,5 +161,21 @@ step_22() {
echo " e.g. psql -h 127.0.0.1 -U mayan -d mayan -W -f 2018-06-07_18-10-56.sql" echo " e.g. psql -h 127.0.0.1 -U mayan -d mayan -W -f 2018-06-07_18-10-56.sql"
} }
VERSION_SEQREV=2 # Read postgres database information dbname/user/pass if empty
readDatabaseInfos() {
if [ "$postgresDb" == "" ] ; then
read -p "Enter postgres database name: " postgresDb
endCheckEmpty postgresDb "database"
fi
if [ "$postgresUser" == "" ] ; then
read -p "Enter postgres user name: " postgresUser
endCheckEmpty postgresUser "user name"
fi
if [ "$postgresPass" == "" ] ; then
read -p "Enter postgres password: " postgresPass
endCheckEmpty postgresPass "password"
fi
}
VERSION_SEQREV=3
. sequencer.sh . sequencer.sh

View File

@@ -26,4 +26,7 @@ step_4() {
echo "[ WARN ] Configuration already exists. Doing nothing" echo "[ WARN ] Configuration already exists. Doing nothing"
fi fi
} }
VERSION_SEQREV=3
. sequencer.sh . sequencer.sh

View File

@@ -93,7 +93,7 @@ step_6() {
step_7_info() { echo "Create pixelfed (horzion) service"; } step_7_info() { echo "Create pixelfed (horzion) service"; }
step_7() { step_7() {
addConf "${horizonService}" "${horizonServiceLoc}" addConf -c "${horizonService}" "${horizonServiceLoc}"
exe systemctl daemon-reload exe systemctl daemon-reload
exe systemctl enable pixelfed.service exe systemctl enable pixelfed.service
exe service pixelfed start exe service pixelfed start
@@ -132,7 +132,7 @@ WantedBy=multi-user.target"
step_8_info() { echo "Nginx configuration"; } step_8_info() { echo "Nginx configuration"; }
step_8() { step_8() {
addConf "$nginxConfig" "$nginxConfigLoc" addConf -c "$nginxConfig" "$nginxConfigLoc"
exe ln -s "$nginxConfigLoc" "$nginxConfigEnable" exe ln -s "$nginxConfigLoc" "$nginxConfigEnable"
exe nginx -t exe nginx -t
saveReturn $? saveReturn $?
@@ -202,7 +202,7 @@ step_22() {
} }
# Sequence Revision # Sequence Revision
VERSION_SEQREV=2 VERSION_SEQREV=3
# Workaround when called from different directory # Workaround when called from different directory
# Not needed when path to sequencer is absolut # Not needed when path to sequencer is absolut

View File

@@ -19,7 +19,7 @@ step_1() {
saveReturn $? saveReturn $?
endReturn endReturn
addConf "$sourceEntry" "$sourceList" addConf -c "$sourceEntry" "$sourceList"
} }
step_2_info() { echo "Install/Upate $toolName"; } step_2_info() { echo "Install/Upate $toolName"; }
@@ -51,5 +51,6 @@ step_99() {
endReturn endReturn
} }
VERSION_SEQREV=2 VERSION_SEQREV=3
. sequencer.sh . sequencer.sh

View File

@@ -21,10 +21,10 @@ step_1() {
step_2_info() { echo "Basic nginx configuration for initial letsencrypt certificate creation"; } step_2_info() { echo "Basic nginx configuration for initial letsencrypt certificate creation"; }
step_2() { step_2() {
# Writing acme-challenge code snipped for certbot web root authentication # Writing acme-challenge code snipped for certbot web root authentication
addConf "$snippetLetsencrypt" "$snippetLetsencryptLoc" addConf -c "$snippetLetsencrypt" "$snippetLetsencryptLoc"
# Writing minimal default (see below) # Writing minimal default (see below)
addConf "$siteDefaultIp4" "$siteDefaultLoc" addConf -c "$siteDefaultIp4" "$siteDefaultLoc"
# try fix errors on first install attempt # try fix errors on first install attempt
# (possible missing ipv6 support on system) # (possible missing ipv6 support on system)
@@ -62,7 +62,7 @@ step_3() {
step_4_info() { echo "Mariadb configuration"; } step_4_info() { echo "Mariadb configuration"; }
step_4() { step_4() {
addConf "$mariadbConfig" "$mariadbConfigLoc" addConf -c "$mariadbConfig" "$mariadbConfigLoc"
echo -n "Restarting mysql ... " echo -n "Restarting mysql ... "
exe service mysql restart && echo "ok" exe service mysql restart && echo "ok"
@@ -107,8 +107,8 @@ date.timezone = Europe/Berlin"
step_6_info() { echo -e "Configuration of ${phpName} fpm and cli\n"; } step_6_info() { echo -e "Configuration of ${phpName} fpm and cli\n"; }
step_6() { step_6() {
addConf "$phpFpmConfig" "$phpFpmConfigLocation" addConf -c "$phpFpmConfig" "$phpFpmConfigLocation"
addConf "$phpCliConfig" "$phpCliConfigLocation" addConf -c "$phpCliConfig" "$phpCliConfigLocation"
echo -n "Restarting ${phpName} ... " echo -n "Restarting ${phpName} ... "
exe service ${phpName}-fpm restart && echo "ok" exe service ${phpName}-fpm restart && echo "ok"
@@ -183,5 +183,5 @@ step_12() {
exe mysql -u root -e 'FLUSH PRIVILEGES;' exe mysql -u root -e 'FLUSH PRIVILEGES;'
} }
VERSION_SEQREV=2 VERSION_SEQREV=3
. sequencer.sh . sequencer.sh

View File

@@ -22,10 +22,10 @@ step_1() {
step_2_info() { echo "Basic nginx configuration for initial letsencrypt certificate creation"; } step_2_info() { echo "Basic nginx configuration for initial letsencrypt certificate creation"; }
step_2() { step_2() {
# Writing acme-challenge code snipped for certbot web root authentication # Writing acme-challenge code snipped for certbot web root authentication
addConf "$snippetLetsencrypt" "$snippetLetsencryptLoc" addConf -c "$snippetLetsencrypt" "$snippetLetsencryptLoc"
# Writing minimal default (see below) # Writing minimal default (see below)
addConf "$siteDefaultIp4" "$siteDefaultLoc" addConf -c "$siteDefaultIp4" "$siteDefaultLoc"
# try fix errors on first install attempt # try fix errors on first install attempt
# (possible missing ipv6 support on system) # (possible missing ipv6 support on system)
@@ -63,7 +63,7 @@ step_3() {
step_4_info() { echo "Mariadb configuration"; } step_4_info() { echo "Mariadb configuration"; }
step_4() { step_4() {
addConf "$mariadbConfig" "$mariadbConfigLoc" addConf -c "$mariadbConfig" "$mariadbConfigLoc"
echo -n "Restarting mysql ... " echo -n "Restarting mysql ... "
exe service mysql restart && echo "ok" exe service mysql restart && echo "ok"
@@ -108,8 +108,8 @@ date.timezone = Europe/Berlin"
step_6_info() { echo -e "Configuration of ${phpName} fpm and cli\n"; } step_6_info() { echo -e "Configuration of ${phpName} fpm and cli\n"; }
step_6() { step_6() {
addConf "$phpFpmConfig" "$phpFpmConfigLocation" addConf -c "$phpFpmConfig" "$phpFpmConfigLocation"
addConf "$phpCliConfig" "$phpCliConfigLocation" addConf -c "$phpCliConfig" "$phpCliConfigLocation"
echo -n "Restarting ${phpName} ... " echo -n "Restarting ${phpName} ... "
exe service ${phpName}-fpm restart && echo "ok" exe service ${phpName}-fpm restart && echo "ok"
@@ -184,5 +184,6 @@ step_12() {
exe mysql -u root -e 'FLUSH PRIVILEGES;' exe mysql -u root -e 'FLUSH PRIVILEGES;'
} }
VERSION_SEQREV=2 VERSION_SEQREV=3
. sequencer.sh . sequencer.sh

View File

@@ -6,7 +6,7 @@
## Version information ## Version information
VERSION_REV=2 VERSION_REV=3
VERSION_MAJOR=0 VERSION_MAJOR=0
VERSION_MINOR=0 VERSION_MINOR=0
@@ -95,29 +95,51 @@ endReturn() {
fi fi
} }
# addConf <CONFIGTEXT> <CONFIGFILE> # addConf <CONF_MODE> <CONFIGTEXT> <CONFIGFILE>
# trying to write a file # trying to write a file
# if exists, one attempt is made to create bck file of it # if exists, one attempt is made to create bck file of it
# if all fails, a log file is created with the conflicts to be resolved by the user # if all fails, a log file is created with the conflicts to be resolved by the user
addConf() { addConf() {
echo -n "Writing $2 ... " local confMode=""
case "$1" in
-c) # create a new file
confMode="-c"
;;
-a) # append to existing file
confMode="-a"
;;
*) # default
echo "Parameter 1 (-a|-c) missing for addConf()"
exit 0;
;;
esac
echo -n "Writing $3 ... "
if [ "$DRY" -ne 0 ] ; then if [ "$DRY" -ne 0 ] ; then
echo "dry-run" echo "dry-run"
return 0; return 0;
fi fi
# try writing config directly # try writing config directly
if [ ! -f "$2" ] ; then if [ ! -f "$3" ] ; then
echo "$1" > "$2" if [ $confMode == "-c" ] ; then
echo "$2" > "$3"
else
echo "$2" >> "$3"
fi
echo "ok" echo "ok"
return 0 return 0
fi fi
# try backup existing config # try backup existing config
if [ ! -f "$2".bck ] ; then if [ ! -f "$3".bck ] ; then
cp -ar "$2" "$2".bck cp -ar "$3" "$3".bck
echo "$1" > "$2" if [ $confMode == "-c" ] ; then
echo "[WARN] Existing config saved to ${2}.bck" echo "$2" > "$3"
else
echo "$2" >> "$3"
fi
echo "[WARN] Existing config saved to ${3}.bck"
return 0 return 0
fi fi
@@ -127,11 +149,11 @@ addConf() {
echo -n "### " >> "$MISSING_CONF" echo -n "### " >> "$MISSING_CONF"
date >> "$MISSING_CONF" date >> "$MISSING_CONF"
fi fi
echo "#--- $2 ---" >> "$MISSING_CONF" echo "#--- $3 ---" >> "$MISSING_CONF"
echo "$1" >> "$MISSING_CONF" echo "$2" >> "$MISSING_CONF"
echo >> "$MISSING_CONF" echo >> "$MISSING_CONF"
echo "[WARN] Check $(realpath "$missingConf") for configuration conflicts ($2)" echo "[WARN] Check $(realpath "$missingConf") for configuration conflicts ($3)"
return 1 return 1
} }
@@ -249,7 +271,7 @@ createTemplate() {
echo " echo \"Doing something...\"" >> $TEMPLATE_NAME echo " echo \"Doing something...\"" >> $TEMPLATE_NAME
echo "}" >> $TEMPLATE_NAME echo "}" >> $TEMPLATE_NAME
echo >> $TEMPLATE_NAME echo >> $TEMPLATE_NAME
echo "VERSION_SEQREV=2" >> $TEMPLATE_NAME echo "VERSION_SEQREV=${VERSION_REV}" >> $TEMPLATE_NAME
echo ". $0" >> $TEMPLATE_NAME echo ". $0" >> $TEMPLATE_NAME
chmod +x $TEMPLATE_NAME chmod +x $TEMPLATE_NAME
@@ -396,7 +418,12 @@ main() {
showVersion showVersion
exit 1 exit 1
fi fi
# TODO exclude older versions if needed # exclude older versions if needed
if [ ! -z $VERSION_SEQREV ] && [ $VERSION_SEQREV -lt 3 ] ; then
echo "[ERROR] Unsupported sequence revision (addConf)"
showVersion
exit 1
fi
if [ -z $VERSION_SEQREV ] ; then if [ -z $VERSION_SEQREV ] ; then
echo -e "[WARNING] No sequence revision found. Trying anyway...\n"; echo -e "[WARNING] No sequence revision found. Trying anyway...\n";
fi fi