--- /dev/null
+#!/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"