[Glibc-bsd-commits] r4067 - in trunk/freebsd-utils/debian: . local local/default
Robert Millan
rmh at alioth.debian.org
Fri Feb 3 23:06:03 UTC 2012
Author: rmh
Date: 2012-02-03 23:06:02 +0000 (Fri, 03 Feb 2012)
New Revision: 4067
Added:
trunk/freebsd-utils/debian/geom.geli.init
trunk/freebsd-utils/debian/local/default/
trunk/freebsd-utils/debian/local/default/geli
Modified:
trunk/freebsd-utils/debian/changelog
trunk/freebsd-utils/debian/geom.install
trunk/freebsd-utils/debian/rules
Log:
Add init script for GELI.
Modified: trunk/freebsd-utils/debian/changelog
===================================================================
--- trunk/freebsd-utils/debian/changelog 2012-02-03 22:29:31 UTC (rev 4066)
+++ trunk/freebsd-utils/debian/changelog 2012-02-03 23:06:02 UTC (rev 4067)
@@ -2,8 +2,9 @@
* Rename freebsd-geom to geom.
* Add geli(8) symlink.
+ * Add init script for GELI.
- -- Robert Millan <rmh at debian.org> Fri, 03 Feb 2012 23:29:26 +0100
+ -- Robert Millan <rmh at debian.org> Sat, 04 Feb 2012 00:05:53 +0100
freebsd-utils (9.0-1) unstable; urgency=low
Added: trunk/freebsd-utils/debian/geom.geli.init
===================================================================
--- trunk/freebsd-utils/debian/geom.geli.init (rev 0)
+++ trunk/freebsd-utils/debian/geom.geli.init 2012-02-03 23:06:02 UTC (rev 4067)
@@ -0,0 +1,186 @@
+#! /bin/sh
+### BEGIN INIT INFO
+# Provides: geli
+# Required-Start: kldutils
+# Required-Stop:
+# X-Start-Before: checkroot
+# X-Stop-After: umountfs
+# Default-Start: S
+# Default-Stop: 0 6
+# Short-Description: Start/stop GELI subsystem.
+# Description:
+### END INIT INFO
+
+# Copyright (c) 2005 Pawel Jakub Dawidek <pjd at FreeBSD.org>
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+
+PATH=/sbin:/bin
+
+. /lib/lsb/init-functions
+. /lib/init/vars.sh
+
+. /etc/default/geli
+
+SYSCTL_N="sysctl -n"
+
+# ltr str src dst
+# Change every $src in $str to $dst.
+ltr()
+{
+ local _str _src _dst
+ _str=$1
+ _src=$2
+ _dst=$3
+ echo "${_str}" | sed -e "s,${_src},${_dst},g"
+}
+
+# Creates a list of providers for GELI encryption.
+geli_make_list()
+{
+ local devices devices2
+ local provider mountpoint type options rest
+
+ # Create list of GELI providers from fstab.
+ while read provider mountpoint type options rest ; do
+ case ":${options}" in
+ :*noauto*)
+ noauto=yes
+ ;;
+ *)
+ noauto=no
+ ;;
+ esac
+
+ case ":${provider}" in
+ :#*)
+ continue
+ ;;
+ *.eli)
+ # Skip swap devices.
+ if [ "${type}" = "swap" -o "${options}" = "sw" -o "${noauto}" = "yes" ]; then
+ continue
+ fi
+ devices="${devices} ${provider}"
+ ;;
+ esac
+ done < /etc/fstab
+
+ # Append providers from geli_devices.
+ devices="${devices} ${geli_devices}"
+
+ for provider in ${devices}; do
+ provider=${provider%.eli}
+ provider=${provider#/dev/}
+ devices2="${devices2} ${provider}"
+ done
+
+ echo ${devices2}
+}
+
+geli_start()
+{
+ log_begin_msg "Starting GELI subsystem..."
+
+ devices=`geli_make_list`
+ if [ -z "${devices}" ]; then
+ log_failure_msg "UNCONFIGURED. See /etc/default/geli"
+ exit 1
+ fi
+
+ log_progress_msg "geom_eli"
+ kldload geom_eli 2> /dev/null
+
+ if [ -z "${geli_tries}" ]; then
+ if [ -n "${geli_attach_attempts}" ]; then
+ # Compatibility with rc.d/gbde.
+ geli_tries=${geli_attach_attempts}
+ else
+ geli_tries=`${SYSCTL_N} kern.geom.eli.tries`
+ fi
+ fi
+
+ for provider in ${devices}; do
+ provider_=`ltr ${provider} '/' '_'`
+
+ eval "flags=\${geli_${provider_}_flags}"
+ if [ -z "${flags}" ]; then
+ flags=${geli_default_flags}
+ fi
+ if [ -e "/dev/${provider}" -a ! -e "/dev/${provider}.eli" ]; then
+ log_progress_msg "${provider}"
+ count=1
+ while [ ${count} -le ${geli_tries} ]; do
+ geli attach ${flags} ${provider}
+ RET=$?
+ if [ -e "/dev/${provider}.eli" ]; then
+ break
+ fi
+ count=$((count+1))
+ done
+ log_end_msg $RET
+ exit $RET
+ fi
+ done
+
+ # end
+ log_end_msg 0
+}
+
+geli_stop()
+{
+ log_begin_msg "Stopping GELI subsystem..."
+
+ devices=`geli_make_list`
+
+ for provider in ${devices}; do
+ if [ -e "/dev/${provider}.eli" ]; then
+ log_progress_msg "${provider}"
+
+ umount "/dev/${provider}.eli" 2>/dev/null
+ geli detach "${provider}"
+ fi
+ done
+
+ # end
+ log_end_msg 0
+}
+
+case "$1" in
+ start|"")
+ geli_start
+ ;;
+ restart|reload|force-reload)
+ echo "Error: argument '$1' not supported" >&2
+ exit 3
+ ;;
+ stop)
+ geli_stop
+ ;;
+ *)
+ echo "Usage: $0 [start|stop]" >&2
+ exit 3
+ ;;
+esac
+
+:
Property changes on: trunk/freebsd-utils/debian/geom.geli.init
___________________________________________________________________
Added: svn:executable
+ *
Modified: trunk/freebsd-utils/debian/geom.install
===================================================================
--- trunk/freebsd-utils/debian/geom.install 2012-02-03 22:29:31 UTC (rev 4066)
+++ trunk/freebsd-utils/debian/geom.install 2012-02-03 23:06:02 UTC (rev 4067)
@@ -10,3 +10,5 @@
sbin/geom/class/sched/geom_sched.so /lib/geom
sbin/geom/class/shsec/geom_shsec.so /lib/geom
sbin/geom/class/stripe/geom_stripe.so /lib/geom
+
+debian/local/default/geli /etc/default
Added: trunk/freebsd-utils/debian/local/default/geli
===================================================================
--- trunk/freebsd-utils/debian/local/default/geli (rev 0)
+++ trunk/freebsd-utils/debian/local/default/geli 2012-02-03 23:06:02 UTC (rev 4067)
@@ -0,0 +1,20 @@
+#
+# Default settings for /etc/init.d/geli
+#
+# Initial setup instructions in:
+# http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/disks-encrypting.html
+#
+
+## List of devices to process. Alternatively, if their corresponding *.eli file
+## is used in /etc/fstab they'll be processed automatically.
+#geli_devices="da2"
+
+## Flags for a specific device.
+#geli_da2_flags="-p -k /root/da2.key"
+
+## Fallback when no device-specific flags are set.
+#geli_default_flags="-p -k /root/default.key"
+
+## How many times to attempt attach before giving up (default is
+## determined by kern.geom.eli.tries).
+#geli_attach_attempts=3
Property changes on: trunk/freebsd-utils/debian/local/default/geli
___________________________________________________________________
Added: svn:executable
+ *
Modified: trunk/freebsd-utils/debian/rules
===================================================================
--- trunk/freebsd-utils/debian/rules 2012-02-03 22:29:31 UTC (rev 4066)
+++ trunk/freebsd-utils/debian/rules 2012-02-03 23:06:02 UTC (rev 4067)
@@ -337,6 +337,7 @@
dh_installinit -pfreebsd-nfs-common --name=nfsiod -- start 20 2 3 4 5 S . stop 20 0 1 6 .
dh_installinit -pfreebsd-nfs-server --name=mountd -- start 20 2 3 4 5 S . stop 80 0 1 6 .
dh_installinit -pfreebsd-nfs-server --name=nfsd -- start 20 2 3 4 5 S . stop 80 0 1 6 .
+ dh_installinit -pgeom --no-restart-on-upgrade --name=geli -- start 26 S . stop 50 0 6 .
# dh_installcron
# dh_installinfo
dh_installman
More information about the Glibc-bsd-commits
mailing list