Last active
August 31, 2016 03:27
-
-
Save sneak/15bc75415953baf5105496a8f0b59298 to your computer and use it in GitHub Desktop.
docker/zfs crypto manual startup for hetzner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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