1 | #!/bin/sh |
---|
2 | # |
---|
3 | # module : |
---|
4 | # publication (rsync) of dirwww content on dirpublish given in argument |
---|
5 | # |
---|
6 | # If the host of publication is cerbere.locean-ipsl.upmc.fr, a specific update |
---|
7 | # is launched. |
---|
8 | # |
---|
9 | # update : |
---|
10 | # $Id$ |
---|
11 | # ++ -p should be suppress it is not any more compulsary (-u is now the good one) |
---|
12 | # fplod 2008-03-28T10:26:58Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
13 | # new personnal webpages policy at LOCEAN so new command and new parameter (-u) |
---|
14 | # fplod 2007-09-28T09:30:43Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
15 | # parametrisation and translation |
---|
16 | # smasson 2007-06-07T16:43:42Z arete.locean-ipsl.upmc.fr (Darwin) |
---|
17 | # can give the answer with input parameters |
---|
18 | # fplod 2007-04-26T11:51:42Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
19 | # |
---|
20 | set -o posix |
---|
21 | command=$(basename ${0} .sh) |
---|
22 | log_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") |
---|
23 | log=/tmp/${command}.${log_date} |
---|
24 | # |
---|
25 | usage=" Usage : ${command} -w dirwww -p dirpublish -u urlpublish" |
---|
26 | # |
---|
27 | minargcount=4 |
---|
28 | #echo " narg ${#}" |
---|
29 | if [ ${#} -lt ${minargcount} ] |
---|
30 | then |
---|
31 | echo "eee : not enought arguments" |
---|
32 | echo "${usage}" |
---|
33 | exit 1 |
---|
34 | fi |
---|
35 | # |
---|
36 | # default |
---|
37 | dirpublish="none" |
---|
38 | urlpublish="none" |
---|
39 | # |
---|
40 | while [ ! -z "${1}" ] |
---|
41 | do |
---|
42 | case ${1} in |
---|
43 | -w) |
---|
44 | dirwww=${2} |
---|
45 | shift |
---|
46 | ;; |
---|
47 | -p) |
---|
48 | dirpublish=${2} |
---|
49 | shift |
---|
50 | ;; |
---|
51 | -u ) |
---|
52 | urlpublish=${2} |
---|
53 | shift |
---|
54 | ;; |
---|
55 | esac |
---|
56 | shift # next flag |
---|
57 | done |
---|
58 | # |
---|
59 | set -u |
---|
60 | # |
---|
61 | # ++ check directories |
---|
62 | # |
---|
63 | answer=${1:-" "} |
---|
64 | case ${answer} in |
---|
65 | y|Y|n|N) |
---|
66 | ;; |
---|
67 | *) |
---|
68 | if [ "${dirpublish}" != "none" ] |
---|
69 | then |
---|
70 | echo "Do you want to install on ${dirpublish} (y|[n]) ?" |
---|
71 | read answer |
---|
72 | fi |
---|
73 | if [ "${urlpublish}" != "none" ] |
---|
74 | then |
---|
75 | echo "Do you want to install on ${urlpublish} (y|[n]) ?" |
---|
76 | read answer |
---|
77 | fi |
---|
78 | ;; |
---|
79 | esac |
---|
80 | # |
---|
81 | case ${answer} in |
---|
82 | y|Y) |
---|
83 | if [ "${dirpublish}" != "none" ] |
---|
84 | then |
---|
85 | # copy of ${dirwww} on $dirpublish |
---|
86 | echo "iii : update of ${dirpublish}" |
---|
87 | rsync -av --exclude=".DS_Store" -e ssh ${dirwww}/ ${dirpublish} |
---|
88 | # detect if in dirpublish following this pattern [USER@]HOST:SRC, HOST |
---|
89 | # is cerbere.locean-ipsl.upmc.fr. If so, a specific update is launched |
---|
90 | userhost=${dirpublish%%:*} |
---|
91 | host=${userhost##*@} |
---|
92 | user=${userhost%%@*} |
---|
93 | if [ "${host}" = "cerbere.locean-ipsl.upmc.fr" ] |
---|
94 | then |
---|
95 | wget -q "http://www.lodyc.jussieu.fr/info_reseau/persoweb/?fastupdate=1&user=${user}" -O /dev/null |
---|
96 | fi |
---|
97 | else |
---|
98 | # urlpublish=http://www.locean-ipsl.upmc.fr/~ginette/produit |
---|
99 | dirpublish=${urlpublish##*~} |
---|
100 | cd ${dirwww} |
---|
101 | lftp -e "mirror -R . ${dirpublish};quit" -u ${LOGNAME} skyros.locean-ipsl.upmc.fr |
---|
102 | # ++ log |
---|
103 | fi |
---|
104 | |
---|
105 | ;; |
---|
106 | *) |
---|
107 | echo "no update of ${dirpublish} or ${urlpublish}" |
---|
108 | ;; |
---|
109 | esac |
---|
110 | # |
---|
111 | # normal exit |
---|
112 | exit 0 |
---|