forked from Tauop/sshGate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·118 lines (95 loc) · 3.5 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/bash
#
# Copyright (c) 2010 Linagora
# Patrick Guiran <pguiran@linagora.com>
# http://github.com/Tauop/sshGate
#
# sshGate is free software, you can redistribute it and/or modify
# it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
#
# sshGate is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
action='all'
if [ $# -ne 0 ]; then
[ "$1" = 'client' ] && action='client'
[ "$1" = 'server' ] && action='server'
fi
# Load configuration file
if [ -r /etc/ScriptHelper.conf ]; then
. /etc/ScriptHelper.conf
SCRIPT_HELPER_DIRECTORY="${SCRIPT_HELPER_DIRECTORY:-}"
SCRIPT_HELPER_DIRECTORY="${SCRIPT_HELPER_DIRECTORY%%/}"
else
SCRIPT_HELPER_DIRECTORY='./lib'
fi
if [ ! -d "${SCRIPT_HELPER_DIRECTORY}/" ]; then
echo "ERROR: sshGate depends on ScriptHelper which doesn't seem to be installed"
exit 2
fi
. "${SCRIPT_HELPER_DIRECTORY}/message.lib.sh"
. "${SCRIPT_HELPER_DIRECTORY}/ask.lib.sh"
. "${SCRIPT_HELPER_DIRECTORY}/exec.lib.sh"
# ----------------------------------------------------------------------------
version=
ASK version "sshgate version ?"
# build are used for testing :-) (can be empty)
build=
ASK --allow-empty build "sshGate build number ?"
include_script_helper='N'
if [ "${action}" = 'all' -o "${action}" = 'server' ]; then
ASK --yesno include_script_helper 'Include ScriptHelper in package ?'
fi
# ----------------------------------------------------------------------------
if [ "${action}" = 'all' -o "${action}" = 'client' ]; then
DOTHIS 'Build sshgate-client package'
dir=/tmp/sshGate-client-${version}
[ -n "${build}" ] && dir="${dir}-${build}"
[ -d ${dir}/ ] && CMD rm -rf ${dir}/
CMD mkdir ${dir}/
CMD mkdir ${dir}/lib/
CMD cp COPYING ${dir}/
CMD cp -r ./client/* ${dir}/
CMD cp ./lib/ask.lib.sh ${dir}/lib/
CMD cp ./lib/message.lib.sh ${dir}/lib/
CMD cp ./lib/random.lib.sh ${dir}/lib/
CMD chmod +x ${dir}/install.sh
CMD chmod +x ${dir}/sshg
CMD chmod +x ${dir}/scpg
CMD tar c --transform "'s|^tmp/||S'" -z -f ${dir}.tar.gz ${dir} 2>/dev/null
CMD mv ${dir}.tar.gz .
CMD rm -rf ${dir}
OK
fi
if [ "${action}" = 'all' -o "${action}" = 'server' ]; then
DOTHIS 'Build sshgate-server package'
dir=/tmp/sshGate-server-${version}
[ -n "${build}" ] && dir="${dir}-${build}"
[ -d ${dir}/ ] && CMD rm -rf ${dir}/
CMD mkdir ${dir}/
CMD cp COPYING ${dir}/
CMD cp -r ./server/* ${dir}/
if [ "${include_script_helper}" = 'Y' ]; then
CMD cp -r ./lib/ ${dir}/
fi
# put version and build number
sed_repl=
sed_repl="${sed_repl} s|%% __SSHGATE_VERSION__ %%|${version}|;"
sed_repl="${sed_repl} s|%% __SSHGATE_BUILD__ %%|${build}|;"
sed -i -e "${sed_repl}" "${dir}/install.sh"
sed -i -e "${sed_repl}" "${dir}/sshgate.conf"
CMD chmod +x ${dir}/install.sh
CMD find ${dir}/ -type f -iname "*swp" -exec rm -f {} '\;'
CMD 'find ${dir}/ -iname ".git" | xargs rm -rf'
CMD tar c --transform "'s|^tmp/||S'" -z -f ${dir}.tar.gz ${dir} 2>/dev/null
CMD mv ${dir}.tar.gz .
CMD rm -rf ${dir}
OK
fi