ports

recipes for building multiple softwares
git clone git://z3bra.org/ports
Log | Files | Refs

commit b314319370e049b6334b83c6ac3d19a0ac727c8a
parent 8110acf4a5b2be42264a678d312a97cdd6e706b8
Author: z3bra <willyatmailoodotorg>
Date:   Sun Aug 16 16:47:47 2015

init: new port

Diffstat:
 init/makeme     | 28 ++++++++++++++++++++++++++++
 init/power.subr | 22 ++++++++++++++++++++++
 init/rc         | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 101 insertions(+), 0 deletions(-)

diff --git a/init/makeme b/init/makeme @@ -0,0 +1,28 @@ +name=init +version=0.0 +source=git://github.com/strake/init +commit=HEAD + +package() { + if cd $name-$version; then + git reset --hard + git pull + else + git clone $source $name-$version + cd $name-$version + fi + + sed 's,/sbin/go,/sbin/rc,' < init.c | sponge init.c + $CC $CFLAGS init.c -o init $LDFLAGS + + mkdir -p $WORKDIR/$name/sbin + mkdir -p $WORKDIR/$name/usr/libexec + cp init $WORKDIR/$name/sbin/init + cp ../rc $WORKDIR/$name/sbin/rc + cp ../power.subr $WORKDIR/$name/usr/libexec/power.subr + + chmod 750 $WORKDIR/$name/sbin/rc + chmod 750 $WORKDIR/$name/usr/libexec/power.subr + ln -sf /usr/libexec/power.subr $WORKDIR/$name/sbin/reboot + ln -sf /usr/libexec/power.subr $WORKDIR/$name/sbin/poweroff +} diff --git a/init/power.subr b/init/power.subr @@ -0,0 +1,22 @@ +#!/bin/sh + +echo system is going down + +echo remounting / read-only +/bin/mount -o remount,ro / + +echo unmounting filesystems +/bin/umount -a + +echo terminating all processes +/bin/killall5 -s TERM +/bin/sleep 2 +/bin/killall5 -s KILL + +/bin/sync +wait + +case $(basename $0) in + reboot) /bin/halt -r ;; + poweroff) /bin/halt -p ;; +esac+ \ No newline at end of file diff --git a/init/rc b/init/rc @@ -0,0 +1,51 @@ +#!/bin/sh + +umask 022 + +echo +echo +echo booting your setup +echo +echo + +/bin/ctrlaltdel -s + +echo mounting virtual filesystem +/bin/mount -n -t proc -o nosuid,noexec,nodev proc /proc +/bin/mount -n -t sysfs -o nosuid,noexec,nodev sys /sys +/bin/mount -n -t tmpfs -o nosuid,mode=0755 dev /dev + +/bin/mkdir -p /dev/pts /dev/shm +/bin/mount -n -t devpts -o gid=5,mode=0620 devpts /dev/pts +/bin/mount -n -t tpmfs -o mode=1777,nosuid,nodev shm /dev/shm + +echo remouting / read-only +/bin/mount -o remount,ro / + +echo running smdev +/bin/smdev -s + +echo setting smdev as the kernel hotplug +echo /bin/smdev > /proc/sys/kernel/hotplug + +/bin/ln -sf /proc/self/fd /dev/fd +/bin/ln -sf /proc/self/fd/0 /dev/stdin +/bin/ln -sf /proc/self/fd/1 /dev/stdout +/bin/ln -sf /proc/self/fd/2 /dev/stderr + +echo mounting filesystem from fstab +/bin/mount -a +ln -sf /proc/mounts /etc/mtab + +echo naming machine \$distro +/bin/hostname \$distro + +:> /var/run/utmp + +echo remounting / read-write +/bin/mount -o remount,rw / + +echo +/bin/respawn /bin/getty /dev/tty0 & +/bin/respawn /bin/getty /dev/tty1 & +/bin/respawn /bin/getty /dev/tty2 &