Annotation of /mcore-src/trunk/mcore-tools/src/modules/basic-version/version.client.class.in
Parent Directory | Revision Log
Revision 2702 -
(hide annotations)
(download)
Thu Dec 17 12:02:10 2015 UTC (8 years, 4 months ago) by niro
File size: 1811 byte(s)
Thu Dec 17 12:02:10 2015 UTC (8 years, 4 months ago) by niro
File size: 1811 byte(s)
-support client deactivation and inform the user properly
1 | niro | 2504 | # $Id$ |
2 | |||
3 | provide basic-version | ||
4 | |||
5 | help_version_os() | ||
6 | { | ||
7 | mecho "get version.os" | ||
8 | mecho " Prints the current os version." | ||
9 | } | ||
10 | |||
11 | help_version_tools() | ||
12 | { | ||
13 | mecho "get version.tools" | ||
14 | mecho " Prints the current mcore-tools version." | ||
15 | } | ||
16 | |||
17 | niro | 2699 | help_version_netboot() |
18 | { | ||
19 | mecho "get version.netboot" | ||
20 | mecho " Prints the current netboot state." | ||
21 | } | ||
22 | |||
23 | niro | 2702 | help_version_deactivated() |
24 | { | ||
25 | mecho "get version.deactivated" | ||
26 | mecho " Shows the current state of the system." | ||
27 | mecho | ||
28 | mecho "set version.deactivated [0|1]" | ||
29 | mecho " Sets the state of the system." | ||
30 | } | ||
31 | |||
32 | niro | 2504 | get_version_os() |
33 | { | ||
34 | local version | ||
35 | |||
36 | if [ -f /etc/os-release ] | ||
37 | then | ||
38 | version="$(source /etc/os-release; echo ${Version_ID})" | ||
39 | fi | ||
40 | |||
41 | if [[ -z ${version} ]] | ||
42 | then | ||
43 | version="UNKNOWN" | ||
44 | fi | ||
45 | |||
46 | rvecho "${version}" | ||
47 | } | ||
48 | |||
49 | get_version_tools() | ||
50 | { | ||
51 | local version | ||
52 | |||
53 | if [ -f ${MCORE_LIBDIR}/VERSION ] | ||
54 | then | ||
55 | version="$(<${MCORE_LIBDIR}/VERSION)" | ||
56 | fi | ||
57 | |||
58 | if [[ -z ${version} ]] | ||
59 | then | ||
60 | version="UNKNOWN" | ||
61 | fi | ||
62 | |||
63 | rvecho "${version}" | ||
64 | } | ||
65 | niro | 2699 | |
66 | get_version_netboot() | ||
67 | { | ||
68 | local netboot | ||
69 | local i | ||
70 | |||
71 | # default no netboot | ||
72 | netboot=0 | ||
73 | |||
74 | if [ -f /proc/cmdline ] | ||
75 | then | ||
76 | for i in $(< /proc/cmdline) | ||
77 | do | ||
78 | case ${i} in | ||
79 | rd.netboot) netboot=1 ;; | ||
80 | esac | ||
81 | done | ||
82 | fi | ||
83 | |||
84 | rvecho "${netboot}" | ||
85 | } | ||
86 | niro | 2702 | |
87 | get_version_deactivated() | ||
88 | { | ||
89 | local deactivated=0 | ||
90 | [[ -e ${MCORE_CONFIG_PATH}/client-deactivated ]] && deactivated=1 | ||
91 | rvecho "${deactivated}" | ||
92 | } | ||
93 | |||
94 | set_version_deactivated() | ||
95 | { | ||
96 | local deactivated="${CLASS_ARGV[0]}" | ||
97 | case "${deactivated}" in | ||
98 | 0) if [[ -e ${MCORE_CONFIG_PATH}/client-deactivated ]] | ||
99 | then | ||
100 | rm ${MCORE_CONFIG_PATH}/client-deactivated | ||
101 | fi | ||
102 | rvecho "Client activated" | ||
103 | ;; | ||
104 | |||
105 | 1) if [[ ! -e ${MCORE_CONFIG_PATH}/client-deactivated ]] | ||
106 | then | ||
107 | touch ${MCORE_CONFIG_PATH}/client-deactivated | ||
108 | fi | ||
109 | rvecho "Client deactivated" | ||
110 | ;; | ||
111 | |||
112 | *) decho "Unknown state '${deactivated}'" | ||
113 | help_version_deactivated | ||
114 | ;; | ||
115 | esac | ||
116 | } |