forked from rootfs/rhcs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·84 lines (76 loc) · 2.09 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
#!/bin/bash
function mon_systemd {
cat <<EOF > ${HOST}/etc/systemd/system/multi-user.target.wants/ceph-mon@${MON_NAME}.service
[Unit]
Description=Ceph Monitor
After=docker.service
[Service]
EnvironmentFile=/etc/environment
ExecStartPre=-/usr/bin/docker stop %i
ExecStartPre=/usr/bin/mkdir -p /etc/ceph /var/lib/ceph/mon
ExecStart=/usr/bin/docker run --rm --name %i --net=host \
-v /var/lib/ceph:/var/lib/ceph \
-v /etc/ceph:/etc/ceph \
--privileged \
-e CEPH_DAEMON=MON \
-e MON_IP=${MON_IP} \
-e CEPH_PUBLIC_NETWORK=${CEPH_PUBLIC_NETWORK} \
-e MON_NAME=${MON_NAME} \
--name=${MON_NAME} \
${IMAGE}
ExecStopPost=-/usr/bin/docker stop %i
Restart=always
RestartSec=10s
TimeoutStartSec=120
TimeoutStopSec=15
[Install]
WantedBy=multi-user.target
EOF
}
function osd_systemd {
cat <<EOF > ${HOST}/etc/systemd/system/multi-user.target.wants/ceph-osd@${DEVICE}.service
[Unit]
Description=Ceph OSD
After=docker.service
[Service]
EnvironmentFile=/etc/environment
ExecStartPre=-/usr/bin/docker stop osd-dev%i
ExecStartPre=-/usr/bin/docker rm osd-dev%i
ExecStart=/usr/bin/docker run --rm --net=host --pid=host\
-v /var/lib/ceph:/var/lib/ceph \
-v /etc/ceph:/etc/ceph \
-v /dev:/dev \
--privileged \
-e CEPH_DAEMON=OSD_CEPH_DISK_ACTIVATE \
-e OSD_DEVICE=/dev/%i \
--name=dev%i \
hchen/rhceph
ExecStop=-/usr/bin/docker stop osd-dev%i
ExecStopPost=-/usr/bin/docker rm osd-dev%i
Restart=always
RestartSec=10s
TimeoutStartSec=120
TimeoutStopSec=15
[Install]
WantedBy=multi-user.target
EOF
}
# Normalize DAEMON to lowercase
CEPH_DAEMON=$(echo ${CEPH_DAEMON} |tr '[:upper:]' '[:lower:]')
case "$CEPH_DAEMON" in
mon)
mon_systemd
;;
osd)
DEVICE=`echo ${OSD_DEVICE}|sed 's/\/dev\///g'`
osd_systemd
;;
*)
if [ ! -n "$CEPH_DAEMON" ]; then
echo "ERROR- One of CEPH_DAEMON or a daemon parameter must be defined as the name "
echo "of the daemon you want to install."
echo "Valid values for CEPH_DAEMON are MON, OSD, MDS, RGW, RESTAPI"
exit 1
fi
;;
esac