This repository has been archived by the owner on Apr 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathikea.sh
213 lines (177 loc) · 4.32 KB
/
ikea.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
#!/bin/sh
#
# Copyright (2019) Petr Ospalý <[email protected]>
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
set -ex
# Stages:
# 1. suite (ISC Kea itself)
# 2. hooks (custom hooks)
STAGE="${1:-suite}"
KEA_INSTALLPREFIX="${KEA_INSTALLPREFIX:-/usr/local}"
MAKE_JOBS="${MAKE_JOBS:-1}"
#
# functions
#
install_kea_runtime_deps()
{
apk update
apk add --no-cache \
boost \
postgresql-client \
mariadb-client \
mariadb-connector-c \
cassandra-cpp-driver \
openssl \
ca-certificates \
curl \
xz \
;
# try to install stable version first, then try from edge or fail
apk add --no-cache log4cplus \
|| \
apk add --no-cache \
--repository http://dl-cdn.alpinelinux.org/alpine/edge/testing \
log4cplus
}
install_kea_build_deps()
{
apk add --no-cache --virtual .build-deps \
build-base \
file \
gnupg \
pkgconf \
automake \
libtool \
docbook-xsl \
libxslt \
doxygen \
openssl-dev \
boost-dev \
postgresql-dev \
mariadb-dev \
musl-dev \
zlib-dev \
bzip2-dev \
sqlite-dev \
cassandra-cpp-driver-dev \
python3-dev \
;
# try to install stable version first, then try from edge or fail
apk add --no-cache log4cplus-dev \
|| \
apk add --no-cache \
--repository http://dl-cdn.alpinelinux.org/alpine/edge/testing \
log4cplus-dev
}
install_kea_from_source()
{
curl -LOR \
"https://ftp.isc.org/isc/kea/${KEA_VERSION}/kea-${KEA_VERSION}.tar.gz{,.sha512.asc}"
mkdir -m 0700 -p /root/.gnupg
gpg2 \
--no-options \
--verbose \
--keyid-format 0xlong \
--keyserver-options \
auto-key-retrieve=true \
--verify \
kea-${KEA_VERSION}.tar.gz*asc \
kea-${KEA_VERSION}.tar.gz
tar xzpf kea-${KEA_VERSION}.tar.gz
rm -rf \
kea-${KEA_VERSION}.tar.gz* \
/root/.gnupg* \
cd kea-${KEA_VERSION}
./configure \
--prefix="${KEA_INSTALLPREFIX}" \
--enable-shell \
--with-mysql=/usr/bin/mysql_config \
--with-pgsql=/usr/bin/pg_config \
--with-cql=/usr/bin/pkg-config \
--with-openssl \
--with-log4cplus=/usr \
;
make -j ${MAKE_JOBS} && make install-strip
cd -
# musl linker search paths
if ! [ -f /etc/ld-musl-$(arch).path ] ; then
echo "/lib:/usr/local/lib:/usr/lib" > /etc/ld-musl-$(arch).path
chmod 0644 /etc/ld-musl-$(arch).path
fi
echo "${KEA_INSTALLPREFIX}/lib" >> /etc/ld-musl-$(arch).path
ldconfig "${KEA_INSTALLPREFIX}/lib"
}
install_hooks_from_source()
{
for hook in /ikea/hooks/*/ ; do
if [ -d "${hook}/${KEA_VERSION}" ] ; then
cd "${hook}/${KEA_VERSION}"
make install
cd -
fi
done
}
clean_apk()
{
apk --purge del .build-deps log4cplus-dev
}
# arg: <variable name>
is_true()
{
_value=$(eval echo "\$${1}" | tr '[:upper:]' '[:lower:]')
case "$_value" in
yes|true)
return 0
;;
esac
return 1
}
#
# main
#
# sanity checks first
if [ -z "$KEA_VERSION" ] ; then
echo "ERROR: Variable 'KEA_VERSION' is unset" 1>&2
exit 1
fi
case "$STAGE" in
suite)
# install packages
install_kea_runtime_deps
install_kea_build_deps
# build and install ISC Kea suite
install_kea_from_source
# delete blob?
if ! is_true KEEP_BUILDBLOB ; then
rm -rf /ikea/kea-${KEA_VERSION}*
fi
;;
hooks)
# install packages
install_kea_runtime_deps
install_kea_build_deps
# build and install ISC Kea hooks
if is_true INSTALL_HOOKS ; then
install_hooks_from_source
fi
# delete blob?
if ! is_true KEEP_BUILDBLOB ; then
rm -rf /ikea/hooks
fi
;;
*)
echo "ERROR: Unknown stage: '${STAGE}' (suite|hooks)" 1>&2
exit 1
;;
esac
# cleanup
if ! is_true KEEP_BUILDDEPS ; then
clean_apk
fi
# delete cache
rm -rf /var/cache/apk/*
exit 0