rpms/kexec-tools/devel/kdump_dracut_modules/99kdumpbase check, NONE, 1.1 dracut-lib.sh, NONE, 1.1 initqueue, NONE, 1.1 install, NONE, 1.1 parse-blacklist.sh, NONE, 1.1 parse-root-opts.sh, NONE, 1.1 selinux-loadpolicy.sh, NONE, 1.1

Neil Horman nhorman at fedoraproject.org
Wed Jul 29 19:34:48 UTC 2009


Author: nhorman

Update of /cvs/extras/rpms/kexec-tools/devel/kdump_dracut_modules/99kdumpbase
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv27916/kdump_dracut_modules/99kdumpbase

Added Files:
	check dracut-lib.sh initqueue install parse-blacklist.sh 
	parse-root-opts.sh selinux-loadpolicy.sh 
Log Message:
Starting mkdumprd2 -> dracut conversion


--- NEW FILE check ---
#!/bin/bash
[[ $1 = -d ]] && echo udev-rules 
exit 0


--- NEW FILE dracut-lib.sh ---
getarg() {
    local o line
    if [ -z "$CMDLINE" ]; then
	read CMDLINE_ETC </etc/cmdline;
	read CMDLINE </proc/cmdline;
	CMDLINE="$CMDLINE $CMDLINE_ETC"
    fi
    for o in $CMDLINE; do
	[ "$o" = "$1" ] && return 0
	[ "${o%%=*}" = "${1%=}" ] && { echo ${o#*=}; return 0; }
    done
    return 1
}

getargs() {
    local o line found
    if [ -z "$CMDLINE" ]; then
	read CMDLINE_ETC </etc/cmdline;
	read CMDLINE </proc/cmdline;
	CMDLINE="$CMDLINE $CMDLINE_ETC"
    fi
    for o in $CMDLINE; do
	[ "$o" = "$1" ] && return 0
	if [ "${o%%=*}" = "${1%=}" ]; then
	    echo -n "${o#*=} "; 
	    found=1;
	fi
    done
    [ -n "$found" ] && return 0
    return 1
}

source_all() {
    local f
    [ "$1" ] && [  -d "/$1" ] || return
    for f in "/$1"/*.sh; do [ -f "$f" ] && . "$f"; done
}

source_conf() {
    local f
    [ "$1" ] && [  -d "/$1" ] || return
    for f in "/$1"/*.conf; do [ -f "$f" ] && . "$f"; done
}

die() {
    {
        echo "<1>dracut: FATAL: $@";
        echo "<1>dracut: Refusing to continue";
    } > /dev/kmsg

    { 
        echo "dracut: FATAL: $@";
        echo "dracut: Refusing to continue";
    } >&2
    
    exit 1
}

warn() {
    echo "<4>dracut Warning: $@" > /dev/kmsg
    echo "dracut Warning: $@" >&2
}

info() {
    if [ -z "$DRACUT_QUIET" ]; then
	DRACUT_QUIET="no"
	getarg quiet && DRACUT_QUIET="yes"
    fi
    echo "<6>dracut: $@" > /dev/kmsg
    [ "$DRACUT_QUIET" != "yes" ] && \
	echo "dracut: $@" 
}

vinfo() {
    while read line; do 
        info $line;
    done
}

check_occurances() {
    # Count the number of times the character $ch occurs in $str
    # Return 0 if the count matches the expected number, 1 otherwise
    local str="$1"
    local ch="$2"
    local expected="$3"
    local count=0

    while [ "${str#*$ch}" != "${str}" ]; do
	str="${str#*$ch}"
	count=$(( $count + 1 ))
    done

    [ $count -eq $expected ]
}

incol2() {
    local dummy check;
    local file="$1";
    local str="$2";

    [ -z "$file" ] && return;
    [ -z "$str"  ] && return;

    while read dummy check restofline; do
	[ "$check" = "$str" ] && return 0
    done < $file
    return 1
}


--- NEW FILE initqueue ---
#!/bin/sh

if [ "$1" = "--onetime" ]; then
    onetime="yes"
    shift
fi
echo "$@" > /tmp/$$.sh
if [ -n "$onetime" ]; then
   echo '[ -e "$job" ] && rm "$job"' >> /tmp/$$.sh
fi
mv /tmp/$$.sh /initqueue/
>> /initqueue/work


--- NEW FILE install ---
#!/bin/bash
dracut_install mount mknod mkdir modprobe pidof sleep chroot \
    sed ls flock cp mv dmesg rm ln
if [ ! -e "${initdir}/bin/sh" ]; then
    dracut_install bash
    (ln -s bash "${initdir}/bin/sh" || :)
fi
# install our scripts and hooks
inst "/etc/kdump-adv-conf/init" "/init"
inst "$moddir/initqueue" "/sbin/initqueue"
mkdir -p ${initdir}/initqueue
mkdir -p ${initdir}/tmp
# Bail out if switch_root does not exist
if which switch_root >/dev/null 2>&1; then
    dracut_install switch_root 
else
    inst "$moddir/switch_root" "/sbin/switch_root" \
	|| derror "Failed to install switch_root"
fi
inst "$moddir/dracut-lib.sh" "/lib/dracut-lib.sh"
inst_hook cmdline 10 "$moddir/parse-root-opts.sh"
inst_hook cmdline 20 "$moddir/parse-blacklist.sh"
inst_hook pre-pivot 50 "$moddir/selinux-loadpolicy.sh"


--- NEW FILE parse-blacklist.sh ---
#!/bin/sh

for p in $(getargs rdblacklist=); do 
     echo "blacklist $p" >> /etc/modprobe.d/initramfsblacklist.conf
done


--- NEW FILE parse-root-opts.sh ---
root=$(getarg root=)

if rflags="$(getarg rootflags=)"; then
    getarg rw && rflags="${rflags},rw" || rflags="${rflags},ro"
else
    getarg rw && rflags=rw || rflags=ro
fi

fstype="$(getarg rootfstype=)"
if [ -z "$fstype" ]; then
    fstype="auto"
fi



--- NEW FILE selinux-loadpolicy.sh ---
#!/bin/sh
# FIXME: load selinux policy.  this should really be done after we switchroot 
if [ -x "$NEWROOT/usr/sbin/load_policy" ] && [ -e "$NEWROOT/etc/sysconfig/selinux" ]; then
    chroot $NEWROOT /usr/sbin/load_policy -i
    if [ $? -eq 3 ]; then
	echo "Initial SELinux policy load failed and enforcing mode requested."
	echo "Not continuing"
	sleep 100d
	exit 1
    fi
fi




More information about the fedora-extras-commits mailing list