source: trunk/softsync/softsync @ 221

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