From: Ludovic CHEVALIER Date: Mon, 9 Feb 2015 13:58:56 +0000 (+0100) Subject: [SCRIPTS] +maj.sh X-Git-Tag: production~27 X-Git-Url: http://git.cyclocoop.org/?p=lhc%2Fweb%2Fclavette_www.git;a=commitdiff_plain;h=8945248b3d948385798d9aa355c70e7089aca2b3 [SCRIPTS] +maj.sh --- diff --git a/scripts/maj.sh b/scripts/maj.sh new file mode 100755 index 0000000..6904c5c --- /dev/null +++ b/scripts/maj.sh @@ -0,0 +1,91 @@ +#!/bin/sh +# +# Ce script a pour objectif de mettre à jour un spip en protégeant les chemins +# variables. +# +# TODO: vérifier les vérsions, et ne faire la maj que si nécessaire + +set -e + +BASE_DIR="$(readlink -e "$(dirname "$0")/..")" +TMP_DIR="$(mktemp -d)" +NEW_SPIP_DIR="$TMP_DIR/spip" +CUR_SPIP_DIR="$BASE_DIR/www" +EXCLUDED= \ + +cmd() { + notice " * running cmd:" "$@" + "$@" || { notice " ! command failed ret=$?" ; exit 1 ; } +} + +notice() { + if [ "$LOGLVL" -gt 0 ] + then + echo "$@" + fi +} + +cleanup() { + [ ! -d "$TMP_DIR" ] || cmd rm -rf "$TMP_DIR" +} + +trap cleanup INT QUIT STOP TERM KILL EXIT + +# Traitement des arguments +SOURCE="" +LOGLVL=1 +while [ $# -gt 0 ] +do + case "$1" in + -s|--source) + shift + SOURCE="$1" + ;; + -v|--verbose) + LOGLVL=2 + ;; + -q|--quiet) + LOGLVL=0 + ;; + esac + shift +done + +if [ ! "$SOURCE" ] +then + # Par default on prend la branche 3.0 + SOURCE="http://files.spip.org/spip/stable/spip-3.0.zip" +fi + +cmd wget \ + $( [ "$LOGLVL" -gt 1 ] || echo -n '-q') \ + "$SOURCE" -O "$TMP_DIR/spip.zip" + +cmd unzip \ + $( [ "$LOGLVL" -gt 1 ] || echo -n '-q') \ + ${VERBOSE:+-q} "$TMP_DIR/spip.zip" -d "$TMP_DIR" + +[ -d "$CUR_SPIP_DIR" ] || cmd mkdir -p "$CUR_SPIP_DIR" + +cmd rsync -a --delete \ + --exclude .htaccess \ + --exclude /IMG/ \ + --exclude /config/chmod.php \ + --exclude /config/connect.php \ + --exclude /config/mes_options.php \ + --exclude /lib/ \ + --exclude /local/ \ + --exclude /plugins/ \ + --exclude /themes/ \ + --exclude /tmp/ \ + "$NEW_SPIP_DIR/" \ + "$CUR_SPIP_DIR/" + +for SPECIAL_DIR in\ + IMG\ + config\ + local\ + tmp +do + install -d -m 750 "$CUR_SPIP_DIR/$SPECIAL_DIR" +done