]> git.ipfire.org Git - thirdparty/dracut.git/blame - test/TEST-16-DMSQUASH/test-init.sh
test: use dd to write status to marker disk
[thirdparty/dracut.git] / test / TEST-16-DMSQUASH / test-init.sh
CommitLineData
ea8e543b 1#!/bin/sh
781f1971
HH
2getcmdline() {
3 while read -r _line || [ -n "$_line" ]; do
b039b20e 4 printf "%s" "$_line"
781f1971
HH
5 done </proc/cmdline;
6}
7
8_dogetarg() {
9 local _o _val _doecho
10 unset _val
11 unset _o
12 unset _doecho
13 CMDLINE=$(getcmdline)
14
15 for _o in $CMDLINE; do
16 if [ "${_o%%=*}" = "${1%%=*}" ]; then
17 if [ -n "${1#*=}" -a "${1#*=*}" != "${1}" ]; then
18 # if $1 has a "=<value>", we want the exact match
19 if [ "$_o" = "$1" ]; then
20 _val="1";
21 unset _doecho
22 fi
23 continue
24 fi
25
26 if [ "${_o#*=}" = "$_o" ]; then
27 # if cmdline argument has no "=<value>", we assume "=1"
28 _val="1";
29 unset _doecho
30 continue
31 fi
32
33 _val="${_o#*=}"
34 _doecho=1
35 fi
36 done
37 if [ -n "$_val" ]; then
38 [ "x$_doecho" != "x" ] && echo "$_val";
39 return 0;
40 fi
41 return 1;
42}
43
44getarg() {
45 local _deprecated _newoption
46 while [ $# -gt 0 ]; do
47 case $1 in
48 -d) _deprecated=1; shift;;
49 -y) if _dogetarg $2 >/dev/null; then
50 if [ "$_deprecated" = "1" ]; then
51 [ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption' instead." || warn "Option '$2' is deprecated."
52 fi
53 echo 1
54 return 0
55 fi
56 _deprecated=0
57 shift 2;;
58 -n) if _dogetarg $2 >/dev/null; then
59 echo 0;
60 if [ "$_deprecated" = "1" ]; then
61 [ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption=0' instead." || warn "Option '$2' is deprecated."
62 fi
63 return 1
64 fi
65 _deprecated=0
66 shift 2;;
67 *) if [ -z "$_newoption" ]; then
68 _newoption="$1"
69 fi
70 if _dogetarg $1; then
71 if [ "$_deprecated" = "1" ]; then
72 [ -n "$_newoption" ] && warn "Kernel command line option '$1' is deprecated, use '$_newoption' instead." || warn "Option '$1' is deprecated."
73 fi
74 return 0;
75 fi
76 _deprecated=0
77 shift;;
78 esac
79 done
80 return 1
81}
82
83getargbool() {
84 local _b
85 unset _b
86 local _default
87 _default="$1"; shift
88 _b=$(getarg "$@")
89 [ $? -ne 0 -a -z "$_b" ] && _b="$_default"
90 if [ -n "$_b" ]; then
91 [ $_b = "0" ] && return 1
92 [ $_b = "no" ] && return 1
93 [ $_b = "off" ] && return 1
94 fi
95 return 0
96}
ea8e543b 97export PATH=/sbin:/bin:/usr/sbin:/usr/bin
9cf339ad 98strstr() { [ "${1##*"$2"*}" != "$1" ]; }
6d58fa27 99CMDLINE=$(while read line || [ -n "$line" ]; do echo $line;done < /proc/cmdline)
ea8e543b
HH
100plymouth --quit
101exec >/dev/console 2>&1
9ca53063 102echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/sdb
ea8e543b
HH
103export TERM=linux
104export PS1='initramfs-test:\w\$ '
105[ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab
106[ -f /etc/fstab ] || ln -sfn /proc/mounts /etc/fstab
107stty sane
108echo "made it to the rootfs!"
781f1971 109getargbool 0 rd.shell && sh -i
ea8e543b
HH
110echo "Powering down."
111mount -n -o remount,ro /
112poweroff -f