v0.2 - It works, bitchez!

master
Robert "ar" Gerus 2013-04-30 02:25:18 +02:00
commit 73cf5d5027
8 changed files with 118 additions and 0 deletions

2
bin/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

BIN
busybox Executable file

Binary file not shown.

2
dev/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

106
init Executable file
View File

@ -0,0 +1,106 @@
#!/busybox sh
die() {
echo ""
echo "Shit broke! Panic shell!"
echo ""
/busybox --install -s
exec /bin/sh
}
info() {
echo -n "-|-" ${@} "... "
}
isok() {
if [[ $1 -eq 0 ]]; then
echo "[ OK ]"
else
echo "[ FUCK ]"
die
fi
}
info "waiting for usb devices to settle"
echo ""
for i in 10 9 8 7 6 5 4 3 2 1 0; do
echo -en ${i}'\r'
/busybox sleep 1
done
echo ""
isok 0
info "mounting devtmpfs"
/busybox mount -n -t devtmpfs devtmpfs ./dev
isok $?
info "mounting proc"
/busybox mount -n -t proc proc ./proc
isok $?
# rootfs_location_uuid=f822d881-d88a-4200-a9cf-6986c5a3e69a
info "looking for device with rootfs"
for var in $(cat /proc/cmdline); do
if [[ ${var/=*} = rootfs_location_uuid ]]; then
uuid=${var/*=}
fi
done
device=$(findfs UUID=${uuid})
isok $?
# rootfs_filename=rootfs.tar.xz
info "getting rootfs filename"
for var in $(cat /proc/cmdline); do
if [[ ${var/=*} = rootfs_filename ]]; then
filename=${var/*=}
fi
done
if [[ -z ${filename} ]]; then
info "going with default"
filename=rootfs.tar.xz
fi
isok 0
info "trying to mount ${device}"
/busybox mount -n -o ro ${device} /mnt
isok $?
info "trying to mount root tmpfs"
/busybox mount -n -o size=4G -t tmpfs roottmpfs /roottmpfs
isok $?
info "checking if ${filename} exists"
[[ -e /mnt/${filename} ]]
isok $?
info "unpacking; will take some time"
(
/busybox tar -C /roottmpfs -xJf /mnt/${filename}
isok $?
) &
# progress dots
echo ""
while [[ ! -z "$(jobs)" ]]; do echo -n .; jobs>/dev/null ; sleep 1; done
info "unmounting rootfs package location"
/busybox umount -n /mnt
isok $?
info "unmounting /dev"
/busybox umount -n /dev
isok $?
info "unmounting /proc"
/busybox umount -n /proc
isok $?
info "trying to switch root"
exec /busybox switch_root /roottmpfs /sbin/init
echo ""
echo "we should not reach this place! here be dragons!"
echo ""
die

2
mnt/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

2
proc/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

2
roottmpfs/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

2
sbin/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore