2020-03-31 12:32:17 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#Absolute path to this script
|
|
|
|
SCRIPT=$(readlink -f $0)
|
|
|
|
#Absolute path this script is in
|
|
|
|
SCRIPTPATH=$(dirname $SCRIPT)
|
|
|
|
STACK=$(basename "$SCRIPTPATH")
|
|
|
|
|
2020-03-31 13:01:38 +00:00
|
|
|
for VOLUME in $(awk NF $SCRIPTPATH/volume_list | tr -d "[:blank:]")
|
2020-03-31 12:32:17 +00:00
|
|
|
do
|
|
|
|
systemctl enable mnt-cinder-volume@${VOLUME}.service
|
|
|
|
done
|
|
|
|
|
|
|
|
cat << EOF > /etc/systemd/system/${STACK}.service
|
|
|
|
[Unit]
|
|
|
|
Description=Starting ${STACK}
|
|
|
|
After=network-online.target firewalld.service docker.service docker.socket
|
|
|
|
Wants=network-online.target docker.service
|
|
|
|
Requires=docker.socket
|
|
|
|
EOF
|
|
|
|
|
2020-03-31 13:01:38 +00:00
|
|
|
for VOLUME in $(awk NF $SCRIPTPATH/volume_list | tr -d "[:blank:]")
|
2020-03-31 12:32:17 +00:00
|
|
|
do
|
2020-03-31 15:52:44 +00:00
|
|
|
VOLUME_ESCAPED=$(systemd-escape ${VOLUME})
|
2020-03-31 12:32:17 +00:00
|
|
|
cat << EOF >> /etc/systemd/system/${STACK}.service
|
2020-04-11 14:17:57 +00:00
|
|
|
After=mnt-cinder-volume@${VOLUME}.service
|
2020-03-31 15:52:44 +00:00
|
|
|
After=mnt-volumes-${VOLUME_ESCAPED}.mount
|
2020-04-11 14:17:57 +00:00
|
|
|
Wants=mnt-cinder-volume@${VOLUME}.service
|
2020-03-31 15:52:44 +00:00
|
|
|
Requires=mnt-volumes-${VOLUME_ESCAPED}.mount
|
2020-03-31 12:32:17 +00:00
|
|
|
|
|
|
|
EOF
|
|
|
|
done
|
|
|
|
|
|
|
|
cat << EOF >> /etc/systemd/system/${STACK}.service
|
|
|
|
[Service]
|
|
|
|
Type=oneshot
|
|
|
|
User=$SUDO_USER
|
|
|
|
ExecStart=$SCRIPTPATH/start.sh
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=multi-user.target
|
|
|
|
EOF
|
|
|
|
systemctl daemon-reload
|
2020-03-31 13:01:38 +00:00
|
|
|
systemctl enable ${STACK}.service
|