Initial commit.
This commit is contained in:
commit
2562ac915f
22
install.sh
Executable file
22
install.sh
Executable file
@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#Absolute path to this script
|
||||||
|
SCRIPT=$(readlink -f $0)
|
||||||
|
#Absolute path this script is in
|
||||||
|
SCRIPTPATH=$(dirname $SCRIPT)
|
||||||
|
|
||||||
|
cat << EOF > "/etc/systemd/system/mnt-cinder-volume@.service"
|
||||||
|
[Unit]
|
||||||
|
Description=Mount cinder volume %I
|
||||||
|
Before=docker.service
|
||||||
|
After=network-online.target firewalld.service
|
||||||
|
Wants=network-online.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
User=$SUDO_USER
|
||||||
|
ExecStart=$SCRIPTPATH/mount-cinder-volume.sh %i
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=docker.service
|
||||||
|
EOF
|
||||||
|
systemctl daemon-reload
|
15
mount-cinder-volume.sh
Executable file
15
mount-cinder-volume.sh
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
DIRECTORY=$HOME
|
||||||
|
test -z $1 && { echo "VOLUME variable is not defined."; exit 1; } || VOLUME="$1"
|
||||||
|
test -f $DIRECTORY/openrc.sh || { echo "ERROR: $DIRECTORY/openrc.sh not found, exiting."; exit 1; }
|
||||||
|
source $DIRECTORY/openrc.sh
|
||||||
|
INSTANCE=$($DIRECTORY/env_py3/bin/openstack server show -c id --format value $(hostname))
|
||||||
|
sudo mkdir -p /mnt/volumes/${VOLUME}
|
||||||
|
if ! mountpoint -q /mnt/volumes/${VOLUME}
|
||||||
|
then
|
||||||
|
VOLUME_ID=$($DIRECTORY/env_py3/bin/openstack volume show ${VOLUME} -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/${VOLUME}
|
||||||
|
mountpoint -q /mnt/volumes/${VOLUME} || { echo "ERROR: could not mount /mnt/volumes/${VOLUME}, exiting."; exit 1; }
|
||||||
|
fi
|
Loading…
Reference in New Issue
Block a user