[SPIP] ~maj v2.1.25-->2.1.26
[velocampus/web/www.git] / scripts / maj.sh
1 #!/bin/sh
2 #
3 # Ce script a pour objectif de mettre à jour un spip en protégeant les chemins
4 # variables.
5 #
6 # TODO: vérifier les vérsions, et ne faire la maj que si nécessaire
7
8 set -e
9
10 BASE_DIR="$(readlink -e "$(dirname "$0")/..")"
11 TMP_DIR="$(mktemp -d)"
12 NEW_SPIP_DIR="$TMP_DIR/spip"
13 CUR_SPIP_DIR="$BASE_DIR/www"
14 EXCLUDED= \
15
16 cmd() {
17 notice " * running cmd:" "$@"
18 "$@" || { notice " ! command failed ret=$?" ; exit 1 ; }
19 }
20
21 notice() {
22 if [ "$LOGLVL" -gt 0 ]
23 then
24 echo "$@"
25 fi
26 }
27
28 cleanup() {
29 [ ! -d "$TMP_DIR" ] || cmd rm -rf "$TMP_DIR"
30 }
31
32 trap cleanup INT QUIT STOP TERM KILL EXIT
33
34 # Traitement des arguments
35 SOURCE=""
36 LOGLVL=1
37 while [ $# -gt 0 ]
38 do
39 case "$1" in
40 -s|--source)
41 shift
42 SOURCE="$1"
43 ;;
44 -v|--verbose)
45 LOGLVL=2
46 ;;
47 -q|--quiet)
48 LOGLVL=0
49 ;;
50 esac
51 shift
52 done
53
54 if [ ! "$SOURCE" ]
55 then
56 # Par default on prend la branche 2.1
57 SOURCE="http://files.spip.org/spip/stable/spip-2.1.zip"
58 fi
59
60 cmd wget \
61 $( [ "$LOGLVL" -gt 1 ] || echo -n '-q') \
62 "$SOURCE" -O "$TMP_DIR/spip.zip"
63
64 cmd unzip \
65 $( [ "$LOGLVL" -gt 1 ] || echo -n '-q') \
66 ${VERBOSE:+-q} "$TMP_DIR/spip.zip" -d "$TMP_DIR"
67
68 [ -d "$CUR_SPIP_DIR" ] || cmd mkdir -p "$CUR_SPIP_DIR"
69
70 cmd rsync -a --delete \
71 --exclude /IMG/ \
72 --exclude /config/chmod.php \
73 --exclude /config/connect.php \
74 --exclude /config/mes_options.php \
75 --exclude /lib/ \
76 --exclude /local/ \
77 --exclude /plugins/ \
78 --exclude /squelettes/ \
79 --exclude /themes/ \
80 --exclude /tmp/ \
81 "$NEW_SPIP_DIR/" \
82 "$CUR_SPIP_DIR/"
83
84 for SPECIAL_DIR in\
85 IMG\
86 config\
87 local\
88 tmp
89 do
90 install -d -m 777 "$CUR_SPIP_DIR/$SPECIAL_DIR"
91 done