1
1
#!/bin/busybox sh
2
+ # shellcheck shell=sh
3
+ # shellcheck disable=SC2039
4
+ #
5
+ # Really, this should be ash, not sh, but shellcheck doesn't support ash, see
6
+ # https://github.com/koalaman/shellcheck/issues/853
7
+ # SC2039 is there because of that (local/== unsupported in sh, work in ash)
2
8
3
9
# This is the init script built into the PrawnOS initramfs
4
10
@@ -21,8 +27,8 @@ echo In PrawnOS Init
21
27
22
28
#add this to start shell at desired point
23
29
rescue_shell() {
24
- [ "{$ 1}" != "debug" ] && echo "Something went wrong. Dropping to a shell." > /dev/tty1
25
- [ "{$ 1}" == "debug" ] && echo "Debug flag detected, entering debug shell" > /dev/tty1
30
+ [ "${ 1}" != "debug" ] && echo "Something went wrong. Dropping to a shell." > /dev/tty1
31
+ [ "${ 1}" == "debug" ] && echo "Debug flag detected, entering debug shell" > /dev/tty1
26
32
echo "Something went wrong. Dropping to a shell." > /dev/tty1
27
33
exec setsid /bin/sh -c 'exec /bin/sh </dev/tty1 >/dev/tty1 2>&1'
28
34
}
@@ -53,10 +59,12 @@ rootpartuuid() {
53
59
# if optional count is provided:
54
60
# returns 1 if substring occurs in string < optional count
55
61
# returns 0 otherwise
56
- occur() while case "$1" in (*"$2"*) set -- \
62
+ occur() {
63
+ while case "$1" in (*"$2"*) set -- \
57
64
"${1#*"$2"}" "$2" "${3:-0}" "$((${4:-0}+1))";;
58
65
(*) return "$((${4:-0}<${3:-1}))";;esac
59
66
do : "${_occur:+$((_occur=$4))}";done
67
+ }
60
68
61
69
# mount the bare necesities
62
70
mount -n -t proc proc /proc
93
101
94
102
echo BLKID: ${BLKID} > /dev/tty1
95
103
96
- #If its an mmcblk device, the kernel partiton will p1. If it is a usb device, the partiton will just be 1
97
- #Just want everything before the 1
104
+ # If it's an mmcblk device, the kernel partiton will be p1. If it is a usb device, the partiton will just be 1.
105
+ # Just want everything before the 1
98
106
ROOT_DEV="${BLKID%1:*}"
99
107
echo ROOT_DEV: ${ROOT_DEV} > /dev/tty1
100
108
101
109
# label any partition on the system with RESCUESHELL to enter the initramfs rescue shell before mount and root_switch.
102
110
# you can do this with "cgpt add -i 1 -l RESCUESHELL /dev/sda" for example to label the first partiton of a usb drive.
103
- if [ -n "$(blkid | grep RESCUESHELL)" ]
104
- then
111
+ if blkid | grep -q RESCUESHELL; then
105
112
rescue_shell debug
106
113
fi
107
114
108
115
109
- if [ -n "$(blkid ${ROOT_DEV}2 | grep crypto_LUKS)" ]
110
- then
111
- #decrypt and mount the root filesystem, disable kernel log messages to avoid clashing with the prompt
116
+ if blkid ${ROOT_DEV}2 | grep -q crypto_LUKS; then
117
+ # decrypt and mount the root filesystem, disable kernel log messages to avoid clashing with the prompt
112
118
dmesg -n 2
113
119
echo "Opening encrypted root partition, this will take 30s..."
114
120
cryptsetup --tries 5 luksOpen ${ROOT_DEV}2 luksroot || rescue_shell
0 commit comments