basic (INSECURE!) init system

This commit is contained in:
aheirman 2021-04-17 10:52:02 +00:00
parent 9a3667b66b
commit d4a927cb22
6 changed files with 52 additions and 2 deletions

View file

@ -16,7 +16,7 @@ echo "PARTITION_START=${PARTITION_START}"
#create room for a partition
ls -al iglunix.img -h
dd if=/dev/zero bs=1 count=0 seek=2G of=iglunix.img
dd if=/dev/zero bs=1 count=0 seek=20G of=iglunix.img
ls -al iglunix.img -h
echo "n
@ -68,6 +68,11 @@ cp /etc/vconsole.conf ${ROOT}/etc/vconsole.conf
#TODO: this is a systemd file,
# use udev/kbd
echo "Copying init.d files& inittab"
mkdir ${ROOT}/etc/init.d/
cp -r /iglunix/init/init.d ${ROOT}/etc/
cp /iglunix/init/inittab ${ROOT}/etc/
echo "Unmounting & closing loopback"
umount ${ROOT}

View file

@ -57,7 +57,8 @@ done
echo "Starting switch_root"
exec switch_root /mnt /bin/sh
#exec switch_root /mnt /etc/init.d/rcS
exec switch_root /mnt /sbin/init
EOF

4
init/init.d/net Executable file
View file

@ -0,0 +1,4 @@
#!/bin/sh
ip link set lo up
ip link set eth0 up
udhcpc -i eth0 -x hostname:$(cat /etc/hostname)

29
init/init.d/rcS Executable file
View file

@ -0,0 +1,29 @@
#!/bin/sh
mount -t proc proc /proc
mount -t sysfs sysfs /sys
mount -t tmpfs tmpfs /tmp
echo 0 > /proc/sys/kernel/printk
ln -s /proc/self/fs/0 /dev/stdin
ln -s /proc/self/fs/1 /dev/stdout
ln -s /proc/self/fs/2 /dev/stderr
mkdir -p /dev/pts
mount -t devpts devpts /dev/pts
hostname -F /etc/hostname
mdev -s
mdev -d
mount -a
/etc/init.d/net
/etc/init.d/sshd
#See https://github.com/landley/toybox/issues/111
echo 0 9999999 > /proc/sys/net/ipv4/ping_group_range
/bin/sh

3
init/init.d/sshd Executable file
View file

@ -0,0 +1,3 @@
#!/bin/sh
/usr/sbin/sshd -R -s

8
init/inittab Normal file
View file

@ -0,0 +1,8 @@
::sysinit:/etc/init.d/rcS
::ctrlaltdel:/sbin/reboot
::shutdown:/sbin/swapoff -a
::shutdown:/bin/umount -a -r
::restart:/sbin/init
ttyS0::askfirst:-/bin/sh
::respawn:/sbin/getty 38400 tty1
::respawn:/sbin/getty 38400 tty2