forked from immarvin/xcat-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
executable file
·85 lines (63 loc) · 2.58 KB
/
entrypoint.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
#! /bin/bash
# This script will be run as the ENTRYPOINT of xCAT docker image
# to start xcatd and depended services
# Export the xCAT default Env variables
. /etc/profile.d/xcat.sh
#verify whether $DST is bind mount from $SRC
#function isBINDMOUNT {
# local SRC=$1
# local DST=$2
# SRC=$(echo "$SRC" | sed -r 's/\/$//')
# findmnt -n $DST | awk -F' ' '{print $2}' | grep -E "\[.*$SRC\]" >/dev/null 2>&1 && return 0
# return 1
#}
#mkdir -p /install/postscripts/ && \
# isBINDMOUNT /opt/xcat/postscripts/ /install/postscripts/ || \
# mount -o bind /opt/xcat/postscripts/ /install/postscripts/
#
#
#mkdir -p /install/prescripts/ && \
# isBINDMOUNT /opt/xcat/prescripts/ /install/prescripts/ || \
# mount -o bind /opt/xcat/prescripts/ /install/prescripts/
chown -R root: /var/log/xcat/
#/dev/loop0 and /dev/loop1 will be occupiered by docker by default
#create a loop device if there is no free loop device inside contanier
losetup -f >/dev/null 2>&1 || (
maxloopdev=$(losetup -a|awk -F: '{print $1}'|sort -f -r|head -n1);
maxloopidx=$[${maxloopdev/#\/dev\/loop}];
mknod /dev/loop$[maxloopidx+1] -m0660 b 7 $[maxloopidx+1] && echo "no free loop device inside container,created a new loop device /dev/loop$[maxloopidx+1]..."
)
echo "restarting http service..."
systemctl start httpd.service
echo "restarting ssh service..."
systemctl start sshd.service
echo "restarting dhcpd service..."
systemctl start dhcpd.service
echo "restarting rsyslog service..."
systemctl start rsyslog.service
echo "restarting xcatd service..."
systemctl start xcatd.service
if [ -e "/etc/NEEDINIT" ]; then
echo "initializing xCAT Tables..."
xcatconfig -d
#chdef -t site -o clustersite domain="$clusterdomain"
echo "initializing networks table..."
tabprune networks -a
makenetworks
rm -f /etc/NEEDINIT
fi
#restore the backuped db on container start to resume the service state
if [ -d "/.dbbackup" ]; then
echo "xCAT DB backup directory \"/.dbbackup\" detected, restoring xCAT tables from /.dbbackup/..."
restorexCATdb -p /.dbbackup/
echo "finished xCAT Tables restore!"
fi
. /etc/profile.d/xcat.sh
cat /etc/motd
HOSTIPS=$(ip -o -4 addr show up|grep -v "\<lo\>"|xargs -I{} expr {} : ".*inet \([0-9.]*\).*")
echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
echo "welcome to Dockerized xCAT, please login with"
[ -n "$HOSTIPS" ] && for i in $HOSTIPS;do echo " ssh root@$i ";done && echo "The initial password is \"cluster\""
echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
#read -p "press any key to continue..."
/bin/bash