-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
executable file
·85 lines (67 loc) · 2.16 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
#!/usr/bin/bash
# Author: Jakub Filak <[email protected]>
set -o nounset
set -o errexit
set -o pipefail
declare -r image="sap_td_os"
function print_help () {
echo "Usage: ./build.sh [-f] [-h|--help] APPLIANCE_DIR"
echo " -f Force build of the docker image"
echo " -h Prints help"
}
if [[ $# < 1 ]]; then
print_help
exit 1
fi
if [[ ${1:-} == "-h" ]] || [[ ${1:-} == "--help" ]]; then
print_help
exit 0
fi
if [[ ${1:-} == "-f" ]]; then
echo "Force image rebuild: removing the image ${image}"
sudo docker rmi ${image}
if sudo docker inspect ${image} &>/dev/null; then
echo "Force image rebuild: the images still exist" 1>&2
exit 1
else
echo "Force image rebuild: removed the image ${image}"
fi
shift
fi
if [[ $# < 1 ]]; then
print_help
exit 1
fi
declare -r appliance_dir=$1
if ! sudo docker inspect ${image} &>/dev/null; then
sudo docker build -t ${image} -f Dockerfile.os . || exit
fi
# docker create --name sap_td_install docker.wdf.sap.corp:51190/dlm/sap_netweaver_install
# docker inspect --format="{{range .Mounts}}{{.Source}}{{end}}" sap_td_install
declare -ar docker_volumes=(sap_td_usrsap sap_td_sapmnt sap_td_sybase)
for volume in ${docker_volumes[@]}; do
if ! sudo docker volume inspect $volume &>/dev/null; then
sudo docker volume create $volume || exit 1
fi
done
if ! sudo docker inspect ${image}_installer &>/dev/null; then
sudo docker run -d -m 4g \
-v $appliance_dir:/opt/sap/td/appliance:ro \
-v /sys/fs/cgroup:/sys/fs/cgroup:ro \
-v sap_td_usrsap:/usr/sap \
-v sap_td_sapmnt:/sapmnt \
-v sap_td_sybase:/sybase \
--privileged \
--hostname vhcalnplci \
--name ${image}_installer \
$image
# give systemd some time to start
sleep 2
fi
sudo docker exec -it ${image}_installer systemctl stop nwabap
sudo docker exec -it ${image}_installer /usr/local/bin/test_drive_install \
--password "P@\$\$w0rd" \
--accept-SAP-developer-license
sudo docker exec -it ${image}_installer su - npladm -c "stopsap ALL"
sudo docker commit ${image}_installer ${image}
./persist.sh