summaryrefslogtreecommitdiff
path: root/setup-cryptswap
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2007-01-26 16:34:18 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2007-01-26 16:34:18 +0000
commitcfa5f10a4a1bac5ae573833051dddc3bcad168bf (patch)
tree60b28cb2866f94869e2e59eccca09837b2f56a50 /setup-cryptswap
parentd8b07f75d3bd01f789ac79588bccf33fde5c463d (diff)
downloadalpine-conf-cfa5f10a4a1bac5ae573833051dddc3bcad168bf.zip
added setup-cryptswap
Diffstat (limited to 'setup-cryptswap')
-rwxr-xr-xsetup-cryptswap48
1 files changed, 48 insertions, 0 deletions
diff --git a/setup-cryptswap b/setup-cryptswap
new file mode 100755
index 0000000..0ec11fc
--- /dev/null
+++ b/setup-cryptswap
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+PREFIX=
+. "$PREFIX/lib/libalpine.sh"
+
+
+list_partitions() {
+ awk '$1 ~ /[0-9]/ {print " " $4}' /proc/partitions
+}
+
+
+if [ -z "$1" ] ; then
+ while [ "x$verify" != "xy" ] ; do
+ echo "Available partitions: " $(list_partitions)
+ echon "Use what partition for encrypted swap? [none] "
+ default_read part "none"
+
+ # check if user requested to abort
+ if [ "x$part" = "xabort" ] || [ "x$part" = "xnone" ] ; then
+ exit
+ fi
+ # check if device exist
+ [ -e /dev/$part ] || continue
+
+ # let the user verify
+ echon "Warning! you will lose all data on $part. Continue? (y/n) [n] "
+ default_read verify "n"
+ done
+else
+ part=$1
+fi
+
+
+apk_add cryptsetup-luks
+
+# set the device in /etc/conf.f/cryptswap
+if grep ^DEVICE= /etc/conf.d/cryptswap >/dev/null ; then
+ sed -i 's:^DEVICE=.*:DEVICE=/dev/'$part':' /etc/conf.d/cryptswap
+else
+ echo "DEVICE=/dev/$part" >> /etc/conf.d/cryptswap
+fi
+
+rc_add -k -s 05 cryptswap
+rc_add -k -s 06 swap
+
+/etc/init.d/cryptswap start
+/etc/init.d/swap start
+