source: trunk/install.sh @ 110

Last change on this file since 110 was 109, checked in by pinsard, 14 years ago

usage of program directive

  • 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# ::
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 tthan 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#
90command=$(basename ${0})
91log_date=$(date -u +"%Y%m%dT%H%M%SZ")
92log=/tmp/$(basename ${command} .sh).log.${log_date}
93#
94usage=" Usage : ${command} -w dirwww -p dirpublish -u urlpublish -l login"
95#
96minargcount=4
97#echo " narg ${#}"
98if [ ${#} -lt ${minargcount} ]
99then
100   echo "eee : not enought arguments"
101   echo "${usage}"
102   exit 1
103fi
104unset minargcount
105#
106# default
107dirpublish="none"
108urlpublish="none"
109login="none"
110#
111set +u
112while [ ! -z "${1}" ]
113do
114   case ${1} in
115      -w)
116         dirwww=${2}
117         shift
118      ;;
119      -p)
120         dirpublish=${2}
121         shift
122      ;;
123      -u)
124         urlpublish=${2}
125         shift
126      ;;
127      -l)
128         login=${2}
129         shift
130      ;;
131   esac
132   # next flag
133   shift
134done
135#
136set -u
137#
138# ++ check directories
139#
140answer=${1:-" "}
141case ${answer} in
142   y|Y|n|N)
143   ;;
144   *)
145      if [ "${dirpublish}" != "none" ]
146      then
147         echo "Do you want to install on ${dirpublish} (y|[n]) ?"
148         read answer
149      fi
150      if [ "${urlpublish}" != "none" ]
151      then
152         echo "Do you want to install on ${urlpublish} (y|[n]) ?"
153         read answer
154      fi
155   ;;
156esac
157#
158case  ${answer} in
159   y|Y)
160      if [ "${dirpublish}" != "none" ]
161      then
162         # copy of ${dirwww} on $dirpublish
163         echo "iii : update of ${dirpublish}"
164         rsync -av --exclude=".DS_Store" -e ssh ${dirwww}/ ${dirpublish}
165         # detect if in dirpublish following this pattern [USER@]HOST:SRC, HOST
166         # is cerbere.locean-ipsl.upmc.fr. If so, a specific update is launched
167         userhost=${dirpublish%%:*}
168         host=${userhost##*@}
169         if [ ${login} = "none" ]
170         then
171            user=${userhost%%@*}
172         else
173            user=${login}
174         fi
175         if [ "${host}" = "cerbere.locean-ipsl.upmc.fr" ]
176         then
177            wget -q "http://intranet.locean-ipsl.upmc.fr/persoweb/?fastupdate=1&user=${user}" -O /dev/null
178         fi
179      else
180         # urlpublish=http://www.locean-ipsl.upmc.fr/~ginette/produit
181         dirpublish=${urlpublish##*~}
182         cd ${dirwww}
183         #lftp -e "mirror -R . ${dirpublish};quit" -u ${LOGNAME} skyros.locean-ipsl.upmc.fr
184         lftp -e "mirror -R . ${dirpublish};quit" -u ${LOGNAME} www.locean-ipsl.upmc.fr
185         # pour acmo a la main ++
186         #++lftp -e 'mirror -R . acmo/nouveaux/;quit' -u fplod www.locean-ipsl.upmc.fr
187         # ++ log
188      fi
189   ;;
190   *)
191      echo "no update of ${dirpublish} or ${urlpublish}"
192   ;;
193esac
194#
195# normal exit
196exit 0
Note: See TracBrowser for help on using the repository browser.