forked from opencurve/curve
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimage.sh
43 lines (37 loc) · 1.01 KB
/
image.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
#!/usr/bin/env bash
# tmpl.sh = /usr/local/metaserver.conf /tmp/metaserver.conf
function tmpl() {
dsv=$1
src=$2
dst=$3
regex="^([^$dsv]+$dsv[[:space:]]*)(.+)__CURVEADM_TEMPLATE__[[:space:]]+(.+)[[:space:]]+__CURVEADM_TEMPLATE__(.*)$"
while IFS= read -r line; do
if [[ ! $line =~ $regex ]]; then
echo "$line"
else
echo "${BASH_REMATCH[1]}${BASH_REMATCH[3]}"
fi
done < $src > $dst
}
prefix="$(pwd)/docker/$2/curvebs"
mkdir -p $prefix $prefix/conf
make install prefix="$prefix"
make install prefix="$prefix" only=etcd
for path in `ls conf/* nebd/etc/nebd/*`;
do
dir=`dirname $path`
file=`basename $path`
# delimiter
dsv="="
if [ $file = "etcd.conf" ]; then
dsv=": "
fi
# destination
dst=$file
if [ $file = "snapshot_clone_server.conf" ]; then
dst="snapshotclone.conf"
fi
tmpl $dsv "$dir/$file" "$prefix/conf/$dst"
done
docker pull opencurvedocker/curve-base:$2
docker build -t "$1" "$(pwd)/docker/$2"