forked from ScoDoc/DocScoDoc
WIP - shellchek config scripts
This commit is contained in:
parent
5f425da6c0
commit
f89fa0bf68
@ -1,4 +1,4 @@
|
||||
|
||||
#!/bin/bash
|
||||
# Version majeure de Debian (..., 9, 10)
|
||||
debian_version=$(cat /etc/debian_version)
|
||||
debian_version=${debian_version%%.*}
|
||||
@ -24,28 +24,28 @@ export POSTGRES_SUPERUSER=postgres
|
||||
export POSTGRES_USER=www-data
|
||||
|
||||
# psql command: if various versions installed, force the one we want:
|
||||
if [ ${debian_version} = "10" ]
|
||||
if [ "${debian_version}" = "10" ]
|
||||
then
|
||||
PSQL=/usr/lib/postgresql/11/bin/psql
|
||||
elif [ ${debian_version} = "9" ]
|
||||
elif [ "${debian_version}" = "9" ]
|
||||
then
|
||||
PSQL=/usr/lib/postgresql/9.6/bin/psql
|
||||
elif [ ${debian_version} = "8" ]
|
||||
elif [ "${debian_version}" = "8" ]
|
||||
then
|
||||
PSQL=/usr/lib/postgresql/9.4/bin/psql
|
||||
elif [ ${debian_version} = "7" ]
|
||||
elif [ "${debian_version}" = "7" ]
|
||||
then
|
||||
PSQL=/usr/lib/postgresql/9.1/bin/psql
|
||||
elif [ ${debian_version} = "5" ]
|
||||
elif [ "${debian_version}" = "5" ]
|
||||
then
|
||||
PSQL=/usr/lib/postgresql/8.3/bin/psql
|
||||
elif [ ${debian_version} = "6" ]
|
||||
elif [ "${debian_version}" = "6" ]
|
||||
then
|
||||
PSQL=/usr/lib/postgresql/8.4/bin/psql
|
||||
else
|
||||
PSQL=/usr/lib/postgresql/8.1/bin/psql
|
||||
fi
|
||||
|
||||
export PSQL
|
||||
|
||||
# tcp port for SQL server (under Debian 4, 5432 or 5433 for 8.1 if 7.4 also installed !)
|
||||
# Important note: if changed, you should probably also change it in
|
||||
@ -53,7 +53,7 @@ fi
|
||||
export POSTGRES_PORT=5432
|
||||
|
||||
# Utilise par le script de reset du mot de passe:
|
||||
if [ ${debian_version} -ge "7" ]
|
||||
if [ "${debian_version}" -ge "7" ]
|
||||
then
|
||||
export ZOPE_VERSION=2.13
|
||||
else
|
||||
|
@ -5,10 +5,10 @@
|
||||
source config.sh
|
||||
source utils.sh
|
||||
|
||||
check_uid_root $0
|
||||
check_uid_root "$0"
|
||||
|
||||
echo 'Installation du demarrage automatique de ScoDoc (systemd)'
|
||||
cp $SCODOC_DIR/config/etc/scodoc.service /etc/systemd/system
|
||||
cp "$SCODOC_DIR"/config/etc/scodoc.service /etc/systemd/system
|
||||
systemctl enable scodoc.service
|
||||
|
||||
echo "A partir de maintenant, utiliser"
|
||||
|
@ -11,6 +11,6 @@ source utils.sh
|
||||
echo 'Creating postgresql database'
|
||||
|
||||
# ---
|
||||
echo 'Creating postgresql database ' $db_name
|
||||
createdb -E UTF-8 -p $POSTGRES_PORT -O $POSTGRES_USER $db_name
|
||||
echo 'Creating postgresql database ' "$db_name"
|
||||
createdb -E UTF-8 -p "$POSTGRES_PORT" -O "$POSTGRES_USER" "$db_name"
|
||||
|
||||
|
@ -13,11 +13,11 @@
|
||||
source config.sh
|
||||
source utils.sh
|
||||
|
||||
check_uid_root $0
|
||||
check_uid_root "$0"
|
||||
|
||||
|
||||
echo -n "Nom du departement (un mot sans ponctuation, exemple \"Info\"): "
|
||||
read DEPT
|
||||
read -r DEPT
|
||||
|
||||
if [[ ! "$DEPT" =~ ^[A-Za-z0-9]+$ ]]
|
||||
then
|
||||
@ -31,9 +31,9 @@ export db_name=SCO$(to_upper "$DEPT")
|
||||
|
||||
cfg_pathname="${SCODOC_VAR_DIR}/config/depts/$DEPT".cfg
|
||||
|
||||
if [ -e $cfg_pathname ]
|
||||
if [ -e "$cfg_pathname" ]
|
||||
then
|
||||
echo 'Erreur: Il existe deja une configuration pour "'$DEPT'"'
|
||||
echo 'Erreur: Il existe deja une configuration pour "'"$DEPT"'"'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -48,11 +48,11 @@ su -c ./create_database.sh $POSTGRES_SUPERUSER
|
||||
su -c ./initialize_database.sh $POSTGRES_USER
|
||||
|
||||
# ----------------------- Enregistre fichier config
|
||||
echo "dbname="$db_name > $cfg_pathname
|
||||
echo "dbname=$db_name" > "$cfg_pathname"
|
||||
|
||||
# ----------------------- Force mise à jour
|
||||
echo -n "Voulez vous mettre a jour ScoDoc (tres recommande) ? (y/n) [y] "
|
||||
read ans
|
||||
read -r ans
|
||||
if [ "$(norm_ans "$ans")" != 'N' ]
|
||||
then
|
||||
(cd "$SCODOC_DIR/config"; ./upgrade.sh)
|
||||
|
@ -4,7 +4,7 @@
|
||||
# ScoDoc: creation de la base de donnees d'utilisateurs
|
||||
#
|
||||
# Ce script prend en charge la creation de la base de donnees
|
||||
# et doit être lancé par l'utilisateur unix root dans le repertoire .../config
|
||||
# et doit <EFBFBD>tre lanc<6E> par l'utilisateur unix root dans le repertoire .../config
|
||||
# ^^^^^^^^^^^^^^^^^^^^^
|
||||
# E. Viennet, Juin 2008
|
||||
#
|
||||
@ -12,7 +12,7 @@
|
||||
source config.sh
|
||||
source utils.sh
|
||||
|
||||
check_uid_root $0
|
||||
check_uid_root "$0"
|
||||
|
||||
# --- Ensure postgres user www-data exists
|
||||
init_postgres_user
|
||||
@ -21,8 +21,8 @@ db_name=SCOUSERS
|
||||
|
||||
echo 'Creating postgresql database ' $db_name
|
||||
|
||||
su -c "createdb -E UTF-8 -O $POSTGRES_USER -p $POSTGRES_PORT $db_name" $POSTGRES_SUPERUSER
|
||||
su -c "createdb -E UTF-8 -O $POSTGRES_USER -p $POSTGRES_PORT $db_name" "$POSTGRES_SUPERUSER"
|
||||
|
||||
echo 'Initializing tables in database ' $db_name
|
||||
echo su -c "$PSQL -U $POSTGRES_USER -p $POSTGRES_PORT $db_name < $SCODOC_DIR/misc/create_user_table.sql" $POSTGRES_USER
|
||||
su -c "$PSQL -U $POSTGRES_USER -p $POSTGRES_PORT $db_name < $SCODOC_DIR/misc/create_user_table.sql" $POSTGRES_USER
|
||||
echo 'Initializing tables in database ' "$db_name"
|
||||
echo su -c "$PSQL -U $POSTGRES_USER -p $POSTGRES_PORT $db_name < $SCODOC_DIR/misc/create_user_table.sql" "$POSTGRES_USER"
|
||||
su -c "$PSQL -U $POSTGRES_USER -p $POSTGRES_PORT $db_name < $SCODOC_DIR/misc/create_user_table.sql" "$POSTGRES_USER"
|
||||
|
@ -17,7 +17,7 @@
|
||||
source config.sh
|
||||
source utils.sh
|
||||
|
||||
check_uid_root $0
|
||||
check_uid_root "$0"
|
||||
|
||||
echo
|
||||
echo "Ce script supprime la base de donnees ScoDoc d'un departement"
|
||||
@ -26,7 +26,7 @@ echo "Attention: le departement doit au prealable avoir ete supprime via l'inter
|
||||
echo "faites le AVANT d'executer ce script !!!"
|
||||
echo
|
||||
echo -n "Nom du departement a supprimer (un mot sans ponctuation, exemple \"Info\"): "
|
||||
read DEPT
|
||||
read -r DEPT
|
||||
|
||||
if [[ ! "$DEPT" =~ ^[A-Za-z0-9]+$ ]]
|
||||
then
|
||||
@ -38,26 +38,26 @@ export DEPT
|
||||
|
||||
cfg_pathname="${SCODOC_VAR_DIR}/config/depts/$DEPT".cfg
|
||||
|
||||
if [ -e $cfg_pathname ]
|
||||
if [ -e "$cfg_pathname" ]
|
||||
then
|
||||
# arret de ScoDoc
|
||||
scodocctl stop
|
||||
|
||||
# suppression de la base postgres
|
||||
db_name=$(cat $cfg_pathname | sed '/^dbname=*/!d; s///;q')
|
||||
db_name=$(sed '/^dbname=*/!d; s///;q' < "$cfg_pathname")
|
||||
echo "suppression de la base postgres $db_name"
|
||||
su -c "dropdb $db_name" $POSTGRES_SUPERUSER || terminate "ne peux supprimer base de donnees $db_name"
|
||||
su -c "dropdb $db_name" "$POSTGRES_SUPERUSER" || terminate "ne peux supprimer base de donnees $db_name"
|
||||
# suppression du fichier de config
|
||||
/bin/rm -f $cfg_pathname || terminate "ne peux supprimer $cfg_pathname"
|
||||
/bin/rm -f "$cfg_pathname" || terminate "ne peux supprimer $cfg_pathname"
|
||||
# relance ScoDoc
|
||||
echo -n "Demarrer le serveur ScoDoc ? (y/n) [n]"
|
||||
read ans
|
||||
read -r ans
|
||||
if [ "$(norm_ans "$ans")" = 'Y' ]
|
||||
then
|
||||
scodocctl start
|
||||
fi
|
||||
exit 0
|
||||
else
|
||||
echo 'Erreur: pas de configuration trouvee pour "'$DEPT'"'
|
||||
echo 'Erreur: pas de configuration trouvee pour "'"$DEPT"'"'
|
||||
exit 1
|
||||
fi
|
||||
|
@ -6,7 +6,7 @@
|
||||
# Avec option:
|
||||
# -a : sauve aussi les bases de données
|
||||
#
|
||||
DEST_ADDRESS=emmanuel.viennet@univ-paris13.fr
|
||||
DEST_ADDRESS=emmanuel.viennet@gmail.com
|
||||
|
||||
INSTANCE_DIR=/opt/scodoc
|
||||
|
||||
@ -36,7 +36,7 @@ while getopts ":d:aunh" opt; do
|
||||
SEND_BY_MAIL=0
|
||||
;;
|
||||
d)
|
||||
DEPTS_TO_SAVE=$( join_by ' ' $DEPTS_TO_SAVE $OPTARG )
|
||||
DEPTS_TO_SAVE=$( join_by ' ' "$DEPTS_TO_SAVE" "$OPTARG" )
|
||||
;;
|
||||
h)
|
||||
echo "Diagnostic installation ScoDoc"
|
||||
@ -71,7 +71,7 @@ then
|
||||
apt-get install sharutils
|
||||
fi
|
||||
|
||||
mkdir $TMP
|
||||
mkdir "$TMP"
|
||||
|
||||
# Files to copy:
|
||||
FILES="/etc/hosts /etc/debian_version /etc/apt /etc/apache2"
|
||||
@ -91,33 +91,33 @@ echo "left in ${TMP}"
|
||||
# -------------------------------------
|
||||
|
||||
copy_log() {
|
||||
if [ -e $1 ]
|
||||
if [ -e "$1" ]
|
||||
then
|
||||
cp $1 $TMP/scodoc_logs/
|
||||
cp "$1" "$TMP"/scodoc_logs/
|
||||
fi
|
||||
}
|
||||
mkdir $TMP/scodoc_logs/
|
||||
copy_log /opt/scodoc/instance/log/event.log
|
||||
copy_log /opt/scodoc/instance/log/event.log.1
|
||||
copy_log /opt/scodoc/instance/log/notes.log
|
||||
copy_log /opt/scodoc/instance/log/notes.log.1
|
||||
mkdir "$TMP"/scodoc_logs/
|
||||
copy_log /opt/scodoc/log/event.log
|
||||
copy_log /opt/scodoc/log/event.log.1
|
||||
copy_log /opt/scodoc/log/notes.log
|
||||
copy_log /opt/scodoc/log/notes.log.1
|
||||
|
||||
|
||||
# -------------------------------------
|
||||
# Linux System Configuration
|
||||
# -------------------------------------
|
||||
|
||||
iptables -L > $TMP/iptables.out
|
||||
ip a > $TMP/ifconfig.out
|
||||
ps auxww > $TMP/ps.out
|
||||
df -h > $TMP/df.out
|
||||
dpkg -l > $TMP/dpkg.lst
|
||||
iptables -L > "$TMP"/iptables.out
|
||||
ip a > "$TMP"/ifconfig.out
|
||||
ps auxww > "$TMP"/ps.out
|
||||
df -h > "$TMP"/df.out
|
||||
dpkg -l > "$TMP"/dpkg.lst
|
||||
|
||||
(cd /opt/scodoc/instance/Products/ScoDoc; svn status > $TMP/svn.status)
|
||||
(cd /opt/scodoc/instance/Products/ScoDoc; svn diff > $TMP/svn.diff)
|
||||
(cd /opt/scodoc/Products/ScoDoc; svn status > "$TMP"/svn.status)
|
||||
(cd /opt/scodoc/Products/ScoDoc; svn diff > "$TMP"/svn.diff)
|
||||
|
||||
(cd /opt/scodoc/instance/Products/ScoDoc; svnversion > $TMP/svn.version)
|
||||
ls -laR /opt/scodoc/instance/Products/ScoDoc > $TMP/ls-laR
|
||||
(cd /opt/scodoc/Products/ScoDoc; svnversion > "$TMP"/svn.version)
|
||||
ls -laR /opt/scodoc/Products/ScoDoc > "$TMP"/ls-laR
|
||||
|
||||
|
||||
# -------------------------------------
|
||||
@ -126,7 +126,7 @@ ls -laR /opt/scodoc/instance/Products/ScoDoc > $TMP/ls-laR
|
||||
(su postgres -c "psql -l") > "${TMP}/psql-l.out"
|
||||
for dept in "${INSTANCE_DIR}"/var/scodoc/config/depts/*.cfg
|
||||
do
|
||||
cnx=$(cat $dept)
|
||||
cnx=$(cat "$dept")
|
||||
(su postgres -c "echo '\dt' | psql -d $cnx") > "${TMP}/psql-$(basename ${dept%%.*}).out"
|
||||
done
|
||||
|
||||
@ -137,14 +137,14 @@ done
|
||||
# copy files:
|
||||
for f in $FILES
|
||||
do
|
||||
cp -R $f $TMP
|
||||
cp -R "$f" "$TMP"
|
||||
done
|
||||
|
||||
|
||||
# -------------------------------------
|
||||
# Optionally save dept(s) database(s)
|
||||
# -------------------------------------
|
||||
DEPTS_TO_SAVE=$(echo ${DEPTS_TO_SAVE} | tr ' ' '\n' | sort | uniq)
|
||||
DEPTS_TO_SAVE=$(echo "${DEPTS_TO_SAVE}" | tr ' ' '\n' | sort | uniq)
|
||||
|
||||
# Dump database of a dept (eg "RT")
|
||||
function dump_dept_db {
|
||||
@ -176,10 +176,10 @@ fi
|
||||
# Archive all stuff to /tmp
|
||||
# -------------------------------------
|
||||
|
||||
tar cfz $TMP.tgz $TMP
|
||||
tar cfz "$TMP".tgz "$TMP"
|
||||
|
||||
echo
|
||||
echo "Fichier de diagnostic: $TMP.tgz"
|
||||
echo "Fichier de diagnostic: "$TMP".tgz"
|
||||
echo
|
||||
|
||||
# If no mail, stop here
|
||||
@ -197,9 +197,9 @@ fi
|
||||
|
||||
#requires: basename,date,md5sum,sed,sendmail,uuencode
|
||||
function fappend {
|
||||
echo "$2">>$1;
|
||||
echo "$2">>"$1";
|
||||
}
|
||||
YYYYMMDD=`date +%Y%m%d`
|
||||
YYYYMMDD=$(date +%Y%m%d)
|
||||
|
||||
# CHANGE THESE
|
||||
TOEMAIL=$DEST_ADDRESS
|
||||
@ -212,45 +212,45 @@ MIMETYPE="application/gnutar" #if not sure, use http://www.webmaster-toolkit.com
|
||||
|
||||
# DON'T CHANGE ANYTHING BELOW
|
||||
TMP="/tmp/tmpfil_123"$RANDOM;
|
||||
BOUNDARY=`date +%s|md5sum`
|
||||
BOUNDARY=$(date +%s|md5sum)
|
||||
BOUNDARY=${BOUNDARY:0:32}
|
||||
FILENAME=`basename $ATTACHMENT`
|
||||
FILENAME=$(basename "$ATTACHMENT")
|
||||
|
||||
rm -rf $TMP;
|
||||
cat $ATTACHMENT|uuencode --base64 $FILENAME>$TMP;
|
||||
sed -i -e '1,1d' -e '$d' $TMP;#removes first & last lines from $TMP
|
||||
DATA=`cat $TMP`
|
||||
rm -rf "$TMP"
|
||||
uuencode --base64 "$FILENAME" < "$ATTACHMENT" >"$TMP"
|
||||
sed -i -e '1,1d' -e '$d' "$TMP"; #removes first & last lines from "$TMP"
|
||||
DATA=$(cat "$TMP")
|
||||
|
||||
rm -rf $TMP;
|
||||
fappend $TMP "From: $FREMAIL";
|
||||
fappend $TMP "To: $TOEMAIL";
|
||||
fappend $TMP "Reply-To: $FREMAIL";
|
||||
fappend $TMP "Subject: $SUBJECT";
|
||||
fappend $TMP "Content-Type: multipart/mixed; boundary=\""$BOUNDARY"\"";
|
||||
fappend $TMP "";
|
||||
fappend $TMP "This is a MIME formatted message. If you see this text it means that your";
|
||||
fappend $TMP "email software does not support MIME formatted messages.";
|
||||
fappend $TMP "";
|
||||
fappend $TMP "--$BOUNDARY";
|
||||
fappend $TMP "Content-Type: text/plain; charset=ISO-8859-1; format=flowed";
|
||||
fappend $TMP "Content-Transfer-Encoding: 7bit";
|
||||
fappend $TMP "Content-Disposition: inline";
|
||||
fappend $TMP "";
|
||||
fappend $TMP "$MSGBODY";
|
||||
fappend $TMP "";
|
||||
fappend $TMP "";
|
||||
fappend $TMP "--$BOUNDARY";
|
||||
fappend $TMP "Content-Type: $MIMETYPE; name=\"$FILENAME\"";
|
||||
fappend $TMP "Content-Transfer-Encoding: base64";
|
||||
fappend $TMP "Content-Disposition: attachment; filename=\"$FILENAME\";";
|
||||
fappend $TMP "";
|
||||
fappend $TMP "$DATA";
|
||||
fappend $TMP "";
|
||||
fappend $TMP "";
|
||||
fappend $TMP "--$BOUNDARY--";
|
||||
fappend $TMP "";
|
||||
fappend $TMP "";
|
||||
#cat $TMP>out.txt
|
||||
cat $TMP|sendmail -t -f none@example.com;
|
||||
rm $TMP;
|
||||
rm -rf "$TMP";
|
||||
fappend "$TMP" "From: $FREMAIL";
|
||||
fappend "$TMP" "To: $TOEMAIL";
|
||||
fappend "$TMP" "Reply-To: $FREMAIL";
|
||||
fappend "$TMP" "Subject: $SUBJECT";
|
||||
fappend "$TMP" "Content-Type: multipart/mixed; boundary=\""$BOUNDARY"\"";
|
||||
fappend "$TMP" "";
|
||||
fappend "$TMP" "This is a MIME formatted message. If you see this text it means that your";
|
||||
fappend "$TMP" "email software does not support MIME formatted messages.";
|
||||
fappend "$TMP" "";
|
||||
fappend "$TMP" "--$BOUNDARY";
|
||||
fappend "$TMP" "Content-Type: text/plain; charset=ISO-8859-1; format=flowed";
|
||||
fappend "$TMP" "Content-Transfer-Encoding: 7bit";
|
||||
fappend "$TMP" "Content-Disposition: inline";
|
||||
fappend "$TMP" "";
|
||||
fappend "$TMP" "$MSGBODY";
|
||||
fappend "$TMP" "";
|
||||
fappend "$TMP" "";
|
||||
fappend "$TMP" "--$BOUNDARY";
|
||||
fappend "$TMP" "Content-Type: $MIMETYPE; name=\"$FILENAME\"";
|
||||
fappend "$TMP" "Content-Transfer-Encoding: base64";
|
||||
fappend "$TMP" "Content-Disposition: attachment; filename=\"$FILENAME\";";
|
||||
fappend "$TMP" "";
|
||||
fappend "$TMP" "$DATA";
|
||||
fappend "$TMP" "";
|
||||
fappend "$TMP" "";
|
||||
fappend "$TMP" "--$BOUNDARY--";
|
||||
fappend "$TMP" "";
|
||||
fappend "$TMP" "";
|
||||
#cat "$TMP">out.txt
|
||||
cat "$TMP"|sendmail -t -f none@example.com;
|
||||
rm "$TMP";
|
||||
|
||||
|
@ -15,15 +15,15 @@ then
|
||||
fi
|
||||
|
||||
|
||||
echo "Changing to directory " $SCODOC_DIR/config
|
||||
cd $SCODOC_DIR/config
|
||||
echo "Changing to directory " "$SCODOC_DIR"/config
|
||||
cd "$SCODOC_DIR"/config || { echo "directory does not exist"; exit 1; }
|
||||
|
||||
echo "Stopping ScoDoc..."
|
||||
scodocctl stop
|
||||
|
||||
# DROITS
|
||||
echo -n "Verification des droits: proprietaire www-data ? (y/n) [y] "
|
||||
read ans
|
||||
read -r ans
|
||||
if [ "$(norm_ans "$ans")" != 'N' ]
|
||||
then
|
||||
echo 'changing owner to www-data'
|
||||
@ -31,7 +31,7 @@ then
|
||||
fi
|
||||
|
||||
echo -n 'Suppression des backups des sources (*~) ? (y/n) [y] '
|
||||
read ans
|
||||
read -r ans
|
||||
if [ "$(norm_ans "$ans")" != 'N' ]
|
||||
then
|
||||
/bin/rm -f ../*~ ../*/*~
|
||||
@ -40,7 +40,7 @@ fi
|
||||
|
||||
# SVN
|
||||
echo -n "svn update ? (y/n) [y] "
|
||||
read ans
|
||||
read -r ans
|
||||
if [ "$(norm_ans "$ans")" != 'N' ]
|
||||
then
|
||||
echo 'Updating from SVN...'
|
||||
@ -50,7 +50,7 @@ fi
|
||||
|
||||
# DEPARTEMENTS (maintenant inutile car dans /var)
|
||||
echo -n "Supprimer les (anciennes) configs de departements ? (y/n) [y] "
|
||||
read ans
|
||||
read -r ans
|
||||
if [ "$(norm_ans "$ans")" != 'N' ]
|
||||
then
|
||||
echo "moving " depts/*.cfg "to /tmp"
|
||||
@ -59,7 +59,7 @@ fi
|
||||
|
||||
# .../var/
|
||||
echo -n "Supprimer et recréer .../var (archives, photos, configs, ...) ? (y/n) [y] "
|
||||
read ans
|
||||
read -r ans
|
||||
if [ "$(norm_ans "$ans")" != 'N' ]
|
||||
then
|
||||
echo "moving ../../../var/scodoc to /tmp"
|
||||
@ -73,7 +73,7 @@ fi
|
||||
|
||||
# LOGS ZOPE
|
||||
echo -n "Effacer les logs de Zope et ScoDoc ? (y/n) [y] "
|
||||
read ans
|
||||
read -r ans
|
||||
if [ "$(norm_ans "$ans")" != 'N' ]
|
||||
then
|
||||
(cd ../../../log/; ./purge)
|
||||
@ -81,7 +81,7 @@ fi
|
||||
|
||||
# IMAGE Data.fs
|
||||
echo -n "Recopier le Data.fs original ? (y/n) [y] "
|
||||
read ans
|
||||
read -r ans
|
||||
if [ "$(norm_ans "$ans")" != 'N' ]
|
||||
then
|
||||
echo "moving Data.fs to /tmp"
|
||||
|
@ -8,15 +8,16 @@
|
||||
source config.sh
|
||||
source utils.sh
|
||||
|
||||
if [ $(id -nu) != $POSTGRES_USER ]
|
||||
if [ "$(id -nu)" != "$POSTGRES_USER" ]
|
||||
then
|
||||
echo "$0: script must be runned as user $POSTGRES_USER"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo 'Initializing tables in database ' $db_name
|
||||
$PSQL -U $POSTGRES_USER -p $POSTGRES_PORT $db_name -f $SCODOC_DIR/misc/createtables.sql
|
||||
# shellcheck disable=SC2154
|
||||
echo 'Initializing tables in database ' "$db_name"
|
||||
$PSQL -U "$POSTGRES_USER" -p "$POSTGRES_PORT" "$db_name" -f "$SCODOC_DIR"/misc/createtables.sql
|
||||
|
||||
|
||||
# Set DeptName in preferences:
|
||||
echo "insert into sco_prefs (name, value) values ('DeptName', '"${DEPT}\'\) | $PSQL -U $POSTGRES_USER -p $POSTGRES_PORT $db_name
|
||||
echo "insert into sco_prefs (name, value) values ('DeptName', '"${DEPT}\'\) | $PSQL -U "$POSTGRES_USER" -p "$POSTGRES_PORT" "$db_name"
|
@ -13,16 +13,14 @@ source utils.sh
|
||||
|
||||
check_uid_root $0
|
||||
|
||||
PYTHON=/opt/zope213/bin/python
|
||||
|
||||
# ------------ Safety checks
|
||||
if [ ${debian_version} != "10" ]
|
||||
if [ "${debian_version}" != "10" ]
|
||||
then
|
||||
echo "Version du systeme Linux Debian incompatible"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ $(arch) != "x86_64" ]
|
||||
if [ "$(arch)" != "x86_64" ]
|
||||
then
|
||||
echo "Version du systeme Linux Debian incompatible (pas X86 64 bits)"
|
||||
exit 1
|
||||
@ -30,8 +28,8 @@ fi
|
||||
|
||||
# ------------ Permissions & directories
|
||||
# source dir should be writable by scodoc to write bytecode files
|
||||
chgrp www-data $SCODOC_DIR $SCODOC_DIR/ZopeProducts/*
|
||||
chmod g+w $SCODOC_DIR $SCODOC_DIR/ZopeProducts/*
|
||||
chgrp www-data "$SCODOC_DIR" "$SCODOC_DIR"/ZopeProducts/*
|
||||
chmod g+w "$SCODOC_DIR" "$SCODOC_DIR"/ZopeProducts/*
|
||||
|
||||
chgrp -R www-data "${SCODOC_VAR_DIR}"/photos
|
||||
chmod -R g+w "${SCODOC_VAR_DIR}"/photos
|
||||
@ -54,8 +52,8 @@ fi
|
||||
|
||||
for locname in en_US.UTF-8 en_US.ISO-8859-15 en_US.ISO-8859-1
|
||||
do
|
||||
outname=$(echo ${locname//-/} | tr '[A-Z]' '[a-z]')
|
||||
if [ $(locale -a | egrep -i ^${outname}$ | wc -l) -lt 1 ]
|
||||
outname=$(echo ${locname//-/} | tr 'A-Z' 'a-z')
|
||||
if [ "$(locale -a | grep -E -i ^${outname}$ | wc -l)" -lt 1 ]
|
||||
then
|
||||
echo adding $locname
|
||||
echo "$locname ${locname##*.}" >> /etc/locale.gen
|
||||
@ -87,7 +85,7 @@ apt-get -y install postgresql
|
||||
apt-get -y install graphviz
|
||||
|
||||
# ------------ INSTALL DES EXTENSIONS PYTHON (2.7)
|
||||
|
||||
# XXX to fix: pip in our env
|
||||
apt-get -y install python-docutils
|
||||
apt-get -y install python-jaxml
|
||||
apt-get -y install python-psycopg2
|
||||
@ -97,20 +95,21 @@ apt-get -y install python-cracklib # was python-crack
|
||||
apt-get -y install python-icalendar
|
||||
apt-get -y install python-requests
|
||||
|
||||
# XXX to fix: mx not needed anymore !
|
||||
apt-get -y install python-egenix-mxtools python-egenix-mxdatetime
|
||||
|
||||
|
||||
# ------------
|
||||
SVNVERSION=$(cd ..; svnversion)
|
||||
SVERSION=$(curl --silent http://scodoc.iutv.univ-paris13.fr/scodoc-installmgr/version?mode=install\&svn=$SVNVERSION)
|
||||
echo $SVERSION > "${SCODOC_VERSION_DIR}/scodoc.sn"
|
||||
SVERSION=$(curl --silent http://scodoc.iutv.univ-paris13.fr/scodoc-installmgr/version?mode=install\&svn="$SVNVERSION")
|
||||
echo "$SVERSION" > "${SCODOC_VERSION_DIR}/scodoc.sn"
|
||||
|
||||
|
||||
# ------------ POSTFIX
|
||||
echo
|
||||
echo "ScoDoc a besoin de pouvoir envoyer des messages par mail."
|
||||
echo -n "Voulez vous configurer la messagerie (tres recommande) ? (y/n) [y] "
|
||||
read ans
|
||||
read -r ans
|
||||
if [ "$(norm_ans "$ans")" != 'N' ]
|
||||
then
|
||||
apt-get -y install postfix
|
||||
@ -120,7 +119,7 @@ fi
|
||||
echo
|
||||
echo "Le firewall aide a proteger votre serveur d'intrusions indesirables."
|
||||
echo -n "Voulez vous configurer un firewall minimal (ufw) ? (y/n) [n] "
|
||||
read ans
|
||||
read -r ans
|
||||
if [ "$(norm_ans "$ans")" = 'Y' ]
|
||||
then
|
||||
echo 'Installation du firewall IP ufw (voir documentation Debian)'
|
||||
@ -145,16 +144,16 @@ a2enmod rewrite
|
||||
echo
|
||||
echo "La configuration du serveur web va modifier votre installation Apache pour supporter ScoDoc."
|
||||
echo -n "Voulez vous configurer le serveur web Apache maintenant (tres conseille) ? (y/n) [y] "
|
||||
read ans
|
||||
read -r ans
|
||||
if [ "$(norm_ans "$ans")" != 'N' ]
|
||||
then
|
||||
echo "Configuration d'Apache"
|
||||
server_name=""
|
||||
while [ -z $server_name ]
|
||||
while [ -z "$server_name" ]
|
||||
do
|
||||
echo "Le nom de votre serveur doit normalement etre connu dans le DNS."
|
||||
echo -n "Nom complet de votre serveur (exemple: notes.univ.fr): "
|
||||
read server_name
|
||||
read -r server_name
|
||||
done
|
||||
# --- CERTIFICATS AUTO-SIGNES
|
||||
echo
|
||||
@ -162,7 +161,7 @@ then
|
||||
echo "auto-signes, qui ne seront pas reconnus comme de confiance"
|
||||
echo "par les navigateurs, mais offrent une certaine securite."
|
||||
echo -n 'Voulez vous generer des certificats ssl auto-signes ? (y/n) [y] '
|
||||
read ans
|
||||
read -r ans
|
||||
if [ "$(norm_ans "$ans")" != 'N' ]
|
||||
then
|
||||
# attention: utilise dans scodoc-site-ssl.orig
|
||||
@ -178,7 +177,7 @@ then
|
||||
fi
|
||||
# ---
|
||||
echo 'generation de /etc/apache2/sites-available/scodoc-site-ssl'
|
||||
cat $SCODOC_DIR/config/etc/scodoc-site-ssl-apache2.4.orig | sed -e "s:YOUR\.FULL\.HOST\.NAME:$server_name:g" > /etc/apache2/sites-available/scodoc-site-ssl.conf
|
||||
cat "$SCODOC_DIR"/config/etc/scodoc-site-ssl-apache2.4.orig | sed -e "s:YOUR\.FULL\.HOST\.NAME:$server_name:g" > /etc/apache2/sites-available/scodoc-site-ssl.conf
|
||||
echo 'activation du site...'
|
||||
a2ensite scodoc-site-ssl
|
||||
|
||||
@ -188,7 +187,7 @@ then
|
||||
then
|
||||
mv $fn $fn.bak
|
||||
fi
|
||||
cp $SCODOC_DIR/config/etc/scodoc-site.orig $fn
|
||||
cp "$SCODOC_DIR"/config/etc/scodoc-site.orig $fn
|
||||
|
||||
if [ -z "$(grep Listen /etc/apache2/ports.conf | grep 443)" ]
|
||||
then
|
||||
@ -222,7 +221,7 @@ if [ "$(norm_ans "$ans")" != 'N' ]
|
||||
then
|
||||
# ScoDoc 7.19+ uses systemd
|
||||
echo 'Installation du demarrage automatique de ScoDoc (systemd)'
|
||||
cp $SCODOC_DIR/config/etc/scodoc.service /etc/systemd/system
|
||||
cp "$SCODOC_DIR"/config/etc/scodoc.service /etc/systemd/system
|
||||
systemctl enable scodoc.service
|
||||
fi
|
||||
|
||||
@ -233,8 +232,8 @@ echo -n "Mises a jour hebdomadaires (tres recommande) ? (y/n) [y] "
|
||||
read ans
|
||||
if [ "$(norm_ans "$ans")" != 'N' ]
|
||||
then
|
||||
cp $SCODOC_DIR/config/etc/scodoc-updater.service /etc/systemd/system
|
||||
cp $SCODOC_DIR/config/etc/scodoc-updater.timer /etc/systemd/system
|
||||
cp "$SCODOC_DIR"/config/etc/scodoc-updater.service /etc/systemd/system
|
||||
cp "$SCODOC_DIR"/config/etc/scodoc-updater.timer /etc/systemd/system
|
||||
systemctl enable scodoc-updater.timer
|
||||
systemctl start scodoc-updater.timer
|
||||
fi
|
||||
|
@ -8,7 +8,7 @@ PG_DUMPFILE=$1
|
||||
# Check locale of installation. If invalid, reinitialize all system
|
||||
|
||||
is_latin1=$(psql -l | grep postgres | grep iso88591 | wc -l)
|
||||
if [ $is_latin1 -gt 1 ]
|
||||
if [ "$is_latin1" -gt 1 ]
|
||||
then
|
||||
echo "Recreating postgres cluster using UTF-8"
|
||||
|
||||
@ -20,8 +20,8 @@ fi
|
||||
|
||||
# Drop all current ScoDoc databases, if any:
|
||||
for f in $(psql -l --no-align --field-separator . | grep SCO | cut -f 1 -d.); do
|
||||
echo dropping $f
|
||||
dropdb $f
|
||||
echo dropping "$f"
|
||||
dropdb "$f"
|
||||
done
|
||||
echo "Restoring postgres data..."
|
||||
psql -f "$PG_DUMPFILE" postgres
|
||||
|
@ -15,7 +15,7 @@ SCODOC_DIR="${INSTANCE_DIR}/Products/ScoDoc"
|
||||
SCODOC_VAR_DIR="${INSTANCE_DIR}/var/scodoc"
|
||||
|
||||
source utils.sh
|
||||
check_uid_root $0
|
||||
check_uid_root "$0"
|
||||
|
||||
# Safety check
|
||||
echo "Ce script va remplacer les donnees de votre installation ScoDoc par celles"
|
||||
@ -28,7 +28,7 @@ echo
|
||||
echo "TOUTES LES BASES POSTGRESQL SERONT EFFACEES !!!"
|
||||
echo
|
||||
echo -n "Voulez vous poursuivre cette operation ? (y/n) [n]"
|
||||
read ans
|
||||
read -r ans
|
||||
if [ ! "$(norm_ans "$ans")" = 'Y' ]
|
||||
then
|
||||
echo "Annulation"
|
||||
@ -57,7 +57,7 @@ then
|
||||
echo "Opening tgz archive..."
|
||||
tmp=$(mktemp -d)
|
||||
chmod a+rx "$tmp"
|
||||
cd "$tmp"
|
||||
cd "$tmp" || { echo "Fatal error: directory not available"; exit 1; }
|
||||
tar xfz "$SRC"
|
||||
SRC=$(ls -1d "$tmp"/*)
|
||||
IS_TMP=1
|
||||
@ -132,11 +132,11 @@ chmod -R 775 "$SCODOC_DIR"
|
||||
# Remove tmp directory
|
||||
if [ $IS_TMP = "1" ]
|
||||
then
|
||||
rm -rf $tmp
|
||||
rm -rf "$tmp"
|
||||
fi
|
||||
|
||||
# Mise a jour BD ScoDoc
|
||||
cd $SCODOC_DIR/config
|
||||
cd "$SCODOC_DIR"/config || { echo "Fatal error: invalid directory"; exit 2; }
|
||||
./upgrade.sh
|
||||
|
||||
#
|
||||
|
@ -10,6 +10,8 @@
|
||||
#
|
||||
source utils.sh
|
||||
|
||||
check_uid_root "$0"
|
||||
|
||||
# Destination directory
|
||||
if [ ! $# -eq 1 ]
|
||||
then
|
||||
@ -34,9 +36,6 @@ fi
|
||||
INSTANCE_DIR=/opt/scodoc
|
||||
SCODOC_DIR="$INSTANCE_DIR/Products/ScoDoc"
|
||||
|
||||
source utils.sh
|
||||
check_uid_root $0
|
||||
|
||||
echo "Stopping ScoDoc..."
|
||||
scodocctl stop
|
||||
|
||||
@ -46,7 +45,7 @@ chown postgres "$DEST"
|
||||
su -c "pg_dumpall > \"$DEST\"/scodoc.dump.txt" postgres
|
||||
if [ ! $? -eq 0 ]
|
||||
then
|
||||
echo "Error dumping postgresql database\nPlease check that SQL server is running\nAborting."
|
||||
printf "Error dumping postgresql database\nPlease check that SQL server is running\nAborting.\n"
|
||||
exit 1
|
||||
fi
|
||||
chown root "$DEST"
|
||||
@ -57,7 +56,7 @@ cp -rp "$INSTANCE_DIR/var" "$DEST"
|
||||
|
||||
# Depts db config (now in .../var)
|
||||
shopt -s nullglob
|
||||
if [ ! -z "$(echo ${SCODOC_DIR}/config/depts/*.cfg)" ]
|
||||
if [ -n "$(echo ${SCODOC_DIR}/config/depts/*.cfg)" ]
|
||||
then
|
||||
echo "Copying legacy depts configs..."
|
||||
cp -rp "$SCODOC_DIR/config/depts" "$DEST"
|
||||
|
@ -4,7 +4,7 @@
|
||||
# ScoDoc: reglage du mot de passe admin Zope
|
||||
# (in Zope terminology, an emergency user)
|
||||
#
|
||||
# Doit être lancé par l'utilisateur unix root dans le repertoire .../config
|
||||
# Doit <EFBFBD>tre lanc<6E> par l'utilisateur unix root dans le repertoire .../config
|
||||
# ^^^^^^^^^^^^^^^^^^^^^
|
||||
# E. Viennet, Juin 2008, Jul 2019
|
||||
#
|
||||
@ -22,14 +22,14 @@ fi
|
||||
echo "Creation d'un utilisateur d'urgence pour ScoDoc"
|
||||
echo "(utile en cas de perte de votre mot de passe admin)"
|
||||
|
||||
if [ ${debian_version} != "10" ]
|
||||
if [ "${debian_version}" != "10" ]
|
||||
then
|
||||
mdir=/opt/zope213/lib/python2.7/site-packages/Zope2-2.13.21-py2.7.egg/Zope2/utilities
|
||||
else
|
||||
mdir=/opt/zope213/lib/python2.7/site-packages/Zope2/utilities
|
||||
fi
|
||||
|
||||
python $mdir/zpasswd.py $SCODOC_DIR/../../access
|
||||
python $mdir/zpasswd.py "$SCODOC_DIR"/../../access
|
||||
|
||||
echo
|
||||
echo "redemarrer scodoc pour prendre en compte le mot de passe"
|
||||
|
@ -1,20 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Upgrade ScoDoc installation using SVN
|
||||
# SVN must be properly configured and have read access to ScoDoc repository
|
||||
# Upgrade ScoDoc installation using GIT
|
||||
# GIT must be properly configured and have read access to ScoDoc repository
|
||||
# This script STOP and RESTART ScoDoc and should be runned as root
|
||||
#
|
||||
# Upgrade also the Linux system using apt.
|
||||
#
|
||||
# Script for ScoDoc 7 (Debian 7, 8, 9, 10)
|
||||
# Script for ScoDoc 8 (10)
|
||||
#
|
||||
# E. Viennet, sep 2013, mar 2017, jun 2019, aug 2020
|
||||
# E. Viennet, sep 2013, mar 2017, jun 2019, aug 2020, dec 2020
|
||||
|
||||
cd /opt/scodoc/Products/ScoDoc/config
|
||||
cd /opt/scodoc/Products/ScoDoc/config || { echo "Invalid directory"; exit 1; }
|
||||
source config.sh
|
||||
source utils.sh
|
||||
|
||||
check_uid_root $0
|
||||
check_uid_root "$0"
|
||||
|
||||
if [ -z "$SCODOC_UPGRADE_RUNNING" ]
|
||||
then
|
||||
@ -31,8 +31,8 @@ fi
|
||||
scodocctl stop
|
||||
|
||||
echo
|
||||
echo "Using SVN to update $SCODOC_DIR..."
|
||||
(cd "$SCODOC_DIR"; svn update)
|
||||
echo "Using git to update $SCODOC_DIR..."
|
||||
(cd "$SCODOC_DIR"; git checkout ScoDoc8; git pull origin master)
|
||||
|
||||
SVNVERSION=$(cd ..; svnversion)
|
||||
|
||||
@ -72,13 +72,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
|
||||
@ -141,7 +141,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
|
||||
|
@ -1,17 +1,17 @@
|
||||
|
||||
#!/bin/bash
|
||||
# Misc utilities for ScoDoc install shell scripts
|
||||
|
||||
to_lower() {
|
||||
echo $1 | tr "[:upper:]" "[:lower:]"
|
||||
echo "$1" | tr "[:upper:]" "[:lower:]"
|
||||
}
|
||||
|
||||
to_upper() {
|
||||
echo $1 | tr "[:lower:]" "[:upper:]"
|
||||
echo "$1" | tr "[:lower:]" "[:upper:]"
|
||||
}
|
||||
|
||||
norm_ans() {
|
||||
x=$(to_upper $1 | tr O Y)
|
||||
echo ${x:0:1}
|
||||
x=$(to_upper "$1" | tr O Y)
|
||||
echo "${x:0:1}"
|
||||
}
|
||||
|
||||
check_uid_root() {
|
||||
@ -44,7 +44,7 @@ scodocctl() {
|
||||
systemctl $1 scodoc
|
||||
else
|
||||
echo "(using legacy SystemV)"
|
||||
/etc/init.d/scodoc $1
|
||||
/etc/init.d/scodoc "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ init_postgres_user() { # run as root
|
||||
then
|
||||
# add database user
|
||||
echo "Creating postgresql user $POSTGRES_USER"
|
||||
su -c "createuser -p $POSTGRES_PORT --no-superuser --no-createdb --no-adduser --no-createrole ${POSTGRES_USER}" $POSTGRES_SUPERUSER
|
||||
su -c "createuser -p $POSTGRES_PORT --no-superuser --no-createdb --no-adduser --no-createrole ${POSTGRES_USER}" "$POSTGRES_SUPERUSER"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -69,8 +69,8 @@ gen_passwd() {
|
||||
password=""
|
||||
while [ "$n" -le "$PASSWORD_LENGTH" ]
|
||||
do
|
||||
password="$password${ALLOWABLE_ASCII:$(($RANDOM%${#ALLOWABLE_ASCII})):1}"
|
||||
password="$password${ALLOWABLE_ASCII:$((RANDOM%${#ALLOWABLE_ASCII})):1}"
|
||||
n=$((n+1))
|
||||
done
|
||||
echo $password
|
||||
echo "$password"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user