Annotation of /mcore-src/trunk/mcore-tools/src/modules/basic-kernel/kernel.client.class.in
Parent Directory | Revision Log
Revision 2649 -
(hide annotations)
(download)
Tue Nov 10 14:45:39 2015 UTC (8 years, 6 months ago) by niro
File size: 1762 byte(s)
Tue Nov 10 14:45:39 2015 UTC (8 years, 6 months ago) by niro
File size: 1762 byte(s)
-added basic kernel modules support
1 | niro | 2649 | # $Id$ |
2 | |||
3 | provide basic-kernel | ||
4 | require basic-init | ||
5 | |||
6 | help_kernel_module() | ||
7 | { | ||
8 | mecho "get kernel.module" | ||
9 | mecho " prints current list of kernel modules" | ||
10 | mecho | ||
11 | mecho "set kernel.module [action] [module] [opts]" | ||
12 | } | ||
13 | |||
14 | get_kernel_module() | ||
15 | { | ||
16 | return 0 | ||
17 | } | ||
18 | |||
19 | set_kernel_module() | ||
20 | { | ||
21 | local action="${CLASS_ARGV[0]}" | ||
22 | local module="${CLASS_ARGV[1]}" | ||
23 | local opts="${CLASS_ARGV[2]}" | ||
24 | |||
25 | [[ -z ${action} ]] && help_kernel_module && return 1 | ||
26 | [[ -z ${module} ]] && help_kernel_module && return 1 | ||
27 | |||
28 | case "${action}" in | ||
29 | add) | ||
30 | CONFIG="${MROOT}/etc/modules-load.d/mcore-${module}.conf" | ||
31 | clearconfig | ||
32 | addconfig "# mcore autogenerated file - do not edit" | ||
33 | addconfig "${module}" | ||
34 | |||
35 | if [[ -n ${opts} ]] | ||
36 | then | ||
37 | CONFIG="${MROOT}/etc/modprobe.d/mcore-${module}.conf" | ||
38 | clearconfig | ||
39 | addconfig "# mcore autogenerated file - do not edit" | ||
40 | addconfig "${module}.${opts}" | ||
41 | fi | ||
42 | |||
43 | # restart systemd modules-load service | ||
44 | # systemd | ||
45 | if is_provided systemd | ||
46 | then | ||
47 | mcore-system-service restart systemd-modules-load.service | ||
48 | fi | ||
49 | # sysvinit | ||
50 | if is_provided sysvinit | ||
51 | then | ||
52 | mcore-system-service restart modules | ||
53 | fi | ||
54 | ;; | ||
55 | |||
56 | del) | ||
57 | if [[ -f ${MROOT}/etc/modules-load.d/mcore-${module}.conf ]] | ||
58 | then | ||
59 | rm ${MROOT}/etc/modules-load.d/mcore-${module}.conf | ||
60 | fi | ||
61 | if [[ -f ${MROOT}/etc/modprobe.d/mcore-${module}.conf ]] | ||
62 | then | ||
63 | rm ${MROOT}/etc/modprobe.d/mcore-${module}.conf | ||
64 | fi | ||
65 | |||
66 | # try to remove the kernel module | ||
67 | modprobe -r "${module}" | ||
68 | |||
69 | # restart systemd modules-load service | ||
70 | # systemd | ||
71 | if is_provided systemd | ||
72 | then | ||
73 | mcore-system-service restart systemd-modules-load.service | ||
74 | fi | ||
75 | # sysvinit | ||
76 | if is_provided sysvinit | ||
77 | then | ||
78 | mcore-system-service restart modules | ||
79 | fi | ||
80 | ;; | ||
81 | |||
82 | *) help_kernel_module && return 1 ;; | ||
83 | esac | ||
84 | } |