Skip to content

Instantly share code, notes, and snippets.

@sneak
Last active August 31, 2016 03:27
Show Gist options
  • Save sneak/15bc75415953baf5105496a8f0b59298 to your computer and use it in GitHub Desktop.
Save sneak/15bc75415953baf5105496a8f0b59298 to your computer and use it in GitHub Desktop.
docker/zfs crypto manual startup for hetzner
#!/bin/bash
DEVS="
ata-HGST_HDS724040ALE640_PK1331PAKAKR6S-part1
ata-HGST_HDS724040ALE640_PK1381PAK9YZBS-part1
ata-ST8000AS0002-1NA17Z_Z84064NM-part5
ata-ST8000AS0002-1NA17Z_Z8406C91-part5
"
echo -n "Enter passphrase: "
read -s PASSPHRASE
echo ""
for DEV in $DEVS ; do
if [[ ! -e /dev/mapper/$DEV ]]; then
echo "Unlocking $DEV..."
echo "$PASSPHRASE" | cryptsetup luksOpen /dev/disk/by-id/$DEV $DEV
fi
done
if [[ -d /var/lib/docker/containers ]]; then
if [[ ! -d /var/lib/docker/volumes ]]; then
# it's not yet mounted but it's non-empty from failure of dockerd to start
# remove contents to ensure ensuing import/mount works right
service docker stop
rm -rf /var/lib/docker
mkdir /var/lib/docker
fi
fi
modprobe zfs
zpool import -a
service docker restart
sleep 5
docker ps
docker images
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment