#!/bin/bash MCORE_LIBDIR="@@MCORE_LIBDIR@@" source @@SYSCONFDIR@@/mcore/mcore.conf source ${MCORE_LIBDIR}/include/common.global.class source ${MCORE_LIBDIR}/include/daemon.global.class die() { echo "ERROR: $@"; exit 1; } load_classes client # very basic getops for argv in $* do case $1 in --add|--del) method="${1//--}" ;; --module) shift; module="$1" ;; --opts) shift; opts="$1" ;; esac shift done [[ -n ${method} ]] || die "No method given" [[ -n ${module} ]] || die "No module given" case "${method}" in add) CONFIG="${MROOT}/etc/modules-load.d/mcore-${module}.conf" clearconfig addconfig "# mcore autogenerated file - do not edit" addconfig "${module}" if [[ -n ${opts} ]] then CONFIG="${MROOT}/etc/modprobe.d/mcore-${module}.conf" clearconfig addconfig "# mcore autogenerated file - do not edit" addconfig "${module}.${opts}" fi # restart systemd modules-load service # systemd if is_provided systemd then ${MCORE_LIBDIR}/mcore-system-service --restart --service systemd-modules-load.service fi # sysvinit if is_provided sysvinit then ${MCORE_LIBDIR}/mcore-system-service --restart --service modules fi ;; del) if [[ -f ${MROOT}/etc/modules-load.d/mcore-${module}.conf ]] then rm ${MROOT}/etc/modules-load.d/mcore-${module}.conf fi if [[ -f ${MROOT}/etc/modprobe.d/mcore-${module}.conf ]] then rm ${MROOT}/etc/modprobe.d/mcore-${module}.conf fi # try to remove the kernel module modprobe -r "${module}" # restart systemd modules-load service # systemd if is_provided systemd then ${MCORE_LIBDIR}/mcore-system-service --restart --service systemd-modules-load.service fi # sysvinit if is_provided sysvinit then ${MCORE_LIBDIR}/mcore-system-service --restart --service modules fi ;; esac