1 | #!/bin/sh -x |
---|
2 | #+ |
---|
3 | # |
---|
4 | # ========== |
---|
5 | # install.sh |
---|
6 | # ========== |
---|
7 | # |
---|
8 | # ---------------------------------------------- |
---|
9 | # publication of HTML files and associated files |
---|
10 | # ---------------------------------------------- |
---|
11 | # |
---|
12 | # SYNOPSIS |
---|
13 | # ======== |
---|
14 | # |
---|
15 | # :: |
---|
16 | # |
---|
17 | # $ install.sh -w dirwww -p dirpublish -u urlpublish -l login |
---|
18 | # |
---|
19 | # DESCRIPTION |
---|
20 | # =========== |
---|
21 | # |
---|
22 | # publication (rsync) of dirwww content on dirpublish given in argument |
---|
23 | # |
---|
24 | # If the host of publication is cerbere.locean-ipsl.upmc.fr, a specific update |
---|
25 | # is launched. |
---|
26 | # |
---|
27 | # -w input directort |
---|
28 | # -p output directory |
---|
29 | # -u output url |
---|
30 | # -l login used to access on output url |
---|
31 | # |
---|
32 | # If needed, existing directories might be removed before (to erase obsolete |
---|
33 | # files), using ncftp tool : |
---|
34 | # |
---|
35 | # For example, to clean directory on LOCEAN web server :: |
---|
36 | # |
---|
37 | # $ ncftp -u fplod www.locean-ipsl.upmc.fr |
---|
38 | # ncftp> cd fplod |
---|
39 | # ncftp> rm -f pageperso/.DS_Store |
---|
40 | # ncftp> rm -rf pageperso |
---|
41 | # ncftp> exit |
---|
42 | # |
---|
43 | # EXAMPLES |
---|
44 | # ======== |
---|
45 | # |
---|
46 | # EVOLUTIONS |
---|
47 | # ========== |
---|
48 | # |
---|
49 | # $Id$ |
---|
50 | # |
---|
51 | # - fplod 2008-09-16T15:24:26Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
52 | # |
---|
53 | # * comments in ReStructured Text |
---|
54 | # |
---|
55 | # - fplod 2008-06-17T09:10:19Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
56 | # |
---|
57 | # * add -l parameter only used in specific case at LOCEAN when user |
---|
58 | # parameter of persoweb must be different tthan login (ex: acmo vs fplod) |
---|
59 | # * replace http://www.lodyc.jussieu.fr/info_reseau/persoweb/?fastupdate=1&user=${user}" by |
---|
60 | # http://intranet.locean-ipsl.upmc.fr/persoweb/?fastupdate=1&user=${user} |
---|
61 | # |
---|
62 | # - fplod 2008-03-28T10:26:58Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
63 | # |
---|
64 | # * new personnal webpages policy at LOCEAN so new command and new parameter (-u) |
---|
65 | # |
---|
66 | # - fplod 2007-09-28T09:30:43Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
67 | # |
---|
68 | # * parametrisation and translation |
---|
69 | # |
---|
70 | # - smasson 2007-06-07T16:43:42Z arete.locean-ipsl.upmc.fr (Darwin) |
---|
71 | # |
---|
72 | # * can give the answer with input parameters |
---|
73 | # |
---|
74 | # - fplod 2007-04-26T11:51:42Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
75 | # |
---|
76 | #- |
---|
77 | system=$(uname) |
---|
78 | case "${system}" in |
---|
79 | AIX|IRIX64) |
---|
80 | echo " www : no specific posix checking" |
---|
81 | ;; |
---|
82 | *) |
---|
83 | set -o posix |
---|
84 | ;; |
---|
85 | esac |
---|
86 | unset system |
---|
87 | # |
---|
88 | command=$(basename ${0}) |
---|
89 | log_date=$(date -u +"%Y%m%dT%H%M%SZ") |
---|
90 | log=/tmp/$(basename ${command} .sh).log.${log_date} |
---|
91 | # |
---|
92 | usage=" Usage : ${command} -w dirwww -p dirpublish -u urlpublish -l login" |
---|
93 | # |
---|
94 | minargcount=4 |
---|
95 | #echo " narg ${#}" |
---|
96 | if [ ${#} -lt ${minargcount} ] |
---|
97 | then |
---|
98 | echo "eee : not enought arguments" |
---|
99 | echo "${usage}" |
---|
100 | exit 1 |
---|
101 | fi |
---|
102 | unset minargcount |
---|
103 | # |
---|
104 | # default |
---|
105 | dirpublish="none" |
---|
106 | urlpublish="none" |
---|
107 | login="none" |
---|
108 | # |
---|
109 | while [ ! -z "${1}" ] |
---|
110 | do |
---|
111 | case ${1} in |
---|
112 | -w) |
---|
113 | dirwww=${2} |
---|
114 | shift |
---|
115 | ;; |
---|
116 | -p) |
---|
117 | dirpublish=${2} |
---|
118 | shift |
---|
119 | ;; |
---|
120 | -u) |
---|
121 | urlpublish=${2} |
---|
122 | shift |
---|
123 | ;; |
---|
124 | -l) |
---|
125 | login=${2} |
---|
126 | shift |
---|
127 | ;; |
---|
128 | esac |
---|
129 | # next flag |
---|
130 | shift |
---|
131 | done |
---|
132 | # |
---|
133 | set -u |
---|
134 | # |
---|
135 | # ++ check directories |
---|
136 | # |
---|
137 | answer=${1:-" "} |
---|
138 | case ${answer} in |
---|
139 | y|Y|n|N) |
---|
140 | ;; |
---|
141 | *) |
---|
142 | if [ "${dirpublish}" != "none" ] |
---|
143 | then |
---|
144 | echo "Do you want to install on ${dirpublish} (y|[n]) ?" |
---|
145 | read answer |
---|
146 | fi |
---|
147 | if [ "${urlpublish}" != "none" ] |
---|
148 | then |
---|
149 | echo "Do you want to install on ${urlpublish} (y|[n]) ?" |
---|
150 | read answer |
---|
151 | fi |
---|
152 | ;; |
---|
153 | esac |
---|
154 | # |
---|
155 | case ${answer} in |
---|
156 | y|Y) |
---|
157 | if [ "${dirpublish}" != "none" ] |
---|
158 | then |
---|
159 | # copy of ${dirwww} on $dirpublish |
---|
160 | echo "iii : update of ${dirpublish}" |
---|
161 | rsync -av --exclude=".DS_Store" -e ssh ${dirwww}/ ${dirpublish} |
---|
162 | # detect if in dirpublish following this pattern [USER@]HOST:SRC, HOST |
---|
163 | # is cerbere.locean-ipsl.upmc.fr. If so, a specific update is launched |
---|
164 | userhost=${dirpublish%%:*} |
---|
165 | host=${userhost##*@} |
---|
166 | if [ ${login} = "none" ] |
---|
167 | then |
---|
168 | user=${userhost%%@*} |
---|
169 | else |
---|
170 | user=${login} |
---|
171 | fi |
---|
172 | if [ "${host}" = "cerbere.locean-ipsl.upmc.fr" ] |
---|
173 | then |
---|
174 | wget -q "http://intranet.locean-ipsl.upmc.fr/persoweb/?fastupdate=1&user=${user}" -O /dev/null |
---|
175 | fi |
---|
176 | else |
---|
177 | # urlpublish=http://www.locean-ipsl.upmc.fr/~ginette/produit |
---|
178 | dirpublish=${urlpublish##*~} |
---|
179 | cd ${dirwww} |
---|
180 | #lftp -e "mirror -R . ${dirpublish};quit" -u ${LOGNAME} skyros.locean-ipsl.upmc.fr |
---|
181 | lftp -e "mirror -R . ${dirpublish};quit" -u ${LOGNAME} localhost |
---|
182 | # pour acmo a la main ++ |
---|
183 | #++lftp -e 'mirror -R . acmo/nouveaux/;quit' -u fplod www.locean-ipsl.upmc.fr |
---|
184 | # ++ log |
---|
185 | fi |
---|
186 | ;; |
---|
187 | *) |
---|
188 | echo "no update of ${dirpublish} or ${urlpublish}" |
---|
189 | ;; |
---|
190 | esac |
---|
191 | # |
---|
192 | # normal exit |
---|
193 | exit 0 |
---|