2020-09-26 16:19:37 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-12-19 19:22:22 +01:00
|
|
|
# Upgrade ScoDoc installation using GIT
|
|
|
|
# GIT must be properly configured and have read access to ScoDoc repository
|
2020-09-26 16:19:37 +02:00
|
|
|
# This script STOP and RESTART ScoDoc and should be runned as root
|
|
|
|
#
|
|
|
|
# Upgrade also the Linux system using apt.
|
|
|
|
#
|
2020-12-19 19:22:22 +01:00
|
|
|
# Script for ScoDoc 8 (10)
|
2020-09-26 16:19:37 +02:00
|
|
|
#
|
2020-12-19 19:22:22 +01:00
|
|
|
# E. Viennet, sep 2013, mar 2017, jun 2019, aug 2020, dec 2020
|
2020-09-26 16:19:37 +02:00
|
|
|
|
2020-12-19 19:22:22 +01:00
|
|
|
cd /opt/scodoc/Products/ScoDoc/config || { echo "Invalid directory"; exit 1; }
|
2020-09-26 16:19:37 +02:00
|
|
|
source config.sh
|
|
|
|
source utils.sh
|
|
|
|
|
2020-12-19 19:22:22 +01:00
|
|
|
check_uid_root "$0"
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
if [ -z "$SCODOC_UPGRADE_RUNNING" ]
|
|
|
|
then
|
|
|
|
apt-get update && apt-get -y dist-upgrade
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Upgrade svn working copy if possible
|
|
|
|
svnver=$(svn --version --quiet)
|
|
|
|
if [[ ${svnver} > "1.7" ]]
|
|
|
|
then
|
|
|
|
(cd "$SCODOC_DIR"; find . -name .svn -type d -exec dirname {} \; | xargs svn upgrade)
|
|
|
|
fi
|
|
|
|
|
2020-12-05 17:29:26 +01:00
|
|
|
scodocctl stop
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
echo
|
2020-12-19 19:22:22 +01:00
|
|
|
echo "Using git to update $SCODOC_DIR..."
|
|
|
|
(cd "$SCODOC_DIR"; git checkout ScoDoc8; git pull origin master)
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
SVNVERSION=$(cd ..; svnversion)
|
|
|
|
|
|
|
|
if [ ! -e "${SCODOC_VERSION_DIR}" ]; then
|
|
|
|
mkdir -p "${SCODOC_VERSION_DIR}"
|
|
|
|
chown www-data.www-data "${SCODOC_VERSION_DIR}"
|
|
|
|
fi
|
|
|
|
if [ ! -e "${SCODOC_VERSION_DIR}"/scodoc.sn ]; then
|
|
|
|
if [ -e "$SCODOC_DIR"/config/scodoc.sn ]; then
|
|
|
|
# migrate from old scodoc installs
|
|
|
|
mv "$SCODOC_DIR"/config/scodoc.sn "${SCODOC_VERSION_DIR}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
SN=$(cat "$SCODOC_DIR"/config/scodoc.sn 2> /dev/null || cat "${SCODOC_VERSION_DIR}"/scodoc.sn)
|
|
|
|
if [ -e "$SCODOC_DIR"/config/scodoc.sn ] || [ -e "${SCODOC_VERSION_DIR}"/scodoc.sn ]
|
|
|
|
then
|
|
|
|
if [[ ! "${SN}" =~ ^[0-9].* ]]
|
|
|
|
then
|
|
|
|
SN='' # fix for invalid previous replies
|
|
|
|
fi
|
|
|
|
mode=upgrade
|
|
|
|
else
|
|
|
|
mode=install
|
|
|
|
fi
|
|
|
|
|
|
|
|
CMD="curl --fail --connect-timeout 5 --silent http://scodoc.iutv.univ-paris13.fr/scodoc-installmgr/version?mode=$mode\&svn=${SVNVERSION}\&sn=${SN}"
|
|
|
|
#echo $CMD
|
|
|
|
SVERSION="$(${CMD})"
|
|
|
|
|
|
|
|
if [ $? == 0 ]; then
|
|
|
|
#echo "answer=${SVERSION}"
|
|
|
|
echo "${SVERSION}" > "${SCODOC_VERSION_DIR}"/scodoc.sn
|
|
|
|
else
|
|
|
|
echo 'Warning: cannot connect to scodoc release server'
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# Check that no Zope "access" file has been forgotten in the way:
|
2020-12-19 19:22:22 +01:00
|
|
|
if [ -e "$SCODOC_DIR"/../../access ]
|
2020-09-26 16:19:37 +02:00
|
|
|
then
|
2020-12-19 19:22:22 +01:00
|
|
|
mv "$SCODOC_DIR"/../../access "$SCODOC_DIR"/../../access.bak
|
2020-09-26 16:19:37 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Fix some permissions which may have been altered in the way:
|
2020-12-19 19:22:22 +01:00
|
|
|
chsh -s /bin/sh "$POSTGRES_USER" # www-data, nologin in Debian 9
|
2020-09-26 16:19:37 +02:00
|
|
|
chown root.www-data "$SCODOC_DIR" # important to create .pyc
|
|
|
|
chmod 775 "${SCODOC_DIR}"
|
|
|
|
chmod a+r "$SCODOC_DIR"/*.py
|
|
|
|
|
|
|
|
chown -R root.www-data "$SCODOC_DIR"/config
|
|
|
|
chmod 775 "$SCODOC_DIR"/config
|
|
|
|
chmod a+rx "$SCODOC_DIR"/config/postupgrade-db.py
|
|
|
|
chmod a+r "$SCODOC_DIR"/config/scodocutils.py
|
|
|
|
|
|
|
|
chown -R root.www-data "$SCODOC_DIR"/misc
|
|
|
|
chmod -R a+r "$SCODOC_DIR"/misc
|
|
|
|
# depts dir:
|
|
|
|
if [ ! -e "${SCODOC_VAR_DIR}/config/depts" ]
|
|
|
|
then
|
|
|
|
mkdir "${SCODOC_VAR_DIR}/config/depts"
|
|
|
|
fi
|
|
|
|
# ScoDoc must be able to write to var directory:
|
|
|
|
chown -R www-data.www-data "${SCODOC_VAR_DIR}"
|
|
|
|
chmod -R u+w "${SCODOC_VAR_DIR}"
|
|
|
|
|
|
|
|
# Important to create .pyc:
|
|
|
|
chgrp -R www-data "${SCODOC_DIR}"/ZopeProducts
|
|
|
|
chmod -R g+w "${SCODOC_DIR}"/ZopeProducts
|
|
|
|
|
|
|
|
# Se recharge car ce fichier peut avoir change durant le svn up !
|
|
|
|
if [ -z "$SCODOC_UPGRADE_RUNNING" ]
|
|
|
|
then
|
|
|
|
export SCODOC_UPGRADE_RUNNING=1
|
|
|
|
./upgrade.sh
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Add some python modules:
|
|
|
|
"$SCODOC_DIR"/config/install_cal_modules.sh
|
|
|
|
/opt/zope213/bin/python -c "import requests" >& /dev/null
|
|
|
|
if [ $? -ne 0 ]
|
|
|
|
then
|
|
|
|
/opt/zope213/bin/pip install requests
|
|
|
|
fi
|
2020-12-15 08:35:44 +01:00
|
|
|
/opt/zope213/bin/python -c "import attrdict" >& /dev/null
|
|
|
|
if [ $? -ne 0 ]
|
|
|
|
then
|
|
|
|
/opt/zope213/bin/pip install attrdict
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check that local configuration file is installed
|
|
|
|
LOCAL_CONFIG_FILENAME="/opt/scodoc/var/scodoc/config/scodoc_local.py"
|
|
|
|
if [ ! -e "$LOCAL_CONFIG_FILENAME" ]
|
|
|
|
then
|
|
|
|
cp "$SCODOC_DIR"/config/scodoc_config_tmpl.py "$LOCAL_CONFIG_FILENAME"
|
|
|
|
chmod 600 "$LOCAL_CONFIG_FILENAME"
|
|
|
|
fi
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
# Ensure www-data can duplicate databases (for dumps)
|
|
|
|
su -c $'psql -c \'alter role "www-data" with CREATEDB;\'' "$POSTGRES_SUPERUSER"
|
|
|
|
#'
|
|
|
|
|
|
|
|
# post-upgrade scripts
|
|
|
|
echo "Executing post-upgrade script..."
|
|
|
|
"$SCODOC_DIR"/config/postupgrade.py
|
|
|
|
|
|
|
|
echo "Executing post-upgrade database script..."
|
2020-12-19 19:22:22 +01:00
|
|
|
su -c "$SCODOC_DIR/config/postupgrade-db.py" "$POSTGRES_USER"
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
echo
|
2020-12-05 17:29:26 +01:00
|
|
|
scodocctl start
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
|