Skip to content

Instantly share code, notes, and snippets.

@vivus-ignis
Created February 26, 2012 17:39
Show Gist options
  • Save vivus-ignis/1917901 to your computer and use it in GitHub Desktop.
Save vivus-ignis/1917901 to your computer and use it in GitHub Desktop.
linux + luks startup script
#!/bin/sh
VOLUMES="rt/data:cryptodata:/data"
SERVICES="mysql"
for vol in $VOLUMES
do
unset status
encrypted_lv=`echo $vol | awk -F: '{print $1}'`
decrypted_device=`echo $vol | awk -F: '{print $2}'`
decrypted_mount=`echo $vol | awk -F: '{print $3}'`
cryptsetup luksOpen /dev/${encrypted_lv} ${decrypted_device} \
&& mount /dev/mapper/${decrypted_device} ${decrypted_mount} \
&& status=ok
done
if [ "x$status" = "xok" ]; then
for svc in $SERVICES
do
/etc/init.d/${svc} start
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment