1 | #! /bin/sh |
---|
2 | #+ |
---|
3 | # |
---|
4 | # .. _install.sh: |
---|
5 | # |
---|
6 | # ========== |
---|
7 | # install.sh |
---|
8 | # ========== |
---|
9 | # |
---|
10 | # NAME |
---|
11 | # ==== |
---|
12 | # |
---|
13 | # install.sh - publication of HTML files and associated files |
---|
14 | # |
---|
15 | # SYNOPSIS |
---|
16 | # ======== |
---|
17 | # |
---|
18 | # .. code-block:: bash |
---|
19 | # |
---|
20 | # install.sh -w dirwww -p dirpublish -u urlpublish -l login |
---|
21 | # |
---|
22 | # DESCRIPTION |
---|
23 | # =========== |
---|
24 | # |
---|
25 | # publication (rsync) of dirwww content on dirpublish given in argument |
---|
26 | # |
---|
27 | # If the host of publication is cerbere.locean-ipsl.upmc.fr, a specific update |
---|
28 | # is launched. |
---|
29 | # |
---|
30 | # .. option:: -w <input directory> |
---|
31 | # .. option:: -p <output directory> |
---|
32 | # .. option:: -u <output url> |
---|
33 | # .. option:: -l <login used to access on output url> |
---|
34 | # |
---|
35 | # EXAMPLES |
---|
36 | # ======== |
---|
37 | # |
---|
38 | # TODO |
---|
39 | # ==== |
---|
40 | # |
---|
41 | # destroy. use fptools one's instead |
---|
42 | # |
---|
43 | # EVOLUTIONS |
---|
44 | # ========== |
---|
45 | # |
---|
46 | # $Id$ |
---|
47 | # |
---|
48 | # - fplod 2009-04-27T10:21:23Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
49 | # |
---|
50 | # * creation from personal tool (used for superbib, SAXO, etc.) |
---|
51 | # |
---|
52 | #- |
---|
53 | system=$(uname) |
---|
54 | case "${system}" in |
---|
55 | AIX|IRIX64) |
---|
56 | echo " www : no specific posix checking" |
---|
57 | ;; |
---|
58 | *) |
---|
59 | set -o posix |
---|
60 | ;; |
---|
61 | esac |
---|
62 | # |
---|
63 | set -u |
---|
64 | # |
---|
65 | command=$(basename ${0}) |
---|
66 | log_date=$(date -u +"%Y%m%dT%H%M%SZ") |
---|
67 | log=/tmp/$(basename ${command} .sh).log.${log_date} |
---|
68 | # |
---|
69 | usage=" Usage : ${command} -w dirwww -p dirpublish -u urlpublish -l login" |
---|
70 | # |
---|
71 | minargcount=4 |
---|
72 | #echo " narg ${#}" |
---|
73 | if [ ${#} -lt ${minargcount} ] |
---|
74 | then |
---|
75 | echo "eee : not enough arguments" |
---|
76 | echo "${usage}" |
---|
77 | exit 1 |
---|
78 | fi |
---|
79 | # |
---|
80 | # default |
---|
81 | dirpublish="none" |
---|
82 | urlpublish="none" |
---|
83 | login="none" |
---|
84 | # |
---|
85 | while [ ${#} -gt 0 ] |
---|
86 | do |
---|
87 | case ${1} in |
---|
88 | -w) |
---|
89 | dirwww=${2} |
---|
90 | shift |
---|
91 | ;; |
---|
92 | -p) |
---|
93 | dirpublish=${2} |
---|
94 | shift |
---|
95 | ;; |
---|
96 | -u) |
---|
97 | urlpublish=${2} |
---|
98 | shift |
---|
99 | ;; |
---|
100 | -l) |
---|
101 | login=${2} |
---|
102 | shift |
---|
103 | ;; |
---|
104 | esac |
---|
105 | # next flag |
---|
106 | shift |
---|
107 | done |
---|
108 | # |
---|
109 | # ++ check directories |
---|
110 | # |
---|
111 | answer=${1:-" "} |
---|
112 | case ${answer} in |
---|
113 | y|Y|n|N) |
---|
114 | ;; |
---|
115 | *) |
---|
116 | if [ "${dirpublish}" != "none" ] |
---|
117 | then |
---|
118 | echo "Do you want to install ${dirwww} on ${dirpublish} (y|[n]) ?" |
---|
119 | read answer |
---|
120 | fi |
---|
121 | if [ "${urlpublish}" != "none" ] |
---|
122 | then |
---|
123 | echo "Do you want to install ${dirwww} on ${urlpublish} (y|[n]) ?" |
---|
124 | read answer |
---|
125 | fi |
---|
126 | ;; |
---|
127 | esac |
---|
128 | # |
---|
129 | case ${answer} in |
---|
130 | y|Y) |
---|
131 | if [ "${dirpublish}" != "none" ] |
---|
132 | then |
---|
133 | # copy of ${dirwww} on $dirpublish |
---|
134 | echo "iii : update of ${dirpublish}" |
---|
135 | rsync -av --exclude=".DS_Store" -e ssh ${dirwww}/ ${dirpublish} |
---|
136 | # detect if in dirpublish following this pattern [USER@]HOST:SRC, HOST |
---|
137 | # is cerbere.locean-ipsl.upmc.fr. If so, a specific update is launched |
---|
138 | userhost=${dirpublish%%:*} |
---|
139 | host=${userhost##*@} |
---|
140 | if [ ${login} = "none" ] |
---|
141 | then |
---|
142 | user=${userhost%%@*} |
---|
143 | else |
---|
144 | user=${login} |
---|
145 | fi |
---|
146 | if [ "${host}" = "cerbere.locean-ipsl.upmc.fr" ] |
---|
147 | then |
---|
148 | wget -q "http://intranet.locean-ipsl.upmc.fr/persoweb/?fastupdate=1&user=${user}" -O /dev/null |
---|
149 | fi |
---|
150 | else |
---|
151 | # urlpublish=http://www.locean-ipsl.upmc.fr/~ginette/produit |
---|
152 | dirpublish=${urlpublish##*~} |
---|
153 | cd ${dirwww} |
---|
154 | #lftp -e "mirror -R . ${dirpublish};quit" -u ${LOGNAME} skyros.locean-ipsl.upmc.fr |
---|
155 | lftp -e "mirror -R . ${dirpublish};quit" -u ${LOGNAME} www.locean-ipsl.upmc.fr |
---|
156 | # ++ log |
---|
157 | fi |
---|
158 | ;; |
---|
159 | *) |
---|
160 | echo "no update of ${dirpublish} or ${urlpublish}" |
---|
161 | ;; |
---|
162 | esac |
---|
163 | # |
---|
164 | # normal exit |
---|
165 | exit 0 |
---|