[2] | 1 | #!/bin/sh |
---|
| 2 | # |
---|
| 3 | # module : |
---|
[23] | 4 | # publication (rsync) of dirwww content on dirpublish given in argument |
---|
[2] | 5 | # |
---|
[31] | 6 | # If the host of publication is cerbere.locean-ipsl.upmc.fr, a specific update |
---|
| 7 | # is launched. |
---|
[2] | 8 | # |
---|
[31] | 9 | # update : |
---|
[23] | 10 | # $Id$ |
---|
[50] | 11 | # ++ -p should be suppress it is not any more compulsary (-u is now the good one) |
---|
| 12 | # fplod 2008-03-28T10:26:58Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 13 | # new personnal webpages policy at LOCEAN so new command and new parameter (-u) |
---|
[23] | 14 | # fplod 2007-09-28T09:30:43Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 15 | # parametrisation and translation |
---|
[14] | 16 | # smasson 2007-06-07T16:43:42Z arete.locean-ipsl.upmc.fr (Darwin) |
---|
| 17 | # can give the answer with input parameters |
---|
[2] | 18 | # fplod 2007-04-26T11:51:42Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 19 | # |
---|
[23] | 20 | set -o posix |
---|
| 21 | command=$(basename ${0} .sh) |
---|
| 22 | log_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") |
---|
| 23 | log=/tmp/${command}.${log_date} |
---|
[2] | 24 | # |
---|
[50] | 25 | usage=" Usage : ${command} -w dirwww -p dirpublish -u urlpublish" |
---|
[23] | 26 | # |
---|
| 27 | minargcount=4 |
---|
[25] | 28 | #echo " narg ${#}" |
---|
[23] | 29 | if [ ${#} -lt ${minargcount} ] |
---|
| 30 | then |
---|
| 31 | echo "eee : not enought arguments" |
---|
| 32 | echo "${usage}" |
---|
| 33 | exit 1 |
---|
| 34 | fi |
---|
| 35 | # |
---|
[50] | 36 | # default |
---|
| 37 | dirpublish="none" |
---|
[52] | 38 | urlpublish="none" |
---|
[50] | 39 | # |
---|
[23] | 40 | while [ ! -z "${1}" ] |
---|
| 41 | do |
---|
| 42 | case ${1} in |
---|
| 43 | -w) |
---|
| 44 | dirwww=${2} |
---|
| 45 | shift |
---|
[2] | 46 | ;; |
---|
[23] | 47 | -p) |
---|
| 48 | dirpublish=${2} |
---|
| 49 | shift |
---|
[2] | 50 | ;; |
---|
[50] | 51 | -u ) |
---|
| 52 | urlpublish=${2} |
---|
| 53 | shift |
---|
| 54 | ;; |
---|
[23] | 55 | esac |
---|
| 56 | shift # next flag |
---|
| 57 | done |
---|
[2] | 58 | # |
---|
[23] | 59 | set -u |
---|
[2] | 60 | # |
---|
[23] | 61 | # ++ check directories |
---|
| 62 | # |
---|
| 63 | answer=${1:-" "} |
---|
[2] | 64 | case ${answer} in |
---|
[14] | 65 | y|Y|n|N) |
---|
[50] | 66 | ;; |
---|
[14] | 67 | *) |
---|
[50] | 68 | if [ "${dirpublish}" != "none" ] |
---|
| 69 | then |
---|
| 70 | echo "Do you want to install on ${dirpublish} (y|[n]) ?" |
---|
| 71 | read answer |
---|
| 72 | fi |
---|
[52] | 73 | if [ "${urlpublish}" != "none" ] |
---|
| 74 | then |
---|
| 75 | echo "Do you want to install on ${urlpublish} (y|[n]) ?" |
---|
| 76 | read answer |
---|
| 77 | fi |
---|
[50] | 78 | ;; |
---|
[14] | 79 | esac |
---|
[50] | 80 | # |
---|
[14] | 81 | case ${answer} in |
---|
[2] | 82 | y|Y) |
---|
[50] | 83 | if [ "${dirpublish}" != "none" ] |
---|
| 84 | then |
---|
[23] | 85 | # copy of ${dirwww} on $dirpublish |
---|
| 86 | echo "iii : update of ${dirpublish}" |
---|
[51] | 87 | rsync -av --exclude=".DS_Store" -e ssh ${dirwww}/ ${dirpublish} |
---|
[23] | 88 | # detect if in dirpublish following this pattern [USER@]HOST:SRC, HOST |
---|
[31] | 89 | # is cerbere.locean-ipsl.upmc.fr. If so, a specific update is launched |
---|
[23] | 90 | userhost=${dirpublish%%:*} |
---|
| 91 | host=${userhost##*@} |
---|
[31] | 92 | user=${userhost%%@*} |
---|
[23] | 93 | if [ "${host}" = "cerbere.locean-ipsl.upmc.fr" ] |
---|
| 94 | then |
---|
[31] | 95 | wget -q "http://www.lodyc.jussieu.fr/info_reseau/persoweb/?fastupdate=1&user=${user}" -O /dev/null |
---|
[23] | 96 | fi |
---|
[50] | 97 | else |
---|
| 98 | # urlpublish=http://www.locean-ipsl.upmc.fr/~ginette/produit |
---|
| 99 | dirpublish=${urlpublish##*~} |
---|
| 100 | cd ${dirwww} |
---|
[51] | 101 | lftp -e "mirror -R . ${dirpublish};quit" -u ${LOGNAME} skyros.locean-ipsl.upmc.fr |
---|
[50] | 102 | # ++ log |
---|
| 103 | fi |
---|
| 104 | |
---|
[2] | 105 | ;; |
---|
| 106 | *) |
---|
[50] | 107 | echo "no update of ${dirpublish} or ${urlpublish}" |
---|
[2] | 108 | ;; |
---|
| 109 | esac |
---|
| 110 | # |
---|
| 111 | # normal exit |
---|
| 112 | exit 0 |
---|