Using systemd to mount volumes and start containers at boot.
This commit is contained in:
parent
640163f4b3
commit
c1af8b11ab
8
create_and_start.sh
Executable file
8
create_and_start.sh
Executable file
@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
#Absolute path to this script
|
||||
SCRIPT=$(readlink -f $0)
|
||||
#Absolute path this script is in
|
||||
SCRIPTPATH=$(dirname $SCRIPT)
|
||||
|
||||
cd $SCRIPTPATH
|
||||
sudo docker-compose up -d
|
@ -5,7 +5,6 @@ services:
|
||||
onlyoffice-document-server:
|
||||
container_name: onlyoffice-document-server
|
||||
image: onlyoffice/documentserver:latest
|
||||
restart: always
|
||||
networks:
|
||||
- reverse-proxy
|
||||
expose:
|
||||
|
42
install.sh
Executable file
42
install.sh
Executable file
@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
#Absolute path to this script
|
||||
SCRIPT=$(readlink -f $0)
|
||||
#Absolute path this script is in
|
||||
SCRIPTPATH=$(dirname $SCRIPT)
|
||||
STACK=$(basename "$SCRIPTPATH")
|
||||
|
||||
for VOLUME in onlyoffice_data onlyoffice_log
|
||||
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
|
||||
|
||||
for VOLUME in onlyoffice_data onlyoffice_log
|
||||
do
|
||||
cat << EOF >> /etc/systemd/system/${STACK}.service
|
||||
After=mnt-cinder-volume@${VOLUME}.service
|
||||
After=mnt-volumes-${VOLUME}.mount
|
||||
Wants=mnt-cinder-volume@${VOLUME}.service
|
||||
Requires=mnt-volumes-${VOLUME}.mount
|
||||
|
||||
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
|
||||
systemctl enable docker-onlyoffice-stack.service
|
25
start.sh
25
start.sh
@ -1,21 +1,8 @@
|
||||
#!/bin/bash
|
||||
source ~/openrc.sh
|
||||
INSTANCE=$(/home/yohan/env_py3/bin/openstack server show -c id --format value $(hostname))
|
||||
sudo mkdir -p /mnt/volumes/onlyoffice_data
|
||||
if ! mountpoint -q /mnt/volumes/onlyoffice_data
|
||||
then
|
||||
VOLUME_ID=$(/home/yohan/env_py3/bin/openstack volume show onlyoffice_data -c id --format value)
|
||||
test -e /dev/disk/by-id/*${VOLUME_ID:0:20} || nova volume-attach $INSTANCE $VOLUME_ID auto
|
||||
sleep 3
|
||||
sudo mount /dev/disk/by-id/*${VOLUME_ID:0:20} /mnt/volumes/onlyoffice_data
|
||||
fi
|
||||
sudo mkdir -p /mnt/volumes/onlyoffice_log
|
||||
if ! mountpoint -q /mnt/volumes/onlyoffice_log
|
||||
then
|
||||
VOLUME_ID=$(/home/yohan/env_py3/bin/openstack volume show onlyoffice_log -c id --format value)
|
||||
test -e /dev/disk/by-id/*${VOLUME_ID:0:20} || nova volume-attach $INSTANCE $VOLUME_ID auto
|
||||
sleep 3
|
||||
sudo mount /dev/disk/by-id/*${VOLUME_ID:0:20} /mnt/volumes/onlyoffice_log
|
||||
fi
|
||||
#Absolute path to this script
|
||||
SCRIPT=$(readlink -f $0)
|
||||
#Absolute path this script is in
|
||||
SCRIPTPATH=$(dirname $SCRIPT)
|
||||
|
||||
sudo docker-compose up -d
|
||||
cd $SCRIPTPATH
|
||||
sudo docker-compose start
|
||||
|
Loading…
Reference in New Issue
Block a user