120 lines
3.6 KiB
Bash
Executable file
120 lines
3.6 KiB
Bash
Executable file
#! /bin/sh
|
|
#$BUILD_DIR/config/chroot_local-includes/usr/share/
|
|
# initramfs-tools/scripts/casper-bottom/90cnas_setup_etc
|
|
#
|
|
# Fix files in /etc clobbered by casper at boot time
|
|
#
|
|
# $Id: $
|
|
# Copyright 2005--2008 sense.lab <senselab@systemausfall.org>
|
|
#
|
|
# This file is part of CryptoNAS.
|
|
#
|
|
# CryptoNAS is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 2 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# CryptoNAS is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with CryptoNAS. If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
# 2008-06-21 Adapted from CryptoNAS (dfsbuild) by James Crofts for
|
|
# use with initramfs-tools
|
|
|
|
|
|
# Scripts hooked into initramfs or casper must NOT have odd
|
|
# characters in them due to the way they are parsed.
|
|
# This includes the hyphen '-'. They break the boot system!
|
|
|
|
|
|
#We don't actually depend on these
|
|
#"prerequisites", but if they exist (they do) we must
|
|
#run after them.
|
|
PREREQ="23networking 25configure_init"
|
|
DESCRIPTION="Preconfiguring CryptoNAS Live System..."
|
|
|
|
#Location of "real" root as seen from initramfs
|
|
_CNAS_ROOT_DIR="/root"
|
|
|
|
. /scripts/casper-functions
|
|
|
|
prereqs()
|
|
{
|
|
echo "$PREREQ"
|
|
}
|
|
|
|
case $1 in
|
|
# get pre-requisites
|
|
prereqs)
|
|
prereqs
|
|
exit 0
|
|
;;
|
|
esac
|
|
|
|
log_begin_msg "$DESCRIPTION"
|
|
|
|
. ${_CNAS_ROOT_DIR}/usr/share/cryptonas-live/etc-scoreboard
|
|
|
|
# "/" must be writeable only by root, or else some CryptoNAS
|
|
# scripts will refuse to run for security reasons.
|
|
chmod go-w ${_CNAS_ROOT_DIR}
|
|
|
|
sed -i 's/^id:.*$/id:3:initdefault:/' ${_CNAS_ROOT_DIR}/etc/inittab
|
|
# add tmpfs entry for mount parent
|
|
# remove old line, if fstab exists
|
|
test -e ${_CNAS_ROOT_DIR}/etc/fstab && sed -i '#/var/cache/cryptobox-server/mnt#d' ${_CNAS_ROOT_DIR}/etc/fstab
|
|
# add new line
|
|
echo "tmpfs /var/cache/cryptobox-server/mnt tmpfs defaults 0 0" >> ${_CNAS_ROOT_DIR}/etc/fstab
|
|
|
|
#Set up /etc/modules with user-provided contents ('K' stands for "kernel")
|
|
_CNAS_KMODULES="$CNAS_SCOREBOARD_DIR/etc.d/modules"
|
|
# if $CNAS_KMODULES is not null then use that file as /etc/modules
|
|
if [ -n "$CNAS_KMODULES" ]
|
|
then
|
|
_CNAS_KMODULES="${CNAS_KMODULES}"
|
|
fi
|
|
|
|
#Add root directory prefix
|
|
_CNAS_KMODULES="${_CNAS_ROOT_DIR}${_CNAS_KMODULES}"
|
|
|
|
if [ -f "$_CNAS_KMODULES" ]
|
|
then
|
|
cp ${_CNAS_KMODULES} ${_CNAS_ROOT_DIR}/etc/modules
|
|
fi
|
|
|
|
#Set up /etc/network/interfaces with user-provided contents
|
|
_CNAS_INTERFACES="$CNAS_SCOREBOARD_DIR/etc.d/network/interfaces"
|
|
# if $CNAS_INTERFACES is not null then use that file as /etc/network/interfaces
|
|
if [ -n "$CNAS_INTERFACES" ]
|
|
then
|
|
_CNAS_INTERFACES="${CNAS_INTERFACES}"
|
|
fi
|
|
|
|
#Add root directory prefix
|
|
_CNAS_INTERFACES="${_CNAS_ROOT_DIR}${_CNAS_INTERFACES}"
|
|
|
|
if [ -f "$_CNAS_INTERFACES" ]
|
|
then
|
|
cp ${_CNAS_INTERFACES} ${_CNAS_ROOT_DIR}/etc/network/interfaces
|
|
fi
|
|
|
|
#"hard" and "secure" are synonyms, so test for both of them
|
|
if [ ${CNAS_HARDNESS} = "hard" -o ${CNAS_HARDNESS} = "secure" ]
|
|
then
|
|
|
|
#FIXME: Since we're now doing this important step at runtime,
|
|
# it would be a good idea to call the initramfs-tools
|
|
# function "panic" if the substitution failed. How
|
|
# can we check whether it succeeded?
|
|
# Alternatively, a known-good inittab could be copied
|
|
# from /usr/lib/cryptobox-cd or someplace similar...
|
|
|
|
# disable keyboard login
|
|
sed -i '/getty/d' /etc/inittab
|
|
fi
|
|
|
|
log_end_msg
|