]>
Commit | Line | Data |
---|---|---|
badda27f HH |
1 | #!/bin/sh |
2 | >/dev/watchdog | |
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 | } | |
badda27f | 98 | export PATH=/sbin:/bin:/usr/sbin:/usr/bin |
9cf339ad | 99 | strstr() { [ "${1##*"$2"*}" != "$1" ]; } |
6d58fa27 | 100 | CMDLINE=$(while read line || [ -n "$line" ]; do echo $line;done < /proc/cmdline) |
badda27f HH |
101 | plymouth --quit |
102 | exec </dev/console >/dev/console 2>&1 | |
103 | ||
104 | ismounted() { | |
6d58fa27 | 105 | while read a m a || [ -n "$a" ]; do |
badda27f HH |
106 | [ "$m" = "$1" ] && return 0 |
107 | done < /proc/mounts | |
108 | return 1 | |
109 | } | |
110 | ||
3d115217 HH |
111 | systemctl --failed --no-legend --no-pager > /failed |
112 | ||
83691c41 | 113 | if ismounted /usr && [ ! -s /failed ]; then |
9ca53063 | 114 | echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/sdc |
badda27f | 115 | fi |
3d115217 | 116 | |
ba66cb27 HH |
117 | if ! ismounted /usr; then |
118 | echo "**************************FAILED**************************" | |
119 | echo "/usr not mounted!!" | |
120 | cat /proc/mounts | |
121 | echo "**************************FAILED**************************" | |
122 | fi | |
123 | ||
83691c41 HH |
124 | journalctl --full --no-pager -o short-monotonic |
125 | ||
126 | if [ -s /failed ]; then | |
127 | echo "**************************FAILED**************************" | |
128 | cat /failed | |
129 | echo "**************************FAILED**************************" | |
130 | fi | |
131 | ||
132 | ls -al /run/systemd/system | |
3d115217 | 133 | |
badda27f HH |
134 | export TERM=linux |
135 | export PS1='initramfs-test:\w\$ ' | |
136 | [ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab | |
137 | [ -f /etc/fstab ] || ln -sfn /proc/mounts /etc/fstab | |
138 | stty sane | |
139 | echo "made it to the rootfs!" | |
781f1971 | 140 | if getargbool 0 rd.shell; then |
3d115217 | 141 | # while sleep 1; do sleep 1;done |
badda27f HH |
142 | strstr "$(setsid --help)" "control" && CTTY="-c" |
143 | setsid $CTTY sh -i | |
144 | fi | |
665b7e58 HH |
145 | set -x |
146 | /usr/bin/systemctl poweroff | |
badda27f | 147 | echo "Powering down." |