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