From ad228600dba989475744f9a2142ca4d53ee8cdbe Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Tue, 22 Jan 2013 11:42:48 +0100 Subject: init --- bin/busybox | Bin 0 -> 2057504 bytes bin/ifup | 7 ++++++ bin/resume | Bin 0 -> 1317856 bytes bin/sh | 1 + bin/udhcpc.script | 47 ++++++++++++++++++++++++++++++++++++++ bin/vgchange | 1 + dev/vc/0 | 1 + etc/mtab | 1 + etc/resolv.conf | 1 + etc/suspend.conf | 10 +++++++++ init | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ sbin/cryptsetup | Bin 0 -> 1524840 bytes 12 files changed, 135 insertions(+) create mode 100755 bin/busybox create mode 100755 bin/ifup create mode 100755 bin/resume create mode 120000 bin/sh create mode 100755 bin/udhcpc.script create mode 120000 bin/vgchange create mode 120000 dev/vc/0 create mode 100644 etc/mtab create mode 100644 etc/resolv.conf create mode 100644 etc/suspend.conf create mode 100755 init create mode 100755 sbin/cryptsetup diff --git a/bin/busybox b/bin/busybox new file mode 100755 index 0000000..3d56a2d Binary files /dev/null and b/bin/busybox differ diff --git a/bin/ifup b/bin/ifup new file mode 100755 index 0000000..2b60f1c --- /dev/null +++ b/bin/ifup @@ -0,0 +1,7 @@ +#!/bin/sh + +DEV=$1 + +ifconfig $DEV up +udhcpc -t 5 -q -s /bin/udhcpc.script + diff --git a/bin/resume b/bin/resume new file mode 100755 index 0000000..977924b Binary files /dev/null and b/bin/resume differ diff --git a/bin/sh b/bin/sh new file mode 120000 index 0000000..c3fa810 --- /dev/null +++ b/bin/sh @@ -0,0 +1 @@ +busybox \ No newline at end of file diff --git a/bin/udhcpc.script b/bin/udhcpc.script new file mode 100755 index 0000000..40ee738 --- /dev/null +++ b/bin/udhcpc.script @@ -0,0 +1,47 @@ +#!/bin/sh +# udhcpc script edited by Tim Riker + +RESOLV_CONF="/etc/resolv.conf" + +[ -n "$1" ] || { echo "Error: should be called from udhcpc"; exit 1; } + +NETMASK="" +[ -n "$subnet" ] && NETMASK="netmask $subnet" +BROADCAST="broadcast +" +[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast" + +case "$1" in + deconfig) + echo "Setting IP address 0.0.0.0 on $interface" + ifconfig $interface 0.0.0.0 + ;; + + renew|bound) + echo "Setting IP address $ip on $interface" + ifconfig $interface $ip $NETMASK $BROADCAST + + if [ -n "$router" ] ; then + echo "Deleting routers" + while route del default gw 0.0.0.0 dev $interface ; do + : + done + + metric=0 + for i in $router ; do + echo "Adding router $i" + route add default gw $i dev $interface metric $((metric++)) + done + fi + + echo "Recreating $RESOLV_CONF" + echo -n > $RESOLV_CONF-$$ + [ -n "$domain" ] && echo "search $domain" >> $RESOLV_CONF-$$ + for i in $dns ; do + echo " Adding DNS server $i" + echo "nameserver $i" >> $RESOLV_CONF-$$ + done + mv $RESOLV_CONF-$$ $RESOLV_CONF + ;; +esac + +exit 0 diff --git a/bin/vgchange b/bin/vgchange new file mode 120000 index 0000000..9428656 --- /dev/null +++ b/bin/vgchange @@ -0,0 +1 @@ +lvm \ No newline at end of file diff --git a/dev/vc/0 b/dev/vc/0 new file mode 120000 index 0000000..bea71cc --- /dev/null +++ b/dev/vc/0 @@ -0,0 +1 @@ +../console \ No newline at end of file diff --git a/etc/mtab b/etc/mtab new file mode 100644 index 0000000..17d1d6f --- /dev/null +++ b/etc/mtab @@ -0,0 +1 @@ +none /dev devtmpfs 0 0 diff --git a/etc/resolv.conf b/etc/resolv.conf new file mode 100644 index 0000000..cae093a --- /dev/null +++ b/etc/resolv.conf @@ -0,0 +1 @@ +nameserver 8.8.8.8 diff --git a/etc/suspend.conf b/etc/suspend.conf new file mode 100644 index 0000000..bfc117d --- /dev/null +++ b/etc/suspend.conf @@ -0,0 +1,10 @@ +snapshot device = /dev/snapshot +resume device = /dev/disk/by-label/rootfs +resume offset = 1349272 +#image size = 350000000 +#suspend loglevel = 2 +compute checksum = y +compress = y +#encrypt = y +#early writeout = y +#splash = y diff --git a/init b/init new file mode 100755 index 0000000..acf61d1 --- /dev/null +++ b/init @@ -0,0 +1,66 @@ +#!/bin/busybox sh + +#set -x + +ROOT=/dev/disk/by-label/rootfs +HOME=/dev/disk/by-uuid/092fdc4a-4356-47d9-9272-9a5f58e33bbf + +prep_dev() +{ + for opt in `cat /proc/cmdline`; do + name=$(echo $opt | cut -d'=' -f 1) + if [ $name == "root" ] || [ $name == "resume" ] || [ $name == "crypt_part" ]; then + type=$(echo $opt | cut -d'=' -f 2) + id=$(echo $opt | cut -d'=' -f 3) + if [ $type == LABEL ]; then + prefix="/dev/disk/by-label"; + elif [ $type == UUID ]; then + prefix="/dev/disk/by-uuid" + fi + mkdir -p $prefix + full="$prefix/$id" + if [ ! -e $full ]; then + ln -s $(findfs "$type=$id") $full + fi + fi + done +} + +rescue_shell() +{ + echo "Something went wrong. Dropping you to a shell." + busybox --install -s + exec /bin/sh +} + +cryptsetup_do() +{ + echo "cryptsetup $1 $2" + cryptsetup -T 3 luksOpen $1 $2 +} + +mount_root() +{ + echo "mount root $1" + mount -o ro $1 /newroot +} + +# Mount the /dev, /proc and /sys filesystems. +mount -t devtmpfs none /dev +mount -t proc none /proc +mount -t sysfs none /sys + +# Do your stuff here. +prep_dev +cryptsetup_do $HOME home +resume +mount_root $ROOT || rescue_shell + +# Clean up. +umount /dev +umount /proc +umount /sys + +# Boot the real thing. +exec switch_root /newroot /sbin/init + diff --git a/sbin/cryptsetup b/sbin/cryptsetup new file mode 100755 index 0000000..aae4b30 Binary files /dev/null and b/sbin/cryptsetup differ -- cgit v1.2.3