Annotation of /mcore-src/trunk/mcore-tools/src/modules/basic-kernel/mcore-kernel-module.in
Parent Directory | Revision Log
Revision 2654 -
(hide annotations)
(download)
Tue Nov 10 15:11:08 2015 UTC (8 years, 6 months ago) by niro
File size: 1728 byte(s)
Tue Nov 10 15:11:08 2015 UTC (8 years, 6 months ago) by niro
File size: 1728 byte(s)
-use helper script to add modules
1 | niro | 2654 | #!/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 | # very basic getops | ||
11 | for argv in $* | ||
12 | do | ||
13 | case $1 in | ||
14 | --add|--del) method="${1//--}" ;; | ||
15 | --module) shift; module="$1" ;; | ||
16 | --opts) shift; opts="$1" ;; | ||
17 | esac | ||
18 | shift | ||
19 | done | ||
20 | |||
21 | [[ -n ${method} ]] || die "No method given" | ||
22 | [[ -n ${module} ]] || die "No module given" | ||
23 | |||
24 | case "${method}" in | ||
25 | add) | ||
26 | CONFIG="${MROOT}/etc/modules-load.d/mcore-${module}.conf" | ||
27 | clearconfig | ||
28 | addconfig "# mcore autogenerated file - do not edit" | ||
29 | addconfig "${module}" | ||
30 | |||
31 | if [[ -n ${opts} ]] | ||
32 | then | ||
33 | CONFIG="${MROOT}/etc/modprobe.d/mcore-${module}.conf" | ||
34 | clearconfig | ||
35 | addconfig "# mcore autogenerated file - do not edit" | ||
36 | addconfig "${module}.${opts}" | ||
37 | fi | ||
38 | |||
39 | # restart systemd modules-load service | ||
40 | # systemd | ||
41 | if is_provided systemd | ||
42 | then | ||
43 | mcore-system-service --restart --service systemd-modules-load.service | ||
44 | fi | ||
45 | # sysvinit | ||
46 | if is_provided sysvinit | ||
47 | then | ||
48 | mcore-system-service --restart --service modules | ||
49 | fi | ||
50 | ;; | ||
51 | |||
52 | del) | ||
53 | if [[ -f ${MROOT}/etc/modules-load.d/mcore-${module}.conf ]] | ||
54 | then | ||
55 | rm ${MROOT}/etc/modules-load.d/mcore-${module}.conf | ||
56 | fi | ||
57 | if [[ -f ${MROOT}/etc/modprobe.d/mcore-${module}.conf ]] | ||
58 | then | ||
59 | rm ${MROOT}/etc/modprobe.d/mcore-${module}.conf | ||
60 | fi | ||
61 | |||
62 | # try to remove the kernel module | ||
63 | modprobe -r "${module}" | ||
64 | |||
65 | # restart systemd modules-load service | ||
66 | # systemd | ||
67 | if is_provided systemd | ||
68 | then | ||
69 | mcore-system-service --restart --service systemd-modules-load.service | ||
70 | fi | ||
71 | # sysvinit | ||
72 | if is_provided sysvinit | ||
73 | then | ||
74 | mcore-system-service --restart --service modules | ||
75 | fi | ||
76 | ;; | ||
77 | esac |