-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·60 lines (47 loc) · 1.8 KB
/
entrypoint.sh
File metadata and controls
executable file
·60 lines (47 loc) · 1.8 KB
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
#!/bin/bash
echo "Starting entrypoint script: $0 $*"
if [ "$1" = "relay" ]
then
if [ -f /etc/opensvc/cluster.conf ]
then
echo "Skip relay bootstrap from /config (cluster.conf already exists)"
exec om daemon run
fi
echo "Configuring OpenSVC with cluster name: ${HOSTNAME}"
om cluster create --kw "cluster.name=${HOSTNAME}" --kw "cluster.secret=$(sed -e s/-//g /proc/sys/kernel/random/uuid)" --kw cluster.nodes=${HOSTNAME} --kw disks.schedule=@0 --kw packages.schedule=@0 --kw patches.schedule=@0 --kw sysreport.schedule=@0 --kw asset.schedule=@0 --kw checks.schedule=@0 --kw compliance.schedule=@0
if ls /config/ssl/* >/dev/null 2>&1
then
echo "Processing configuration file for system/sec/cert"
om system/sec/cert create
for file in $(ls /config/ssl/* 2>/dev/null)
do
echo "Processing configuration file: $file"
key=$(basename "$file")
om system/sec/cert key add --name "$key" --from "$file"
done
fi
for file in $(ls /config/users/* 2>/dev/null)
do
RELAY_USER=$(basename $file)
echo "Processing configuration file: $file"
echo $RELAY_USER | egrep -q "^[a-zA-Z]\w*$" || {
echo "Unsupported characters in user name $RELAY_USER"
}
om "system/usr/$RELAY_USER" create --kw grant=heartbeat || {
echo "Failed to create user $RELAY_USER."
exit 1
}
om "system/usr/$RELAY_USER" key add --name password --from "$file" || {
echo "Failed to set password for user $RELAY_USER."
exit 1
}
done
for file in $(ls /config/cluster/* 2>/dev/null)
do
key=$(basename "$file")
om cluster config update --set "$key=$(cat $file)"
done
exec om daemon run
else
exec "$@"
fi