Contents of /mcore-src/trunk/mcore-tools/src/modules/basic-version/version.client.class.in
Parent Directory | Revision Log
Revision 2704 -
(show annotations)
(download)
Thu Dec 17 12:31:44 2015 UTC (8 years, 9 months ago) by niro
File size: 1789 byte(s)
Thu Dec 17 12:31:44 2015 UTC (8 years, 9 months ago) by niro
File size: 1789 byte(s)
-fixed logic
1 | # $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 | help_version_netboot() |
18 | { |
19 | mecho "get version.netboot" |
20 | mecho " Prints the current netboot state." |
21 | } |
22 | |
23 | help_version_activated() |
24 | { |
25 | mecho "get version.activated" |
26 | mecho " Shows the current state of the system." |
27 | mecho |
28 | mecho "set version.activated [0|1]" |
29 | mecho " Sets the state of the system." |
30 | } |
31 | |
32 | 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 | |
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 | |
87 | get_version_activated() |
88 | { |
89 | local activated=1 |
90 | [[ -e ${MCORE_CONFIG_PATH}/client-deactivated ]] && activated=0 |
91 | rvecho "${activated}" |
92 | } |
93 | |
94 | set_version_activated() |
95 | { |
96 | local activated="${CLASS_ARGV[0]}" |
97 | case "${activated}" in |
98 | 1) 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 | 0) 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_activated |
114 | ;; |
115 | esac |
116 | } |