From 8ed9bb762bd42e6262d417333a5a42c2c15a79e0 Mon Sep 17 00:00:00 2001 From: Ludovic CHEVALIER Date: Tue, 25 Jun 2013 15:12:37 +0200 Subject: [PATCH] [SCRIPTS] +script de maj de spip --- scripts/maj.sh | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100755 scripts/maj.sh diff --git a/scripts/maj.sh b/scripts/maj.sh new file mode 100755 index 00000000..ee9e51e5 --- /dev/null +++ b/scripts/maj.sh @@ -0,0 +1,86 @@ +#!/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 /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/" + +chmod 777 "$CUR_SPIP_DIR/IMG" +chmod 777 "$CUR_SPIP_DIR/config" +chmod 777 "$CUR_SPIP_DIR/local" +chmod 777 "$CUR_SPIP_DIR/tmp" -- 2.20.1