diff options
-rw-r--r-- | main/alpine-baselayout/APKBUILD | 4 | ||||
-rw-r--r-- | main/busybox-initscripts/APKBUILD | 16 | ||||
-rw-r--r-- | main/busybox-initscripts/default.script | 108 |
3 files changed, 124 insertions, 4 deletions
diff --git a/main/alpine-baselayout/APKBUILD b/main/alpine-baselayout/APKBUILD index 25a435f3f7..344700454f 100644 --- a/main/alpine-baselayout/APKBUILD +++ b/main/alpine-baselayout/APKBUILD @@ -1,7 +1,7 @@ # Maintainer: Natanael Copa <ncopa@alpinelinux.org> pkgname=alpine-baselayout pkgver=2.1.1 -pkgrel=0 +pkgrel=1 pkgdesc="Alpine base dir structure and init scripts" url=http://git.alpinelinux.org/cgit/alpine-baselayout depends= @@ -25,6 +25,6 @@ build() { package() { cd "$_builddir" make install PREFIX= DESTDIR="$pkgdir" || return 1 - rm -f "$pkgdir"/etc/issue + rm -rf "$pkgdir"/etc/issue "$pkgdir"/usr/share/udhcpc } md5sums="4f47c32a0e88ae0bd4673a07478525c0 alpine-baselayout-2.1.1.tar.bz2" diff --git a/main/busybox-initscripts/APKBUILD b/main/busybox-initscripts/APKBUILD index 5d1ebdaf37..f676f2c4e7 100644 --- a/main/busybox-initscripts/APKBUILD +++ b/main/busybox-initscripts/APKBUILD @@ -2,7 +2,7 @@ # Maintainer: Natanael Copa <ncopa@alpinelinux.org> pkgname=busybox-initscripts pkgver=2.2 -pkgrel=2 +pkgrel=3 pkgdesc="Init scripts for busybox daemons" url="http://git.alpinelinux.org/cgit/aports/tree/core/busybox-initscripts" arch="noarch" @@ -11,13 +11,19 @@ depends="busybox" makedepends= install=$pkgname.post-install subpackages= +replaces="alpine-baselayout" source="acpid.initd 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 xvd_links + default.script " build() { + return 0 +} + +package() { local i cd "$srcdir" @@ -38,6 +44,11 @@ build() { poweroff EOF chmod +x "$pkgdir"/etc/acpi/PWRF/00000080 + + # script for udhcpc + install -Dm755 "$srcdir"/default.script \ + "$pkgdir"/usr/share/udhcpc/default.script || return 1 + } md5sums="eba3eab9ace889088e01c6c9e80ae3db acpid.initd @@ -61,4 +72,5 @@ ad1556961294e4aa2abca6be52138b7c dvbdev 5c8725b4cbdeda23b00f08124a0d20bf ide_links c422992ca5bfdfabdbba1f1532bc1358 usbdev 30b0c85956b6701caf55309a17e537f6 usbdisk_link -826d85313ca7a4a0205d63bd58b7d01f xvd_links" +826d85313ca7a4a0205d63bd58b7d01f xvd_links +c92e18e9d47f4a2a6ca6b3a81ea2f838 default.script" diff --git a/main/busybox-initscripts/default.script b/main/busybox-initscripts/default.script new file mode 100644 index 0000000000..c6cfbc5be1 --- /dev/null +++ b/main/busybox-initscripts/default.script @@ -0,0 +1,108 @@ +#!/bin/sh + +# script for udhcpc +# Copyright (c) 2008 Natanael Copa <natanael.copa@gmail.com> + +UDHCPC="/etc/udhcpc" +UDHCPC_CONF="$UDHCPC/udhcpc.conf" + +RESOLV_CONF="/etc/resolv.conf" +[ -f $UDHCPC_CONF ] && . $UDHCPC_CONF + +export broadcast +export dns +export domain +export interface +export ip +export mask +export metric +export router +export subnet + +export PATH=/usr/bin:/bin:/usr/sbin:/sbin + +run_scripts() { + local dir=$1 + if [ -d $dir ]; then + for i in $dir/*; do + [ -f $i ] && $i + done + fi +} + +deconfig() { + ip addr flush dev $interface +} + +routes() { + [ -z "$router" ] && return + local gw metric + while ip route del default via dev $interface 2>/dev/null; do + : + done + metric=0 + for gw in $router; do + route add default gw $gw dev $interface metric $metric + metric=$(( $metric + 1 )) + done +} + +resolvconf() { + local i + if [ "$RESOLV_CONF" = "no" ] || [ "$RESOLV_CONF" = "NO" ] \ + || [ -z "$RESOLV_CONF" ]; then + return + fi + echo -n > "$RESOLV_CONF" + [ -n "$domain" ] && echo "search $domain" >> "$RESOLV_CONF" + for i in $dns; do + echo "nameserver $i" >> "$RESOLV_CONF" + done +} + +bound() { + ip addr add $ip/$mask dev $interface + ip link set dev $interface up + routes + resolvconf +} + +renew() { + if ! ip addr show dev $interface | grep $ip/$mask; then + ip addr flush dev $interface + ip addr add $ip/$mask dev $interface + fi + + local i + for i in $router; do + if ! ip route show | grep ^default | grep $i; then + routes + break + fi + done + + if ! grep "^search $domain"; then + resolvconf + return + fi + for i in $dns; do + if ! grep "^nameserver $i"; then + resolvconf + return + fi + done +} + +case "$1" in + deconfig|renew|bound) + run_scripts $UDHCPC/pre-$1 + $1 + run_scripts $UDHCPC/post-$1 + ;; + *) + echo "Error: this script should be called from udhcpc" >&2 + exit 1 + ;; +esac +exit 0 + |