cgdroot.rc revision 1.2
11.2Salnsn#	$NetBSD: cgdroot.rc,v 1.2 2018/12/29 00:52:11 alnsn Exp $
21.1Skhorben#
31.1Skhorben# Copyright (c) 2013 Pierre Pronchery <khorben@defora.org>
41.1Skhorben# All rights reserved.
51.1Skhorben# 
61.1Skhorben# Redistribution and use in source and binary forms, with or without
71.1Skhorben# modification, are permitted provided that the following conditions
81.1Skhorben# are met:
91.1Skhorben# 1. Redistributions of source code must retain the above copyright
101.1Skhorben#    notice, this list of conditions and the following disclaimer.
111.1Skhorben# 2. Redistributions in binary form must reproduce the above copyright
121.1Skhorben#    notice, this list of conditions and the following disclaimer in the
131.1Skhorben#    documentation and/or other materials provided with the distribution.
141.1Skhorben# 
151.1Skhorben# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
161.1Skhorben# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
171.1Skhorben# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
181.1Skhorben# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
191.1Skhorben# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
201.1Skhorben# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
211.1Skhorben# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
221.1Skhorben# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
231.1Skhorben# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
241.1Skhorben# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
251.1Skhorben
261.1SkhorbenPATH=/sbin:/usr/sbin:/bin:/usr/bin
271.1Skhorbenexport PATH
281.1SkhorbenTERM=wsvt25
291.1Skhorbenexport TERM
301.1SkhorbenHOME=/
311.1Skhorbenexport HOME
321.1SkhorbenBLOCKSIZE=1k
331.1Skhorbenexport BLOCKSIZE
341.1SkhorbenEDITOR=ed
351.1Skhorbenexport EDITOR
361.1Skhorben
371.1Skhorbenumask 022
381.1Skhorben
391.2Salnsnmounted=
401.2Salnsnfor dev in NAME=cgd.conf ROOT.a ; do
411.2Salnsn	if mount -o ro $dev /etc/cgd 2>/dev/null ; then
421.2Salnsn		mounted=$dev
431.2Salnsn	fi
441.2Salnsndone
451.2Salnsnif [ -z "$mounted" ]; then
461.1Skhorben	echo "Could not mount the boot partition" 1>&2
471.1Skhorben	exit 2
481.1Skhorbenfi
491.1Skhorben/sbin/wsconsctl -d -w splash.enable=0 > /dev/null 2>&1
501.1Skhorbencgdconfig -C
511.1Skhorbenif [ $? -ne 0 ]; then
521.1Skhorben	echo "Could not decrypt the encrypted volume" 1>&2
531.1Skhorben	umount /etc/cgd
541.1Skhorben	exit 2
551.1Skhorbenfi
561.1Skhorbenmount -o ro /dev/cgd0a /altroot
571.1Skhorbenif [ $? -ne 0 ]; then
581.1Skhorben	echo "Could not mount the root partition" 1>&2
591.1Skhorben	cgdconfig -U
601.1Skhorben	umount /etc/cgd
611.1Skhorben	exit 2
621.1Skhorbenfi
631.1Skhorbenumount /etc/cgd
641.1Skhorben/sbin/wsconsctl -d -w splash.enable=1 > /dev/null 2>&1
651.1Skhorbensysctl -w init.root=/altroot
66