ACC SHELL

Path : /sbin/
File Upload :
Current File : //sbin/lsinitrd

#!/bin/bash
#
# lsinitrd - show contents of an initrd image
#
# Copyright (C) 2008 SuSE Linux Products GmbH, Nuernberg, Germany
#
# This program 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.
#
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
# USA.

# This file is kept in the following git repository:
#
# git://git.opensuse.org/projects/mkinitrd.git
#

usage() {
    echo "Usage: lsinitrd [-l] [-h] [-c] <initrd>"
}

config=0
while [ "$1" ] ; do
    case $1 in
        -l|--long)
            verbose=1
            shift
            ;;
        -c|--config)
            config=1
            shift
            ;;
        -h)
            usage
            exit 1
            ;;
        -*)
            echo "Unknown option $1"
            usage
            exit 1
            ;;
        *)
            break;
            ;;
    esac
done

initrd=$1

if [ -z "$initrd" ] ; then
    echo "No initrd file specified"
    usage
    exit 1
fi

if [ "$verbose" ] ; then
    args="-tv"
else
    args="-t"
fi

if [ "$config" -eq 1 ] ; then
    # yes, that's snow, but doesn't use any temporary files :)
    for configfile in $(zcat $initrd | cpio $args 2>/dev/null | grep '^config/') ; do
        echo "=========> $configfile <============"
        zcat $initrd | cpio -i --to-stdout $configfile 2>/dev/null
        echo
    done
else
    zcat $initrd | cpio $args
fi

ACC SHELL 2018