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