Add initramfs-login

This commit is contained in:
nemunaire 2018-02-11 00:21:53 +01:00
parent 5746c8269f
commit e9ddee7ef1
5 changed files with 45 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
tftp/initramfs-login.img

17
Makefile Normal file
View File

@ -0,0 +1,17 @@
all: tftp/initramfs-login.img
login/login: login/*.go
GOOS=linux GOARCH=amd64 go build -tags netgo -ldflags '-w -extldflags "-static -lncurses"' -o $@ ./login
tftp/initramfs-login.img: initramfs-login login/login
mkdir -p $</{bin,sbin,etc,proc,sys} $</usr/share/udhcpc/
cp /bin/busybox $</bin
cp /usr/share/udhcpc/default.script $</usr/share/udhcpc/default.script
ln -sf busybox $</bin/sh
ln -sf busybox $</sbin/hotplug
mkdir -p $</etc/terminfo/l
cp /etc/terminfo/l/linux $</etc/terminfo/l/
cp login/login $</bin
cd $< && find . -print0 | cpio -H newc --null -o | xz --best --check=crc32 > ../$@

View File

@ -0,0 +1 @@
$MODALIAS=.* 0:0 660 @modprobe "$MODALIAS"

15
initramfs-login/init Executable file
View File

@ -0,0 +1,15 @@
#!/bin/sh
mount -t proc proc /proc
mount -t sysfs sysfs /sys
echo 0 > /proc/sys/kernel/printk
busybox --install -s
mknod /dev/null c 1 3
mknod /dev/tty c 5 0
mdev -s
exec setsid sh -c 'exec sh /init2 </dev/tty1 >/dev/tty1 2>&1'

11
initramfs-login/init2 Normal file
View File

@ -0,0 +1,11 @@
#!/bin/sh
for mod in e100 e1000 e1000e 8139cp 8139too r8169 virtio-net; do
modprobe "${mod}"
done
ip link set eth0 up && udhcpc > /dev/null 2> /dev/null &
/bin/login
reboot -f