scripts/mount-docker-sockets.sh

26 lines
729 B
Bash
Executable File

#!/bin/bash
TARGET=/var/run/docker-snowboard.socket
MAX_FAILS=10
SLEEP_TIME=2
echo "removing $TARGET"
rm /var/run/docker-snowboard.sock -rf
echo "relaying snowboards socket with ssh"
ssh -nNT -L /var/run/docker-snowboard.sock:/var/run/docker.sock root@cscherr.de &
# check if the target is a socket, and adjust it.
for ((i=0; i<=MAX_FAILS; i++)); do
if [[ $(file -b /var/run/docker-snowboard.sock) = 'socket' ]]; then
set -e
echo "$TARGET is a socket, adjusting permissions"
chmod 660 /var/run/docker-snowboard.sock
chgrp docker /var/run/docker-snowboard.sock
exit 0 # good end
else
echo "$i: $TARGET is not a socket"
fi
sleep $SLEEP_TIME
done
echo "$TARGET is not a socket even after waiting"
exit 1 # bad end