diff options
Diffstat (limited to 'main/busybox-initscripts')
22 files changed, 552 insertions, 0 deletions
diff --git a/main/busybox-initscripts/APKBUILD b/main/busybox-initscripts/APKBUILD new file mode 100644 index 0000000000..6dc784924d --- /dev/null +++ b/main/busybox-initscripts/APKBUILD @@ -0,0 +1,54 @@ +# Contributor: Natanael Copa <ncopa@alpinelinux.org> +# Maintainer: Natanael Copa <ncopa@alpinelinux.org> +pkgname=busybox-initscripts +pkgver=2.0 +pkgrel=2 +pkgdesc="Init scripts for busybox daemons" +url="http://git.alpinelinux.org/cgit/aports/tree/core/busybox-initscripts" +license="GPL-2" +depends="busybox" +makedepends= +install=$pkgname.post-install +subpackages= +source="cron.initd dnsd.initd httpd.initd inetd.initd klogd.initd + mdev-mount.initd mdev.initd rdate.initd syslog.initd watchdog.initd + cron.confd klogd.confd rdate.confd syslog.confd watchdog.confd + mdev.conf dvbdev ide_links usbdev usbdisk_link + $install" + +build() { + local i + cd "$srcdir" + + mkdir -p "$pkgdir"/etc/conf.d "$pkgdir"/etc/init.d "$pkgdir"/lib/mdev + for i in *.initd; do + install -m755 "$srcdir"/$i "$pkgdir"/etc/init.d/${i%.*} || return 1 + done + for i in *.confd; do + install -m644 "$srcdir"/$i "$pkgdir"/etc/conf.d/${i%.*} || return 1 + done + install -m644 mdev.conf "$pkgdir"/etc + install -m755 dvbdev ide_links usbdev usbdisk_link "$pkgdir"/lib/mdev/ +} + +md5sums="45b4ca78fad54f56018b9a2e9358dc68 cron.initd +3af526f4de1a607f7932a15f7c8e8eb1 dnsd.initd +f7daf05f9984aa398fdbd3fe02e82678 httpd.initd +dad8e381142dfb42483de324aff4cf28 inetd.initd +e22077bfe7b8b0fe7c06cfe208e68dca klogd.initd +12379687c0cfb5446e0cfc20bd6992bb mdev-mount.initd +ef3e93fe17964dd600364b1340654b5b mdev.initd +533288e7df1fdfc029b1048b8e6c770f rdate.initd +b5b23dd06cea120bd8d850b54bca0b59 syslog.initd +254186e513ff9fb9ede6a2e92257b247 watchdog.initd +8ddb8d040c9c7a32c63039a2c80ff496 cron.confd +60bc14cc3163d76f41bcc93dc0f9984b klogd.confd +22adbf155ffc4595206ded6daad07812 rdate.confd +77fb31a75511247bf4e3430565a276bc syslog.confd +0bb55dde32f5e119111fa4938daaef3d watchdog.confd +022b670c549e402573797cc72fa12032 mdev.conf +ad1556961294e4aa2abca6be52138b7c dvbdev +5c8725b4cbdeda23b00f08124a0d20bf ide_links +1acfd58dfd1cf324c90ca3a3be519510 usbdev +30b0c85956b6701caf55309a17e537f6 usbdisk_link +038db8453f57a36afaee2a4d883008e4 busybox-initscripts.post-install" diff --git a/main/busybox-initscripts/busybox-initscripts.post-install b/main/busybox-initscripts/busybox-initscripts.post-install new file mode 100644 index 0000000000..11575f58b9 --- /dev/null +++ b/main/busybox-initscripts/busybox-initscripts.post-install @@ -0,0 +1,9 @@ +#!/bin/sh + +# this is for upgraders +if [ -L /etc/runlevels/boot/mdev ]; then + mkdir -p /etc/runlevels/sysinit + mv /etc/runlevels/boot/mdev /etc/runlevels/sysinit/ 2>/dev/null +fi +exit 0 + diff --git a/main/busybox-initscripts/cron.confd b/main/busybox-initscripts/cron.confd new file mode 100644 index 0000000000..2f2eb7bb75 --- /dev/null +++ b/main/busybox-initscripts/cron.confd @@ -0,0 +1,3 @@ +# enter the cron options +CRON_OPTS="-c /etc/crontabs" + diff --git a/main/busybox-initscripts/cron.initd b/main/busybox-initscripts/cron.initd new file mode 100644 index 0000000000..ffae38b806 --- /dev/null +++ b/main/busybox-initscripts/cron.initd @@ -0,0 +1,14 @@ +#!/sbin/runscript + +start() { + ebegin "Starting busybox cron" + start-stop-daemon --start --exec /usr/sbin/crond -- $CRON_OPTS + eend $? +} + +stop () { + ebegin "Stopping busybox cron" + start-stop-daemon --stop --exec crond + eend $? +} + diff --git a/main/busybox-initscripts/dnsd.initd b/main/busybox-initscripts/dnsd.initd new file mode 100644 index 0000000000..8d625f9e5e --- /dev/null +++ b/main/busybox-initscripts/dnsd.initd @@ -0,0 +1,17 @@ +#!/sbin/runscript + +depend() { + need net +} + +start() { + ebegin "Starting dnsd" + start-stop-daemon --start --exec /usr/sbin/dnsd -- -d $DNSD_OPTS + eend $? +} + +stop () { + ebegin "Stopping dnsd" + start-stop-daemon --stop --exec /usr/sbin/dnsd + eend $? +} diff --git a/main/busybox-initscripts/dvbdev b/main/busybox-initscripts/dvbdev new file mode 100644 index 0000000000..f0186c176c --- /dev/null +++ b/main/busybox-initscripts/dvbdev @@ -0,0 +1,18 @@ +#!/bin/sh + +# MDEV=dvb0.demux1 -> ADAPTER=dvb0 -> N=0 +ADAPTER=${MDEV%.*} +N=${ADAPTER#dvb} +# MDEV=dvb0.demux1 -> DEVB_DEV=demux1 +DVB_DEV=${MDEV#*.} + +case "$ACTION" in + add|"") + mkdir -p dvb/adapter${N} + mv ${MDEV} dvb/adapter${N}/${DVB_DEV} + ;; + remove) + rm -f dvb/adapter${N}/${DVB_DEV} + rmdir dvb/adapter${N} 2>/dev/null + rmdir dvb/ 2>/dev/null +esac diff --git a/main/busybox-initscripts/httpd.initd b/main/busybox-initscripts/httpd.initd new file mode 100644 index 0000000000..7f114e650c --- /dev/null +++ b/main/busybox-initscripts/httpd.initd @@ -0,0 +1,20 @@ +#!/sbin/runscript + +DAEMON=/usr/sbin/httpd + +depend() { + need net +} + +start() { + ebegin "Starting busybox httpd" + start-stop-daemon --start --exec $DAEMON -- $HTTPD_OPTS + eend $? +} + +stop () { + ebegin "Stopping busybox httpd" + start-stop-daemon --stop --exec $DAEMON + eend $? +} + diff --git a/main/busybox-initscripts/ide_links b/main/busybox-initscripts/ide_links new file mode 100644 index 0000000000..be0c95aa9c --- /dev/null +++ b/main/busybox-initscripts/ide_links @@ -0,0 +1,23 @@ +#!/bin/sh + +[ -f /proc/ide/$MDEV/media ] || exit + +media=`cat /proc/ide/$MDEV/media` +for i in $media $media[0-9]* ; do + if [ "`readlink $i 2>/dev/null`" = $MDEV ] ; then + LINK=$i + break + fi +done + +# link exist, remove if necessary and exit +if [ "$LINK" ] ; then + [ "$ACTION" = remove ] && rm $LINK + exit +fi + +# create a link +num=`ls $media[0-9]* 2>/dev/null | wc -l` +ln -sf $MDEV "$media`echo $num`" +[ -e "$media" ] || ln -sf $MDEV "$media" + diff --git a/main/busybox-initscripts/inetd.initd b/main/busybox-initscripts/inetd.initd new file mode 100644 index 0000000000..b5cf9d7d3e --- /dev/null +++ b/main/busybox-initscripts/inetd.initd @@ -0,0 +1,18 @@ +#!/sbin/runscript + +depend() { + need net +} + +start() { + ebegin "Starting busybox inetd" + start-stop-daemon --start --exec /usr/sbin/inetd -- $INETD_OPTS + eend $? +} + +stop () { + ebegin "Stopping busybox inetd" + start-stop-daemon --stop --exec /usr/sbin/inetd + eend $? +} + diff --git a/main/busybox-initscripts/klogd.confd b/main/busybox-initscripts/klogd.confd new file mode 100644 index 0000000000..100deedaac --- /dev/null +++ b/main/busybox-initscripts/klogd.confd @@ -0,0 +1 @@ +KLOGD_OPTS="" diff --git a/main/busybox-initscripts/klogd.initd b/main/busybox-initscripts/klogd.initd new file mode 100644 index 0000000000..5cf7e6fd16 --- /dev/null +++ b/main/busybox-initscripts/klogd.initd @@ -0,0 +1,20 @@ +#!/sbin/runscript + +depend() { + need clock hostname + provide logger + keyword novserver +} + +start() { + ebegin "Starting busybox kernel logging" + start-stop-daemon --start --exec /sbin/klogd -- ${KLOGD_OPTS} + eend $? +} + +stop () { + ebegin "Stopping busybox kernel logging" + start-stop-daemon --stop --exec /sbin/klogd + eend $? +} + diff --git a/main/busybox-initscripts/mdev-mount.initd b/main/busybox-initscripts/mdev-mount.initd new file mode 100644 index 0000000000..c7aaa824c2 --- /dev/null +++ b/main/busybox-initscripts/mdev-mount.initd @@ -0,0 +1,64 @@ +#!/sbin/runscript +# Largely based on Gentoo's udev-mount +# +# Copyright 1999-2008 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# + +description="Mount tmpfs on /dev" + +mount_dev_directory() +{ + if [ "$(mountinfo -t /dev)" = "mdev" ]; then + # already mounted + if fstabinfo --quiet /dev; then + mount -o remount -n /dev + fi + return 0 + fi + + # No options are processed here as they should all be in /etc/fstab + ebegin "Mounting /dev" + mkdir -p /dev + if fstabinfo --quiet /dev; then + mount -n /dev + else + # Some devices require exec, Bug #92921 + mount -n -t tmpfs -o "exec,nosuid,mode=0755,size=1M" mdev /dev + fi + eend $? +} + +seed_dev() +{ + # Seed /dev with some things that we know we need + + # creating /dev/console, /dev/tty and /dev/tty1 to be able to write + # to $CONSOLE with/without bootsplash before udevd creates it + [ -c /dev/console ] || mknod -m 600 /dev/console c 5 1 + [ -c /dev/tty1 ] || mknod -m 620 /dev/tty1 c 4 1 + [ -c /dev/tty ] || mknod -m 666 /dev/tty c 5 0 + + # udevd will dup its stdin/stdout/stderr to /dev/null + # and we do not want a file which gets buffered in ram + [ -c /dev/null ] || mknod -m 666 /dev/null c 1 3 + + # so udev can add its start-message to dmesg + [ -c /dev/kmsg ] || mknod -m 660 /dev/kmsg c 1 11 + + # Not provided by sysfs but needed + ln -snf /proc/self/fd /dev/fd + ln -snf fd/0 /dev/stdin + ln -snf fd/1 /dev/stdout + ln -snf fd/2 /dev/stderr + [ -e /proc/kcore ] && ln -snf /proc/kcore /dev/core + + # Create problematic directories + mkdir -p /dev/pts /dev/shm + return 0 +} + +start() { + mount_dev_directory || return 1 + seed_dev +} diff --git a/main/busybox-initscripts/mdev.conf b/main/busybox-initscripts/mdev.conf new file mode 100644 index 0000000000..6ee65a20e5 --- /dev/null +++ b/main/busybox-initscripts/mdev.conf @@ -0,0 +1,100 @@ +# +# This is a sample mdev.conf. +# + +# Devices: +# Syntax: %s %d:%d %s +# devices user:group mode + +# null does already exist; therefore ownership has to be changed with command +null root:root 0666 @chmod 666 $MDEV +zero root:root 0666 +grsec root:root 0660 +full root:root 0666 + +random root:root 0666 +urandom root:root 0444 +hwrandom root:root 0660 + +# console does already exist; therefore ownership has to be changed with command +console root:tty 0600 @chmod 600 $MDEV && mkdir -p vc && ln -sf ../$MDEV vc/0 +fd0 root:floppy 0660 +kmem root:root 0640 +mem root:root 0640 +port root:root 0640 +ptmx root:tty 0666 + +# ram.* +ram([0-9]*) root:disk 0660 >rd/%1 +loop([0-9]+) root:disk 0660 >loop/ +sd[a-z].* root:disk 0660 */lib/mdev/usbdisk_link +hd[a-z][0-9]* root:disk 0660 */lib/mdev/ide_links +md[0-9] root:disk 0660 + +tty root:tty 0666 +tty[0-9] root:root 0600 +tty[0-9][0-9] root:tty 0660 +ttyS[0-9]* root:uucp 0660 +pty.* root:tty 0660 +vcs[0-9]* root:tty 0660 +vcsa[0-9]* root:tty 0660 + + +ttyLTM[0-9] root:dialout 0660 @ln -sf $MDEV modem +ttySHSF[0-9] root:dialout 0660 @ln -sf $MDEV modem +slamr root:dialout 0660 @ln -sf $MDEV slamr0 +slusb root:dialout 0660 @ln -sf $MDEV slusb0 +fuse root:root 0666 + +# dri device +card[0-9] root:video 0660 =dri/ + +# alsa sound devices and audio stuff +pcm.* root:audio 0660 =snd/ +control.* root:audio 0660 =snd/ +midi.* root:audio 0660 =snd/ +seq root:audio 0660 =snd/ +timer root:audio 0660 =snd/ + +adsp root:audio 0660 >sound/ +audio root:audio 0660 >sound/ +dsp root:audio 0660 >sound/ +mixer root:audio 0660 >sound/ +sequencer.* root:audio 0660 >sound/ + +# misc stuff +agpgart root:root 0660 >misc/ +psaux root:root 0660 >misc/ +rtc root:root 0664 >misc/ + +# input stuff +event[0-9]+ root:root 0640 =input/ +mice root:root 0640 =input/ +mouse[0-9] root:root 0640 =input/ +ts[0-9] root:root 0600 =input/ + +# v4l stuff +vbi[0-9] root:video 0660 >v4l/ +video[0-9] root:video 0660 >v4l/ + +# dvb stuff +dvb.* root:video 0660 */lib/mdev/dvbdev + +# load drivers for usb devices +usbdev[0-9].[0-9] root:root 0660 */lib/mdev/usbdev +usbdev[0-9].[0-9]_.* root:root 0660 + +# net devices +tun[0-9]* root:root 0600 =net/ +tap[0-9]* root:root 0600 =net/ + +# zaptel devices +zap(.*) root:dialout 0660 =zap/%1 +dahdi!(.*) root:dialout 0660 =dahdi/%1 + +# raid controllers +cciss!(.*) root:disk 0660 =cciss/%1 +ida!(.*) root:disk 0660 =ida/%1 +rd!(.*) root:disk 0660 =rd/%1 + +sr[0-9] root:cdrom 0660 >cdrom diff --git a/main/busybox-initscripts/mdev.initd b/main/busybox-initscripts/mdev.initd new file mode 100644 index 0000000000..e9309c7006 --- /dev/null +++ b/main/busybox-initscripts/mdev.initd @@ -0,0 +1,33 @@ +#!/sbin/runscript + +depend() { + provide dev + need sysfs mdev-mount + before checkfs fsck + keyword novserver +} + +start() { + # check if udev is specified on cmd line + if get_bootparam "udev"; then + ewarn "Skipping mdev as udev requested in kernel cmdline" + return 0 + fi + + ebegin "Starting busybox mdev" + mkdir -p /dev + + # use mdev for hotplug + echo "/sbin/mdev" > /proc/sys/kernel/hotplug + + # create devices + mdev -s + eend $? +} + +stop() { + ebegin "Stopping busybox mdev" + echo "" > /proc/sys/kernel/hotplug + eend +} + diff --git a/main/busybox-initscripts/rdate.confd b/main/busybox-initscripts/rdate.confd new file mode 100644 index 0000000000..93c6786169 --- /dev/null +++ b/main/busybox-initscripts/rdate.confd @@ -0,0 +1,2 @@ +# Set the ntp server here +NTP_HOST=pool.net.org diff --git a/main/busybox-initscripts/rdate.initd b/main/busybox-initscripts/rdate.initd new file mode 100644 index 0000000000..3e6c6582c9 --- /dev/null +++ b/main/busybox-initscripts/rdate.initd @@ -0,0 +1,12 @@ +#!/sbin/runscript + +start() { + if [ -z "$NTP_HOST" ] ; then + eerror "Please set NTP_HOST in /etc/conf.d/rdate" + return 1 + fi + ebegin "Running busybox rdate" + rdate "$NTP_HOST" + eend $? +} + diff --git a/main/busybox-initscripts/syslog.confd b/main/busybox-initscripts/syslog.confd new file mode 100644 index 0000000000..5f23b819d5 --- /dev/null +++ b/main/busybox-initscripts/syslog.confd @@ -0,0 +1 @@ +SYSLOGD_OPTS="" diff --git a/main/busybox-initscripts/syslog.initd b/main/busybox-initscripts/syslog.initd new file mode 100644 index 0000000000..390cd6def3 --- /dev/null +++ b/main/busybox-initscripts/syslog.initd @@ -0,0 +1,19 @@ +#!/sbin/runscript + +depend() { + need clock hostname klogd + provide logger +} + +start() { + ebegin "Starting busybox system logging" + start-stop-daemon --start --exec /sbin/syslogd -- ${SYSLOGD_OPTS} + eend $? +} + +stop () { + ebegin "Stopping busybox system logging" + start-stop-daemon --stop --exec /sbin/syslogd + eend $? +} + diff --git a/main/busybox-initscripts/usbdev b/main/busybox-initscripts/usbdev new file mode 100644 index 0000000000..b1aff296cd --- /dev/null +++ b/main/busybox-initscripts/usbdev @@ -0,0 +1,62 @@ +#!/bin/sh + +# script is buggy; until patched just do exit 0 +#exit 0 + +# add zeros to device or bus +add_zeros () { + case "$(echo $1 | wc -L)" in + 1) echo "00$1" ;; + 2) echo "0$1" ;; + *) echo "$1" + esac + exit 0 +} + + +# bus and device dirs in /sys +local USB_PATH=$(echo $MDEV | sed -e 's/usbdev\([0-9]\).[0-9]/usb\1/') +USB_PATH=$(find /sys/devices -type d -name "$USB_PATH") +local USB_DEV_DIR=$(echo $MDEV | sed -e 's/usbdev\([0-9]\).\([0-9]\)/\1-\2/') + +# dir names in /dev +local BUS=$(add_zeros $(echo $MDEV | sed -e 's/^usbdev\([0-9]\).[0-9]/\1/')) +local USB_DEV=$(add_zeros $(echo $MDEV | sed -e 's/^usbdev[0-9].\([0-9]\)/\1/')) + + +# try to load the proper driver for usb devices +case "$ACTION" in + add|"") + # load usb bus driver + for i in $USB_PATH/*/modalias ; do + modprobe `cat $i` 2>/dev/null + done + # load usb device driver if existent + if [ -d $USB_PATH/$USB_DEV_DIR ]; then + for i in $USB_PATH/$USB_DEV_DIR/*/modalias ; do + modprobe `cat $i` 2>/dev/null + done + fi + # move usb device file + mkdir -p bus/usb/$BUS + mv $MDEV bus/usb/$BUS/$USB_DEV + ;; + remove) + # unload device driver, if device dir is existent + if [ -d $USB_PATH/$USB_DEV_DIR ]; then + for i in $USB_PATH/$USB_DEV_DIR/*/modalias ; do + modprobe -r `cat $i` 2>/dev/null + done + fi + # unload usb bus driver. Does this make sense? + # what happens, if two usb devices are plugged in + # and one is removed? + for i in $USB_PATH/*/modalias ; do + modprobe -r `cat $i` 2>/dev/null + done + # remove device file and possible empty dirs + rm -f bus/usb/$BUS/$USB_DEV + rmdir bus/usb/$BUS/ 2>/dev/null + rmdir bus/usb/ 2>/dev/null + rmdir bus/ 2>/dev/null +esac diff --git a/main/busybox-initscripts/usbdisk_link b/main/busybox-initscripts/usbdisk_link new file mode 100644 index 0000000000..750242bb5c --- /dev/null +++ b/main/busybox-initscripts/usbdisk_link @@ -0,0 +1,34 @@ +#!/bin/sh + +# NOTE: since mdev -s only provide $MDEV, don't depend on any hotplug vars. + +current=$(readlink usbdisk) + +if [ "$current" = "$MDEV" ] && [ "$ACTION" = "remove" ]; then + rm -f usbdisk usba1 +fi +[ -n "$current" ] && exit + +if [ -e /sys/block/$MDEV ]; then + SYSDEV=$(readlink -f /sys/block/$MDEV/device) + # if /sys device path contains '/usb[0-9]' then we assume its usb + # also, if its an usb without partitions we require FAT + if [ "${SYSDEV##*/usb[0-9]}" != "$SYSDEV" ]; then + # do not create link if there is not FAT + dd if=/dev/$MDEV bs=512 count=1 2>/dev/null | strings | grep FAT >/dev/null || exit 0 + + ln -sf $MDEV usbdisk + # keep this for compat. people have it in fstab + ln -sf $MDEV usba1 + fi + +elif [ -e /sys/block/*/$MDEV ] ; then + PARENT=$(dirname /sys/block/*/$MDEV) + SYSDEV=$(readlink -f $PARENT/device) + if [ "${SYSDEV##*/usb[0-9]}" != "$SYSDEV" ]; then + ln -sf $MDEV usbdisk + # keep this for compat. people have it in fstab + ln -sf $MDEV usba1 + fi +fi + diff --git a/main/busybox-initscripts/watchdog.confd b/main/busybox-initscripts/watchdog.confd new file mode 100644 index 0000000000..5cfd2c2cc4 --- /dev/null +++ b/main/busybox-initscripts/watchdog.confd @@ -0,0 +1,3 @@ +#WATCHDOG_OPTS="-t 30" +WATCHDOG_DEV="" + diff --git a/main/busybox-initscripts/watchdog.initd b/main/busybox-initscripts/watchdog.initd new file mode 100644 index 0000000000..7363bb7553 --- /dev/null +++ b/main/busybox-initscripts/watchdog.initd @@ -0,0 +1,25 @@ +#!/sbin/runscript + +depend() { + need dev + after hwdrivers +} + +start() { + if ! [ -n "$WATCHDOG_DEV" ]; then + eerror "WATCHDOG_DEV is not set" + return 1 + fi + + ebegin "Starting busybox watchdog" + start-stop-daemon --start --exec /sbin/watchdog \ + -- $WATCHDOG_OPTS $WATCHDOG_DEV + eend $? +} + +stop () { + ebegin "Stopping busybox watchdog" + start-stop-daemon --stop --exec /sbin/watchdog + eend $? +} + |