void-packages

Void Source Packages
git clone git://ezup.dev/void-packages.git
Log | Files | Refs | README | LICENSE

kernel-hooks (1154B)


      1#!/bin/sh
      2#
      3# Run scripts found in /etc/kernel.d/ directories.
      4#
      5# Arguments:	$ACTION = [run/targets]
      6#		$TARGET = [post-install/post-remove]
      7#		$PKGNAME
      8#		$VERSION
      9#		$UPDATE = [yes/no]
     10#
     11ACTION="$1"
     12TARGET="$2"
     13PKGNAME="$3"
     14VERSION="$4"
     15UPDATE="$5"
     16
     17RUN_TARGETS="pre-install post-install pre-remove post-remove"
     18
     19case "$ACTION" in
     20targets)
     21	echo "${RUN_TARGETS}"
     22	;;
     23run)
     24	# Ignore pre-remove when updating a package.
     25	if [ "${TARGET}" = "pre-remove" ]; then
     26		[ "${UPDATE}" = "yes" ] && exit 0
     27	fi
     28
     29	# Create required dirs when necessary.
     30	for _dir_ in ${RUN_TARGETS}; do
     31		[ ! -d etc/kernel.d/${_dir_} ] && mkdir -p etc/kernel.d/${_dir_}
     32	done
     33
     34	# Execute kernel hooks for the specified target.
     35	for _file_ in etc/kernel.d/${TARGET}/*; do
     36		[ ! -x "${_file_}" ] && continue
     37		echo "Executing ${TARGET} kernel hook: $(basename ${_file_}) ..."
     38
     39		# A package may export "kernel_hooks_version" as a hint
     40		# to pass this version to the hooks.
     41		if [ -n "${kernel_hooks_version}" ]; then
     42			env ROOTDIR="." ${_file_} ${PKGNAME} ${kernel_hooks_version}
     43		else
     44			env ROOTDIR="." ${_file_} ${PKGNAME} ${VERSION}
     45		fi
     46	done
     47	;;
     48*)
     49	exit 1
     50	;;
     51esac
     52
     53exit 0