source: trunk/softsync/softsync @ 129

Last change on this file since 129 was 129, checked in by g7moreau, 7 years ago
  • Initial releases of softsync for internal repository
File size: 2.8 KB
Line 
1#!/bin/bash
2#
3# 2014/09/09 Gabriel Moreau
4
5export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin
6export LANG=C
7
8
9function usage() {
10   cat <<END_USAGE
11NAME
12   $(basename $0) - deploy soft
13
14SYNOPSIS
15   $0 -a arch -n soft_name -r release_number [-v] [-h]
16
17OPTIONS
18   -a  arch : 32_bit / 64_bit
19   -n  name of the soft, example: matlab
20   -r  release number of the soft, example: 2.3.1
21   -o  os distribution name
22   -d  delete (mirror) mode
23   -v  verbose
24   -h  help
25
26AUTHOR
27   Gabriel Moreau
28
29COPYRIGHT
30   Copyright (C) 2014-2017, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France
31   Licence : GNU GPL version 2 or later
32END_USAGE
33   }
34
35MyVarRSCmd="/usr/bin/ionice -c 3 /usr/bin/nice -18 /usr/bin/rsync"
36MyVarRSOpt="--contimeout=3 --timeout=3 --bwlimit=5000 --rsync-path='/usr/bin/ionice -c 3 /usr/bin/nice -18 /usr/bin/rsync'"
37
38# get options
39if [ $# -eq 0 ]; then usage; exit 1; fi 
40while getopts "a:n:r:o:dvh" options
41do
42   case ${options} in
43      a)
44         if echo ${OPTARG} | egrep -q '^[[:digit:]]+'
45         then
46            export MyVarOSArch=${OPTARG}
47         else
48            usage
49            exit 2
50         fi
51         ;;
52
53      n)
54         if echo ${OPTARG} | egrep -q '[[:alpha:]]'
55         then
56            export soft_name=${OPTARG}
57         else
58            usage
59            exit 2
60         fi
61         ;;
62
63      r)
64         if echo ${OPTARG} | egrep -q '[[:digit:]]'
65         then
66            export soft_version=${OPTARG}
67         else
68            usage
69            exit 2
70         fi
71         ;;
72
73      o)
74         if echo ${OPTARG} | egrep -q '[[:alpha:]]'
75         then
76            export os_name=${OPTARG}
77         else
78            usage
79            exit 2
80         fi
81         ;;
82
83      d)
84         export MyVarRSOpt="${MyVarRSOpt} --delete"
85         ;;
86
87      v)
88         export verbose='yes'
89         ;;
90
91      h|*)
92         usage
93         exit 3
94         ;;
95   esac
96done
97
98
99MyVarRSShare="legilnx40::opt/${MyVarOSArch}"
100soft_version_server=${soft_version}
101if [ -n "${os_name}" ]
102then
103   soft_version_server="${soft_version}..dist.${os_name}"
104fi
105
106[ -d "/opt/${soft_name}" ] || mkdir -p "/opt/${soft_name}"
107if eval ${MyVarRSCmd} -avn ${MyVarRSOpt} ${MyVarRSShare}/${soft_name}/.zz-end.${soft_version_server} /opt/${soft_name}/.zz-end.${soft_version} \
108      | /bin/grep -q ^\.zz-end
109then
110   rm -f /opt/${soft_name}/.zz-end.${soft_version}
111   [ "${verbose}" == "yes" ] && \
112      echo ${MyVarRSCmd} -avz ${MyVarRSOpt} ${MyVarRSShare}/${soft_name}/${soft_version_server}/ /opt/${soft_name}/${soft_version}/
113   if eval ${MyVarRSCmd} -avz ${MyVarRSOpt} ${MyVarRSShare}/${soft_name}/${soft_version_server}/ /opt/${soft_name}/${soft_version}/
114   then
115      chmod ugo+rX /opt/${soft_name}/
116      eval ${MyVarRSCmd} -aq ${MyVarRSOpt} ${MyVarRSShare}/${soft_name}/.zz-end.${soft_version_server} /opt/${soft_name}/.zz-end.${soft_version}
117   fi
118fi
Note: See TracBrowser for help on using the repository browser.