Projet

Général

Profil

Paste
Télécharger (952 octets) Statistiques
| Branche: | Révision:

root / other-scripts / one-use / mv-htmltest-drupal7.sh @ d808fa20

1 cf6a035a Julien Enselme
#!/bin/bash
2
3 312a4195 Julien Enselme
for dir in $(find /users/guest/assos/drupal7/sites -maxdepth 1 -mindepth 1 -type d ! -name all | sort) ; do
4 cf6a035a Julien Enselme
5
    ## Get database name
6
    site=${dir##*/}
7
    db=${site##*.}
8 ef85b909 Julien Enselme
    echo $site
9 cf6a035a Julien Enselme
    if [ $db = 'default' ] ; then
10
	db='default_assos'
11
    fi
12
13
    ##  Look in the variable table
14
    mysql --defaults-extra-file=~/private/myassos.cnf -N -e "SELECT value FROM $db.variable WHERE CONVERT(value USING utf8) LIKE '%htmltest%'" > ~/tmp/out
15
16
    ## If results
17
    if [ $(cat ~/tmp/out | wc -l) -ne 0 ] ; then
18
	sed 's/htmltest/drupal7/g' < ~/tmp/out > ~/tmp/in
19
20
	i=$((0))
21
	while read line ; do
22
	    out[$i]=$line
23
	    i=$((i+1))
24
	done < ~/tmp/out
25
26
	i=$((0))
27
	while read line ; do
28
	    in[$i]=$line
29
	    i=$((i+1))
30
	done < ~/tmp/in
31
32
	for i in $(seq 0 $((${#out[*]}-1))) ; do
33
	    mysql --defaults-extra-file=~/private/myassos.cnf -e "UPDATE $db.variable SET value=${in[$i]} WHERE value = ${out[$i]}"
34
	done
35
36
	rm ~/tmp/out ~/tmp/in
37
    fi
38
done