diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | setup-alpine.in | 9 | ||||
-rw-r--r-- | setup-devd.in | 123 | ||||
-rw-r--r-- | setup-xorg-base.in | 2 |
5 files changed, 135 insertions, 1 deletions
@@ -11,6 +11,7 @@ setup-apkrepos setup-bootable setup-cryptswap setup-desktop +setup-devd setup-disk setup-dns setup-gparted-desktop @@ -12,6 +12,7 @@ SBIN_FILES := copy-modloop\ setup-apkcache\ setup-apkrepos\ setup-bootable\ + setup-devd\ setup-disk\ setup-dns\ setup-hostname\ diff --git a/setup-alpine.in b/setup-alpine.in index e6a1104..356bb4e 100644 --- a/setup-alpine.in +++ b/setup-alpine.in @@ -77,6 +77,9 @@ if [ -n "$CREATEANSWERFILE" ]; then # Set hostname to alpine-test HOSTNAMEOPTS="-n alpine-test" + # Set device manager to mdev + DEVDOPTS="mdev" + # Contents of /etc/network/interfaces INTERFACESOPTS="auto lo iface lo inet loopback @@ -126,6 +129,7 @@ fi if [ "$rc_sys" != LXC ]; then $PREFIX/sbin/setup-keymap ${KEYMAPOPTS} $PREFIX/sbin/setup-hostname ${HOSTNAMEOPTS} + $PREFIX/sbin/setupd-devd -C mdev # just to bootstrap fi [ -z "$SSH_CONNECTION" ] && rst_if=1 @@ -193,6 +197,11 @@ fi $PREFIX/sbin/setup-apkrepos ${APKREPOSOPTS} +# Now that network and apk are operational we can install another device manager +if [ "$rc_sys" != LXC ] && [ -n "$DEVDOPTS" -a "$DEVDOPTS" != mdev ]; then + $PREFIX/sbin/setup-devd ${DEVDOPTS} +fi + # lets stop here if in "quick mode" if [ "$quick" = 1 ]; then exit 0 diff --git a/setup-devd.in b/setup-devd.in new file mode 100644 index 0000000..8c61243 --- /dev/null +++ b/setup-devd.in @@ -0,0 +1,123 @@ +#!/bin/sh -e + +PREFIX=@PREFIX@ + +. "$PREFIX/lib/libalpine.sh" + +prog="${0##*/}" + +usage () { + cat <<EOF +$prog: usage: setup-devd [ -h ] [ -C ] [ mdev | mdevd | udev ] + +Set up the device manager. + +Options: + -h Show this help + -C Perform a coldplug after starting the device manager. + +The optional argument tells setup-devd what device manager to use. +mdev (from busybox) is the default. +mdevd is standalone, compatible with mdev, more efficient. +udev (from eudev) is the complex, full-featured one. +Without an argument, the choice is prompted interactively. + +EOF + exit 1 +} + +disable_mdev () { + if rc-service -e mdev ; then + rc-service -s mdev-init stop + rc-service -s mdev stop + rc-update delete mdev-init sysinit || : + rc-update delete mdev sysinit || : + fi +} + +enable_mdev () { + apk add --quiet mdev-openrc + rc-update add mdev sysinit + rc-update add mdev-init sysinit + rc-service mdev start + if "$1" ; then + rc-service mdev-init start + fi +} + +disable_mdevd () { + if rc-service -e mdevd ; then + rc-service -s mdevd stop + rc-update delete mdevd-init sysinit 2>/dev/null || : + rc-update delete mdevd sysinit 2>/dev/null || : + fi +} + +enable_mdevd () { + apk add --quiet mdevd mdevd-openrc + rc-update add mdevd sysinit + rc-update add mdevd-init sysinit + rc-service mdevd start + if "$1" ; then + rc-service mdevd-init start + fi +} + +disable_udev () { + if rc-service -e udev ; then + rc-service -s udev stop + rc-update delete udev-postmount default 2>/dev/null || : + rc-update delete udev-settle sysinit 2>/dev/null || : + rc-update delete udev-trigger sysinit 2>/dev/null || : + rc-update delete udev sysinit 2>/dev/null || : + fi +} + +enable_udev () { + apk add --quiet eudev udev-init-scripts udev-init-scripts-openrc + rc-update add udev sysinit + rc-update add udev-trigger sysinit + rc-update add udev-settle sysinit + rc-update add udev-postmount default + rc-service udev start + if "$1" ; then + rc-service udev-trigger start + rc-service udev-settle start + rc-service udev-postmount start + fi +} + +coldplug=false +while getopts "hC" opt ; do + case $opt in + h) usage ;; + C) coldplug=true ;; + '?') usage ;; + esac +done +shift $((OPTIND - 1)) +devd="$1" +if test -n "$devd" ; then + interactive=false +else + interactive=true +fi + +until isin "$devd" mdev mdevd udev ; do + ask "What program should manage /dev? [mdev|mdevd|udev]" mdev + devd="$resp" +done + +if "$interactive" ; then + if ask_yesno "Scan the hardware to populate /dev? [y|n] (Say yes if you're running this script for the first time.)" n ; then + coldplug=true + else + coldplug=false + fi +fi + +case "$devd" in + mdev) disable_mdevd ; disable_udev ; enable_mdev $coldplug ;; + mdevd) disable_mdev ; disable_udev ; enable_mdevd $coldplug ;; + udev) disable_mdev ; disable_mdevd ; enable_udev $coldplug ;; +esac diff --git a/setup-xorg-base.in b/setup-xorg-base.in index e3a7912..b1de8fe 100644 --- a/setup-xorg-base.in +++ b/setup-xorg-base.in @@ -13,4 +13,4 @@ fi apk add xorg-server xf86-input-libinput eudev mesa "$@" -setup-udev +setup-devd udev |