This repository has been archived by the owner on Sep 15, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
build-wrapper.sh
executable file
·58 lines (46 loc) · 1.61 KB
/
build-wrapper.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
#!/bin/bash
#
# Copyright (c) 2015 Uli Fuchs <[email protected]>
# Released under the terms of the MIT License
#
# Gets the value of a given key in '/proc/meminfo'
# @param1 string - key name, e.g. 'MemTotal'
# @return integer - value in MB
function getMemInfo() {
local mem=$(cat /proc/meminfo | grep "$1" | awk '{print $2}')
echo $(expr $mem / 1024)
}
# Checks if the system provides 2048MB _free_ swap space.
# This will be tested by Oracle before the rpm installer runs.
# @return integer - 1 if less than 2048 swap space available otherwise 0
function needExtraSwapSpace() {
local swapFree=$(getMemInfo "SwapFree")
[ $swapFree -lt 2048 ] && echo 1 || echo 0
}
NEED_EXTRASWAP=$(needExtraSwapSpace)
SWAPFILE=/root/swapfile
[ $NEED_EXTRASWAP -eq 1 ] && {
echo
echo ===================================================================================
echo "There are only $(getMemInfo "SwapFree")MB free swap space available but it needs 2048MB."
echo "Creating extra swap space of 2048MB. This takes some seconds..."
sudo dd if=/dev/zero of=$SWAPFILE count=1024 bs=2097152 &> /dev/null
sudo mkswap -c $SWAPFILE
sudo swapon $SWAPFILE
echo
swapon -s
echo ===================================================================================
echo
}
docker build -t "madhead/docker-oracle-xe" .
[ $NEED_EXTRASWAP -eq 1 ] && {
echo
echo ===================================================================================
echo "Removing the extra swap space"
sudo swapoff $SWAPFILE
sudo rm -f $SWAPFILE
echo
swapon -s
echo ===================================================================================
echo
}