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