source: trunk/install.sh

Last change on this file was 354, checked in by pinsard, 8 years ago

fix thanks to coding rules; typo

  • Property svn:keywords set to Id
File size: 4.6 KB
Line 
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#-
81system=$(uname)
82case "${system}" in
83   AIX|IRIX64)
84      echo " www : no specific posix checking"
85   ;;
86   *)
87      set -o posix
88   ;;
89esac
90unset system
91#
92set -u
93#
94command=$(basename ${0})
95log_date=$(date -u +"%Y%m%dT%H%M%SZ")
96log=/tmp/$(basename ${command} .sh).log.${log_date}
97#
98usage=" Usage : ${command} -w dirwww -p dirpublish -u urlpublish -l login"
99#
100minargcount=4
101#echo " narg ${#}"
102if [ ${#} -lt ${minargcount} ]
103then
104   echo "eee : not enough arguments"
105   echo "${usage}"
106   exit 1
107fi
108unset minargcount
109#
110# default
111dirpublish="none"
112urlpublish="none"
113login="none"
114#
115while [ ${#} -gt 0 ]
116do
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
137done
138#
139# ++ check directories
140#
141answer=${1:-" "}
142case ${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   ;;
157esac
158#
159case  ${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   ;;
194esac
195#
196# normal exit
197exit 0
Note: See TracBrowser for help on using the repository browser.