Skip to content

Commit 9b78ea0

Browse files
committed
Refactor init scripts
1 parent 7420712 commit 9b78ea0

File tree

4 files changed

+25
-8
lines changed

4 files changed

+25
-8
lines changed

config/rootfs-overlay/etc/init.d/rcS

Lines changed: 0 additions & 6 deletions
This file was deleted.

config/rootfs-overlay/etc/rcS.d/S98setup renamed to config/rootfs-overlay/etc/init.d/setup

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
11
#!/bin/sh
2+
### BEGIN INIT INFO
3+
# Provides: setup
4+
# Required-Start: $network
5+
# Required-Stop:
6+
# Default-Start: 2 3 4 5
7+
# Default-Stop:
8+
# Short-Description: Linux Exploit Dev Environment Setup
9+
# Description: Linux Exploit Dev Environment Setup
10+
### END INIT INFO
211

312
case "$1" in
413
start)
14+
# Setup networking
15+
ETH_IF="$(ls /sys/class/net | grep -E '^(eth|enp)')"
16+
ip link set "$ETH_IF" up
17+
if [ -x "$(command -v udhcpc)" ]; then
18+
udhcpc # Busybox DHCP
19+
elif [ -x "$(command -v dhclient)" ]; then
20+
dhclient # Ubuntu DHCP
21+
fi
22+
523
# If the user already exists this won't cause any problems
624
adduser user --disabled-password 2>/dev/null
725

@@ -16,7 +34,7 @@ case "$1" in
1634

1735
# Only mount binder if the kernel supports it
1836
cat /proc/filesystems | grep binder > /dev/null
19-
if [[ $? -eq 0 ]]; then
37+
if [ $? -eq 0 ]; then
2038
mkdir -p /dev/binderfs
2139
mount -t binder binder /dev/binderfs
2240
ln -s /dev/binderfs/binder /dev/binder

config/rootfs-overlay/etc/inittab

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# process == program to run
1515

1616
# Startup the system
17+
::sysinit:/bin/mount -t devtmpfs devtmpfs /dev
1718
::sysinit:/bin/mount -t proc proc /proc
1819
::sysinit:/bin/mount -t sysfs nodev /sys
1920
::sysinit:/bin/mount -o remount,rw /
@@ -26,7 +27,7 @@ null::sysinit:/bin/ln -sf /proc/self/fd/1 /dev/stdout
2627
null::sysinit:/bin/ln -sf /proc/self/fd/2 /dev/stderr
2728
::sysinit:/bin/hostname -F /etc/hostname
2829
# now run any rc scripts
29-
::sysinit:/etc/init.d/rcS
30+
::sysinit:/etc/rc
3031

3132
# Instead of running getty on the serial port, we can directly run a bash login
3233
# shell so we're immediately logged in as root

config/rootfs-overlay/etc/rc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
3+
# TODO: Properly run all rc scripts
4+
/etc/init.d/setup start

0 commit comments

Comments
 (0)