-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit
executable file
·66 lines (59 loc) · 1.17 KB
/
init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env bash
function configure_init()
{
set -x
export PATH=/sbin:/bin
}
function configure_fs()
{
mount -o remount,rw /
mount -t proc proc /proc
mount -t sysfs sys /sys
# /dev/ptmx
mkdir -p /dev/pts
mount -t devpts devpts /dev/pts
}
function configure_net()
{
ip l s dev lo up
dhcpcd eth0
}
function configure_env()
{
local env=(
TERM=xterm
)
export "${env[@]}"
}
function configure_tty_minimum()
{ stty rows 50 cols 182; }
function parse_cmdline()
{
local args i
mapfile -d' ' args < /proc/cmdline
for i in "${args[@]}"; do
local key value
# we do allow backslash escape here
IFS='=' read key value <<<"$i"
[[ -n $value ]] || continue
value="${value%% }"
case "$key" in
eval) eval "$value";;
shell) sh -c "$value";;
env) export "${value?}";;
tty.rows) stty rows "$value";;
tty.cols) stty cols "$value";;
esac
done
}
function main()
{
configure_init
configure_fs
configure_net
configure_env
configure_tty_minimum
parse_cmdline
tmux || bash
}
main "$@"