source: trunk/install.sh @ 140

Last change on this file since 140 was 116, checked in by pinsard, 13 years ago

Consolidation of shell scripts

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