Contents of /mcore-src/trunk/mcore-tools/src/modules/basic-kernel/mcore-kernel-module.in
Parent Directory | Revision Log
Revision 2656 -
(show annotations)
(download)
Tue Nov 10 15:26:58 2015 UTC (8 years, 10 months ago) by niro
File size: 1813 byte(s)
Tue Nov 10 15:26:58 2015 UTC (8 years, 10 months ago) by niro
File size: 1813 byte(s)
-fixed logic
1 | #!/bin/bash |
2 | |
3 | MCORE_LIBDIR="@@MCORE_LIBDIR@@" |
4 | source @@SYSCONFDIR@@/mcore/mcore.conf |
5 | source ${MCORE_LIBDIR}/include/common.global.class |
6 | source ${MCORE_LIBDIR}/include/daemon.global.class |
7 | |
8 | die() { echo "ERROR: $@"; exit 1; } |
9 | |
10 | load_classes client |
11 | |
12 | # very basic getops |
13 | for argv in $* |
14 | do |
15 | case $1 in |
16 | --add|--del) method="${1//--}" ;; |
17 | --module) shift; module="$1" ;; |
18 | --opts) shift; opts="$1" ;; |
19 | esac |
20 | shift |
21 | done |
22 | |
23 | [[ -n ${method} ]] || die "No method given" |
24 | [[ -n ${module} ]] || die "No module given" |
25 | |
26 | case "${method}" in |
27 | add) |
28 | CONFIG="${MROOT}/etc/modules-load.d/mcore-${module}.conf" |
29 | clearconfig |
30 | addconfig "# mcore autogenerated file - do not edit" |
31 | addconfig "${module}" |
32 | |
33 | if [[ -n ${opts} ]] |
34 | then |
35 | CONFIG="${MROOT}/etc/modprobe.d/mcore-${module}.conf" |
36 | clearconfig |
37 | addconfig "# mcore autogenerated file - do not edit" |
38 | addconfig "${module}.${opts}" |
39 | fi |
40 | |
41 | # restart systemd modules-load service |
42 | # systemd |
43 | if is_provided systemd |
44 | then |
45 | ${MCORE_LIBDIR}/mcore-system-service --restart --service systemd-modules-load.service |
46 | fi |
47 | # sysvinit |
48 | if is_provided sysvinit |
49 | then |
50 | ${MCORE_LIBDIR}/mcore-system-service --restart --service modules |
51 | fi |
52 | ;; |
53 | |
54 | del) |
55 | if [[ -f ${MROOT}/etc/modules-load.d/mcore-${module}.conf ]] |
56 | then |
57 | rm ${MROOT}/etc/modules-load.d/mcore-${module}.conf |
58 | fi |
59 | if [[ -f ${MROOT}/etc/modprobe.d/mcore-${module}.conf ]] |
60 | then |
61 | rm ${MROOT}/etc/modprobe.d/mcore-${module}.conf |
62 | fi |
63 | |
64 | # try to remove the kernel module |
65 | modprobe -r "${module}" |
66 | |
67 | # restart systemd modules-load service |
68 | # systemd |
69 | if is_provided systemd |
70 | then |
71 | ${MCORE_LIBDIR}/mcore-system-service --restart --service systemd-modules-load.service |
72 | fi |
73 | # sysvinit |
74 | if is_provided sysvinit |
75 | then |
76 | ${MCORE_LIBDIR}/mcore-system-service --restart --service modules |
77 | fi |
78 | ;; |
79 | esac |