X-Git-Url: http://git.cyclocoop.org/?p=velocampus%2Fweb%2Fwww.git;a=blobdiff_plain;f=scripts%2Fmaj.sh;fp=scripts%2Fmaj.sh;h=8462b1d91016d2720be469d30a5daa1c4d94b397;hp=0000000000000000000000000000000000000000;hb=e99f0878011913365e49b30d90e496c24c301393;hpb=80b4d3e85f78d402ed2e73f8f5d1bf4c19962eed diff --git a/scripts/maj.sh b/scripts/maj.sh new file mode 100755 index 0000000..8462b1d --- /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/archives/SPIP-v2-1.25.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 /squelettes/ \ + --exclude /themes/ \ + --exclude /tmp/ \ + "$NEW_SPIP_DIR/" \ + "$CUR_SPIP_DIR/" + +for SPECIAL_DIR in\ + IMG\ + config\ + local\ + tmp +do + install -d -m 777 "$CUR_SPIP_DIR/$SPECIAL_DIR" +done