forked from freeipa/freeipa-container
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·138 lines (123 loc) · 3.03 KB
/
install.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
#!/bin/bash
set -e
if [ "$1" == 'help' ] ; then
if [ -n "$IMAGE" ] ; then
sed "s#\$IMAGE#$IMAGE#" /usr/share/ipa/atomic-install-help
else
cat /usr/share/ipa/atomic-install-help
fi
exit
fi
if [ -z "$DATADIR" -o -z "$HOST" ] ; then
echo "Not sure where FreeIPA data should be stored." >&2
exit 1
fi
if [ -f "$HOST$DATADIR"/etc/ipa/default.conf ] ; then
echo "FreeIPA seems already initialized in [$DATADIR]." >&2
exit 1
fi
NAME_PARAM=''
if [ -n "$NAME" ] ; then
NAME_PARAM=" --name $NAME"
fi
mkdir -p "$HOST$DATADIR"
rm -f "$HOST$DATADIR"/docker-run-opts
HOSTNAME_PARAM=
NET_PARAM=
PUBLISH_PARAM=false
CAP_ADD_PARAM=
IP_ADDRESS_PARAM=
while [[ "$#" -ne '0' ]] ; do
case "$1" in
--hostname|hostname)
shift
HOSTNAME_PARAM="$1"
shift
;;
--hostname=*)
HOSTNAME_PARAM="${1#--hostname=}"
shift
;;
hostname=*)
HOSTNAME_PARAM="${1#hostname=}"
shift
;;
net)
shift
NET_PARAM="$1"
shift
;;
net=*)
NET_PARAM="${1#net=}"
shift
;;
net-host)
NET_PARAM="host"
shift
;;
publish)
PUBLISH_PARAM=true
shift
;;
cap-add)
shift
CAP_ADD_PARAM="$1"
shift
;;
cap-add=*)
CAP_ADD_PARAM="${1#cap-add=}"
shift
;;
ip-address)
shift
IP_ADDRESS_PARAM="$1"
shift
;;
ip-address=*)
IP_ADDRESS_PARAM="${1#ip-address=}"
shift
;;
--)
shift
break
;;
*)
break
esac
done
if [ -n "$HOSTNAME_PARAM" ] ; then
echo "-h $HOSTNAME_PARAM" >> "$HOST$DATADIR"/docker-run-opts
echo "$HOSTNAME_PARAM" > "$HOST$DATADIR"/hostname
OPTS="-h $HOSTNAME_PARAM"
elif [[ "$NET_PARAM" != "host" ]] ; then
echo "Please specify the hostname for the server with --hostname parameter." >&2
echo "Usage: atomic install$NAME_PARAM $IMAGE --hostname FQDN.of.the.IPA.server" >&2
exit 1
fi
if [ -n "$NET_PARAM" ] ; then
echo "--net=$NET_PARAM" >> "$HOST$DATADIR"/docker-run-opts
OPTS="$OPTS --net=$NET_PARAM"
fi
if $PUBLISH_PARAM ; then
echo "-p 53:53 -p 80:80 -p 443:443 -p 389:389 -p 636:636 -p 88:88 -p 464:464 -p 7389:7389 -p 9443:9443 -p 9444:9444 -p 9445:9445 -p 53:53/udp -p 88:88/udp -p 464:464/udp" >> "$HOST$DATADIR"/docker-run-opts
OPTS="$OPTS -p 53:53 -p 80:80 -p 443:443 -p 389:389 -p 636:636 -p 88:88 -p 464:464 -p 7389:7389 -p 9443:9443 -p 9444:9444 -p 9445:9445 -p 53:53/udp -p 88:88/udp -p 464:464/udp"
fi
while [ -n "$CAP_ADD_PARAM" ] ; do
echo "--cap-add=${CAP_ADD_PARAM%%:*}" >> "$HOST$DATADIR"/docker-run-opts
OPTS="$OPTS --cap-add=${CAP_ADD_PARAM%%:*}"
if [ "$CAP_ADD_PARAM" == "${CAP_ADD_PARAM#*:}" ] ; then
CAP_ADD_PARAM=''
else
CAP_ADD_PARAM="${CAP_ADD_PARAM#*:}"
fi
done
if [ -n "$IP_ADDRESS_PARAM" ] ; then
echo "-e IPA_SERVER_IP=$IP_ADDRESS_PARAM" >> "$HOST$DATADIR"/docker-run-opts
OPTS="$OPTS -e IPA_SERVER_IP=$IP_ADDRESS_PARAM"
fi
echo "--rm" >> "$HOST$DATADIR"/docker-run-opts
set -x
chroot "$HOST" /usr/bin/docker run -ti --rm $NAME_PARAM \
-e NAME="$NAME" -e IMAGE="$IMAGE" \
-v "$DATADIR":/data:Z -v /sys/fs/cgroup:/sys/fs/cgroup:ro -v /dev/urandom:/dev/random:ro --tmpfs /run --tmpfs /tmp \
$OPTS "$IMAGE" exit-on-finished "$@"