[2] | 1 | #! /bin/sh |
---|
| 2 | #+ |
---|
| 3 | # |
---|
| 4 | # .. _install.sh: |
---|
| 5 | # |
---|
[164] | 6 | # ========== |
---|
| 7 | # install.sh |
---|
| 8 | # ========== |
---|
| 9 | # |
---|
[2] | 10 | # NAME |
---|
| 11 | # ==== |
---|
| 12 | # |
---|
| 13 | # install.sh - publication of HTML files and associated files |
---|
| 14 | # |
---|
| 15 | # SYNOPSIS |
---|
| 16 | # ======== |
---|
| 17 | # |
---|
| 18 | # :: |
---|
| 19 | # |
---|
| 20 | # $ install.sh -w dirwww -p dirpublish -u urlpublish -l login |
---|
| 21 | # |
---|
| 22 | # DESCRIPTION |
---|
| 23 | # =========== |
---|
| 24 | # |
---|
| 25 | # publication (rsync) of dirwww content on dirpublish given in argument |
---|
| 26 | # |
---|
| 27 | # If the host of publication is cerbere.locean-ipsl.upmc.fr, a specific update |
---|
| 28 | # is launched. |
---|
| 29 | # |
---|
| 30 | # -w input directort |
---|
| 31 | # -p output directory |
---|
| 32 | # -u output url |
---|
| 33 | # -l login used to access on output url |
---|
| 34 | # |
---|
| 35 | # EXAMPLES |
---|
| 36 | # ======== |
---|
| 37 | # |
---|
[164] | 38 | # TODO |
---|
| 39 | # ==== |
---|
| 40 | # |
---|
| 41 | # destroy. use fptools one's instead |
---|
| 42 | # |
---|
[2] | 43 | # EVOLUTIONS |
---|
| 44 | # ========== |
---|
| 45 | # |
---|
| 46 | # $Id$ |
---|
| 47 | # |
---|
| 48 | # - fplod 2009-04-27T10:21:23Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 49 | # |
---|
| 50 | # * creation from personnal tool (used for superbib, SAXO, etc.) |
---|
| 51 | # |
---|
| 52 | #- |
---|
| 53 | system=$(uname) |
---|
| 54 | case "${system}" in |
---|
| 55 | AIX|IRIX64) |
---|
| 56 | echo " www : no specific posix checking" |
---|
| 57 | ;; |
---|
| 58 | *) |
---|
| 59 | set -o posix |
---|
| 60 | ;; |
---|
| 61 | esac |
---|
| 62 | # |
---|
[101] | 63 | set -u |
---|
| 64 | # |
---|
[2] | 65 | command=$(basename ${0}) |
---|
| 66 | log_date=$(date -u +"%Y%m%dT%H%M%SZ") |
---|
| 67 | log=/tmp/$(basename ${command} .sh).log.${log_date} |
---|
| 68 | # |
---|
| 69 | usage=" Usage : ${command} -w dirwww -p dirpublish -u urlpublish -l login" |
---|
| 70 | # |
---|
| 71 | minargcount=4 |
---|
| 72 | #echo " narg ${#}" |
---|
| 73 | if [ ${#} -lt ${minargcount} ] |
---|
| 74 | then |
---|
| 75 | echo "eee : not enought arguments" |
---|
| 76 | echo "${usage}" |
---|
| 77 | exit 1 |
---|
| 78 | fi |
---|
| 79 | # |
---|
| 80 | # default |
---|
| 81 | dirpublish="none" |
---|
| 82 | urlpublish="none" |
---|
| 83 | login="none" |
---|
| 84 | # |
---|
[101] | 85 | while [ ${#} -gt 0 ] |
---|
[2] | 86 | do |
---|
| 87 | case ${1} in |
---|
| 88 | -w) |
---|
| 89 | dirwww=${2} |
---|
| 90 | shift |
---|
| 91 | ;; |
---|
| 92 | -p) |
---|
| 93 | dirpublish=${2} |
---|
| 94 | shift |
---|
| 95 | ;; |
---|
| 96 | -u) |
---|
| 97 | urlpublish=${2} |
---|
| 98 | shift |
---|
| 99 | ;; |
---|
| 100 | -l) |
---|
| 101 | login=${2} |
---|
| 102 | shift |
---|
| 103 | ;; |
---|
| 104 | esac |
---|
| 105 | # next flag |
---|
| 106 | shift |
---|
| 107 | done |
---|
| 108 | # |
---|
| 109 | # ++ check directories |
---|
| 110 | # |
---|
| 111 | answer=${1:-" "} |
---|
| 112 | case ${answer} in |
---|
| 113 | y|Y|n|N) |
---|
| 114 | ;; |
---|
| 115 | *) |
---|
| 116 | if [ "${dirpublish}" != "none" ] |
---|
| 117 | then |
---|
| 118 | echo "Do you want to install ${dirwww} on ${dirpublish} (y|[n]) ?" |
---|
| 119 | read answer |
---|
| 120 | fi |
---|
| 121 | if [ "${urlpublish}" != "none" ] |
---|
| 122 | then |
---|
| 123 | echo "Do you want to install ${dirwww} on ${urlpublish} (y|[n]) ?" |
---|
| 124 | read answer |
---|
| 125 | fi |
---|
| 126 | ;; |
---|
| 127 | esac |
---|
| 128 | # |
---|
| 129 | case ${answer} in |
---|
| 130 | y|Y) |
---|
| 131 | if [ "${dirpublish}" != "none" ] |
---|
| 132 | then |
---|
| 133 | # copy of ${dirwww} on $dirpublish |
---|
| 134 | echo "iii : update of ${dirpublish}" |
---|
| 135 | rsync -av --exclude=".DS_Store" -e ssh ${dirwww}/ ${dirpublish} |
---|
| 136 | # detect if in dirpublish following this pattern [USER@]HOST:SRC, HOST |
---|
| 137 | # is cerbere.locean-ipsl.upmc.fr. If so, a specific update is launched |
---|
| 138 | userhost=${dirpublish%%:*} |
---|
| 139 | host=${userhost##*@} |
---|
| 140 | if [ ${login} = "none" ] |
---|
| 141 | then |
---|
| 142 | user=${userhost%%@*} |
---|
| 143 | else |
---|
| 144 | user=${login} |
---|
| 145 | fi |
---|
| 146 | if [ "${host}" = "cerbere.locean-ipsl.upmc.fr" ] |
---|
| 147 | then |
---|
| 148 | wget -q "http://intranet.locean-ipsl.upmc.fr/persoweb/?fastupdate=1&user=${user}" -O /dev/null |
---|
| 149 | fi |
---|
| 150 | else |
---|
| 151 | # urlpublish=http://www.locean-ipsl.upmc.fr/~ginette/produit |
---|
| 152 | dirpublish=${urlpublish##*~} |
---|
| 153 | cd ${dirwww} |
---|
| 154 | #lftp -e "mirror -R . ${dirpublish};quit" -u ${LOGNAME} skyros.locean-ipsl.upmc.fr |
---|
| 155 | lftp -e "mirror -R . ${dirpublish};quit" -u ${LOGNAME} www.locean-ipsl.upmc.fr |
---|
| 156 | # ++ log |
---|
| 157 | fi |
---|
| 158 | ;; |
---|
| 159 | *) |
---|
| 160 | echo "no update of ${dirpublish} or ${urlpublish}" |
---|
| 161 | ;; |
---|
| 162 | esac |
---|
| 163 | # |
---|
| 164 | # normal exit |
---|
| 165 | exit 0 |
---|