diff --git a/config/upgrade.sh b/config/upgrade.sh old mode 100755 new mode 100644 index 67a5008..564b3e3 --- a/config/upgrade.sh +++ b/config/upgrade.sh @@ -14,7 +14,7 @@ cd /opt/scodoc/Products/ScoDoc/config source config.sh source utils.sh -check_uid_root $0 +check_uid_root "$0" if [ -z "$SCODOC_UPGRADE_RUNNING" ] then @@ -23,7 +23,8 @@ fi # Upgrade svn working copy if possible svnver=$(svn --version --quiet) -if [[ ${svnver} > "1.7" ]] +# shellcheck disable=SC2072 +if [[ ${svnver} > "1.7" ]] then (cd "$SCODOC_DIR"; find . -name .svn -type d -exec dirname {} \; | xargs svn upgrade) fi @@ -63,7 +64,7 @@ CMD="curl --fail --connect-timeout 5 --silent http://scodoc.iutv.univ-paris13.fr #echo $CMD SVERSION="$(${CMD})" -if [ $? == 0 ]; then +if [ "$?" == 0 ]; then #echo "answer=${SVERSION}" echo "${SVERSION}" > "${SCODOC_VERSION_DIR}"/scodoc.sn else @@ -72,13 +73,13 @@ fi # Check that no Zope "access" file has been forgotten in the way: -if [ -e $SCODOC_DIR/../../access ] +if [ -e "$SCODOC_DIR"/../../access ] then - mv $SCODOC_DIR/../../access $SCODOC_DIR/../../access.bak + mv "$SCODOC_DIR"/../../access "$SCODOC_DIR"/../../access.bak fi # Fix some permissions which may have been altered in the way: -chsh -s /bin/sh $POSTGRES_USER # www-data, nologin in Debian 9 +chsh -s /bin/sh "$POSTGRES_USER" # www-data, nologin in Debian 9 chown root.www-data "$SCODOC_DIR" # important to create .pyc chmod 775 "${SCODOC_DIR}" chmod a+r "$SCODOC_DIR"/*.py @@ -119,7 +120,9 @@ then /opt/zope213/bin/pip install requests fi -/opt/zope213/bin/pip install --upgrade python-dateutil +# upgrade old dateutil (check version manually to speedup) +v=$(/opt/zope213/bin/python -c "import dateutil; print dateutil.__version__") +[[ "$v" < "2.8.1" ]] && /opt/zope213/bin/pip install --upgrade python-dateutil # Ensure www-data can duplicate databases (for dumps) su -c $'psql -c \'alter role "www-data" with CREATEDB;\'' "$POSTGRES_SUPERUSER" @@ -130,7 +133,7 @@ echo "Executing post-upgrade script..." "$SCODOC_DIR"/config/postupgrade.py echo "Executing post-upgrade database script..." -su -c "$SCODOC_DIR/config/postupgrade-db.py" $POSTGRES_USER +su -c "$SCODOC_DIR/config/postupgrade-db.py" "$POSTGRES_USER" # echo