Linux HOWTOs

About | Home | Search


HOWTO: hotplug
Description: Kernel & scripts make newly plugged-in devices available immediately
Click here for ChangeLog
NOTE: I use GNU tar >= 1.13.25 so it's -j for .tar.bz2 files,
it's safe to assume that make, gcc, binutils, fileutils/coreutils, gawk, sed, and grep are prerequisites for almost everything


# hotplug 2004_09_23
# ==================
# Slackware 9.0's 'hotplug' package includes version 2002_08_26 and there's
# also a patched version in 'patches'.  9.1's includes 2003_08_05 and
# version 2004_01_05 is in 'patches'.  10.0's includes 2004_01_05, 10.1 and
# 10.2's include 2004_09_23.

# Prerequisites:
# modutils (for 2.2.x/2.4.x kernels) or module-init-tools
#  (for 2.5.x/2.6.x kernels)
# a Linux kernel with CONFIG_HOTPLUG enabled

cd
test -f installed/hotplug-2004_09_23.tar.bz2 &&
 mv installed/hotplug-2004_09_23.tar.bz2 .
test ! -f hotplug-2004_09_23.tar.bz2 &&
 wget http://ftp.kernel.org/pub/linux/utils/kernel/hotplug/\
hotplug-2004_09_23.tar.bz2

# Verify tarball w/ md5sum:
# (this came from my gpg-verified tarball)
echo "58e6995f9df71ce59b0ec2787019e5fe  hotplug-2004_09_23.tar.bz2" | \
 md5sum -c

# Verify tarball w/ sha1sum:
# (this also came from my gpg-verified tarball)
echo "2dd1be1337765600c66e48e5726a30a197a4f483  hotplug-2004_09_23.tar.\
bz2" | sha1sum -c

# Verify tarball w/ gpg:
( gpg --list-keys 517D0F0E > /dev/null 2>&1 || gpg --recv-keys 517D0F0E ) &&
 wget -nc http://ftp.kernel.org/pub/linux/utils/kernel/hotplug/\
hotplug-2004_09_23.tar.bz2.sign &&
  gpg --verify hotplug-2004_09_23.tar.bz2.sign &&
   rm hotplug-2004_09_23.tar.bz2.sign

mkdir -p -m 0700 src
cd src
find -maxdepth 1 -type d -name "hotplug-*" -exec rm -r {} \;
tar xjvf ~/hotplug-2004_09_23.tar.bz2
cd hotplug-2004_09_23
test $UID = 0 && chown -R root:root .

# Patch it to:
# 1) Fix /etc/hotplug/net.agent to use Slackware's /etc/rc.d/rc.inet1
# 2) Quiet an error in /etc/hotplug/input.rc that will give an error if
#    /proc/bus/input/devices doesn't exist, which it won't if you're running
#    a kernel other than 2.6.x
# 3) Log to syslog when hotplug starts and stops, but unlike the Slack
#    patch, don't make sure that logger and /var/run/syslogd.pid exist
#    because I use syslog-ng.  Rather than check for the pid of syslog,
#    syslog-ng, and other variants, we'll just assume that everyone is
#    running some sort of syslog and just check to make sure that
#    /usr/bin/logger is executable.
# 4) Quiet some of the logging and messages to the console
# 5) Change a few files to use/refer-to /etc/rc.d/rc.hotplug instead of the
#    default /etc/init.d/hotplug
wget -nc http://englanders.cc/pub/linux/patches/hotplug-2004_09_23.patch &&
 patch -p1 < hotplug-2004_09_23.patch

# Become root to install it
su

# Back up existing hotplug files (not including firmware, man pages, docs),
# if there are any:
test -d /etc/hotplug &&
 ( mkdir -p -m 0700 ~/backup
   cd /
   tar cjvf ~/backup/hotplug-`date +%Y%m%d`.tar.bz2 /etc/rc.d/rc.hotplug \
    /etc/hotplug /etc/hotplug.d )

test -x /sbin/removepkg && /sbin/removepkg hotplug
make install
test -f /etc/hotplug/pnp.distmap || touch /etc/hotplug/pnp.distmap

# If you want to collect ascii event logs for events that aren't handled
# by some /etc/hotplug/*.agent:
touch /var/log/hotplug/events

# To prevent hotplug from loading a module, add it to /etc/hotplug/blacklist

# Slackware's hotplug package (and older versions of hotplug) use
# /usr/lib/hotplug/firmware, move what's in there to /lib/firmware:
test ! -d /lib/firmware && mkdir -p /lib/firmware
test -d /usr/lib/hotplug/firmware &&
 ( mv -f /usr/lib/hotplug/firmware/* /lib/firmware/
   rm -r /usr/lib/hotplug )

# Become yourself again
exit

cd
mkdir -p -m 0700 installed
rm -f installed/hotplug-*.tar.*
mv hotplug-2004_09_23.tar.bz2 installed/


# If you ever want to uninstall hotplug, this should do it:
su
test -d /etc/hotplug && rm -r /etc/hotplug
test -d /etc/hotplug.d && rm -r /etc/hotplug.d
rm -f /etc/rc.d/rc.hotplug /sbin/hotplug
find /usr/doc -type d -maxdepth 1 -name "hotplug-*" -exec rm -r {} \;
test -d /usr/lib/hotplug && rm -r /usr/lib/hotplug
( cd /usr/man/man8 ; rm -f hotplug.8 hotplug.8.gz )
exit
find ~/src -maxdepth 1 -type d -name "hotplug-*" -exec rm -r {} \;
rm -f ~/installed/hotplug-*.tar.*

Back to the list


Last updated: Tue, 07 Aug 2018 12:06:17 -0400
Jason Englander <jason at englanders dot us>