source: trunk/adm/install.sh @ 111

Last change on this file since 111 was 101, checked in by pinsard, 13 years ago

Consolidation of shell scripts

  • Property svn:executable set to *
File size: 3.1 KB
Line 
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#-
44system=$(uname)
45case "${system}" in
46   AIX|IRIX64)
47      echo " www : no specific posix checking"
48   ;;
49   *)
50      set -o posix
51   ;;
52esac
53#
54set -u
55#
56command=$(basename ${0})
57log_date=$(date -u +"%Y%m%dT%H%M%SZ")
58log=/tmp/$(basename ${command} .sh).log.${log_date}
59#
60usage=" Usage : ${command} -w dirwww -p dirpublish -u urlpublish -l login"
61#
62minargcount=4
63#echo " narg ${#}"
64if [ ${#} -lt ${minargcount} ]
65then
66   echo "eee : not enought arguments"
67   echo "${usage}"
68   exit 1
69fi
70#
71# default
72dirpublish="none"
73urlpublish="none"
74login="none"
75#
76while [ ${#} -gt 0 ]
77do
78   case ${1} in
79      -w)
80         dirwww=${2}
81         shift
82      ;;
83      -p)
84         dirpublish=${2}
85         shift
86      ;;
87      -u)
88         urlpublish=${2}
89         shift
90      ;;
91      -l)
92         login=${2}
93         shift
94      ;;
95   esac
96   # next flag
97   shift
98done
99#
100# ++ check directories
101#
102answer=${1:-" "}
103case ${answer} in
104   y|Y|n|N)
105   ;;
106   *)
107      if [ "${dirpublish}" != "none" ]
108      then
109         echo "Do you want to install ${dirwww} on ${dirpublish} (y|[n]) ?"
110         read answer
111      fi
112      if [ "${urlpublish}" != "none" ]
113      then
114         echo "Do you want to install ${dirwww} on ${urlpublish} (y|[n]) ?"
115         read answer
116      fi
117   ;;
118esac
119#
120case ${answer} in
121   y|Y)
122      if [ "${dirpublish}" != "none" ]
123      then
124         # copy of ${dirwww} on $dirpublish
125         echo "iii : update of ${dirpublish}"
126         rsync -av --exclude=".DS_Store" -e ssh ${dirwww}/ ${dirpublish}
127         # detect if in dirpublish following this pattern [USER@]HOST:SRC, HOST
128         # is cerbere.locean-ipsl.upmc.fr. If so, a specific update is launched
129         userhost=${dirpublish%%:*}
130         host=${userhost##*@}
131         if [ ${login} = "none" ]
132         then
133            user=${userhost%%@*}
134         else
135            user=${login}
136         fi
137         if [ "${host}" = "cerbere.locean-ipsl.upmc.fr" ]
138         then
139           wget -q "http://intranet.locean-ipsl.upmc.fr/persoweb/?fastupdate=1&user=${user}" -O /dev/null
140         fi
141      else
142         # urlpublish=http://www.locean-ipsl.upmc.fr/~ginette/produit
143         dirpublish=${urlpublish##*~}
144         cd ${dirwww}
145         #lftp -e "mirror -R . ${dirpublish};quit" -u ${LOGNAME} skyros.locean-ipsl.upmc.fr
146         lftp -e "mirror -R . ${dirpublish};quit" -u ${LOGNAME} www.locean-ipsl.upmc.fr
147         # ++ log
148      fi
149   ;;
150   *)
151      echo "no update of ${dirpublish} or ${urlpublish}"
152   ;;
153esac
154#
155# normal exit
156exit 0
Note: See TracBrowser for help on using the repository browser.