Amélioration du Makefile + création par défaut d'une URL http://x-truc.p.org/
[wikifarm.git] / install / newfield.sh
1 #! /bin/sh
2 InstallDir=$(dirname $0)
3 FarmDir=${InstallDir}/../
4
5 # Nom du wiki en paramètre ou en read
6 if [ $# -lt 1 ]; then
7 echo "Nom du nouveau champs wiki (doit pouvoir être un nom de dossier) :"
8 read NomDuWiki
9 else
10 NomDuWiki=$1
11 fi
12
13 FieldDir=${FarmDir}${NomDuWiki}
14
15 # Vérification de l'existance du champs
16 if [ -d $FieldDir ]; then
17 echo "Ce champs existe déjà."
18 exit
19 fi
20
21 # Récupération de l'url
22 echo "Url du wiki (http://$NomDuWiki.polytechnique.org/):"
23 read FieldUrl
24 if [ -z "$FieldUrl" ]; then
25 FieldUrl=http://$NomDuWiki.polytechnique.org/
26 FieldUrlFolder=/
27 else
28 if [ "$FieldUrl" = "ok" ]; then
29 echo "url invalide ok"
30 exit
31 fi
32 if [ $(echo $FieldUrl | sed -e "s,^http://[^/]*/.*$,ok,") != "ok" ]; then
33 echo "url invalide"
34 exit
35 fi
36 # suppression du / final dans l'url
37 FieldUrl=$(echo $FieldUrl | sed -e "s,/$,,")
38 FieldUrlFolder=$(echo $FieldUrl | sed -e "s,^http://[^/]*\(/.*\)$,\\1/,")
39 fi
40
41 # récapitulatif
42 echo "Création du champs wiki $NomDuWiki"
43 echo " dossier : $FieldDir"
44 echo " url : $FieldUrl"
45 echo " url relatif : $FieldUrlFolder"
46
47 # copie des fichiers
48 cp -Ra ${InstallDir}/NomDuWiki $FieldDir
49
50 # application des dossiers et url spécifiques au champs
51 sed -e "s,^RewriteBase .*$,RewriteBase $FieldUrlFolder," ${InstallDir}/NomDuWiki/.htaccess > $FieldDir/.htaccess
52 sed -e "s,^.*ScriptUrl.*$, \$ScriptUrl = '$FieldUrl';," ${InstallDir}/NomDuWiki/local/config.php > ${FieldDir}/local/config.php
53
54 #création des dossiers et fichiers attribués à l'utilisateur www-data
55 #wget --quiet ${FieldUrl}/Site/Admin?createconf=1 -O /dev/null
56 #wget --quiet ${FieldUrl}/Site/Admin?createconf=1 -O /dev/null
57