source: trunk/adm/install.sh @ 10

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

Consolidation of shell scripts

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