Magellan Linux

Contents of /mcore-src/trunk/mcore-tools/src/modules/basic-system/system.control.class.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2832 - (show annotations) (download)
Wed Aug 30 13:54:01 2017 UTC (6 years, 8 months ago) by niro
File size: 2671 byte(s)
-support arch sys information to be able to detect which arch of the os is running
1 # $Id$
2
3 push_firstboot 10_system_passwd
4
5 push_config 10_system_passwd
6
7 help_system_reboot()
8 {
9 local serial="${CLASS_ARGV[0]}"
10 control_client "${serial}" help system.reboot
11 }
12
13 control_system_reboot()
14 {
15 local serial="${CLASS_ARGV[0]}"
16 control_client "${serial}" set system.reboot
17 }
18
19 help_system_shutdown()
20 {
21 local serial="${CLASS_ARGV[0]}"
22 control_client "${serial}" help system.shutdown
23 }
24
25 control_system_shutdown()
26 {
27 local serial="${CLASS_ARGV[0]}"
28 control_client "${serial}" set system.shutdown
29 }
30
31 help_system_console()
32 {
33 local serial="${CLASS_ARGV[0]}"
34 control_client "${serial}" help system.console
35 }
36
37 control_system_console()
38 {
39 local serial="${CLASS_ARGV[0]}"
40 local user="${CLASS_ARGV[1]}"
41
42 control_client "${serial}" set system.console "${user}"
43 }
44
45 help_system_passwd()
46 {
47 local serial="${CLASS_ARGV[0]}"
48 control_client "${serial}" help system.passwd
49 }
50
51 set_system_passwd()
52 {
53 local serial="${CLASS_ARGV[0]}"
54 local user="${CLASS_ARGV[1]}"
55 local pass="${CLASS_ARGV[2]}"
56 local column
57
58 case "${user}" in
59 root) column="root" ;;
60 ${MCORE_UNPRIV_USER}) column="user" ;;
61 *) echo "Unknown user '${user}', aborting"; return 1 ;;
62 esac
63
64 import_resource client_auth "${serial}" "${column}" "${pass}"
65 }
66
67 control_client_system_passwd()
68 {
69 local serial="${CLASS_ARGV[0]}"
70 push_config_10_system_passwd "${serial}"
71 }
72
73 help_system_cmdline()
74 {
75 local serial="${CLASS_ARGV[0]}"
76 control_client "${serial}" help system.cmdline
77 }
78
79 get_system_cmdline()
80 {
81 local serial="${CLASS_ARGV[0]}"
82 local variable="${CLASS_ARGV[1]}"
83
84 control_client "${serial}" get system.cmdline "${variable}"
85 }
86
87 help_system_arch()
88 {
89 local serial="${CLASS_ARGV[0]}"
90 control_client "${serial}" help system.arch
91 }
92
93 get_system_arch()
94 {
95 local serial="${CLASS_ARGV[0]}"
96 control_client "${serial}" get system.arch
97 }
98
99 push_config_10_system_passwd()
100 {
101 local serial="$1"
102 local user
103 local pass
104 local column
105
106 for user in root ${MCORE_UNPRIV_USER}
107 do
108 case "${user}" in
109 root) column="root" ;;
110 ${MCORE_UNPRIV_USER}) column="user" ;;
111 esac
112
113 pass=$(mysqldo "select ${column} from client_auth where serial='${serial}'")
114 if [[ ${pass} = NULL ]]
115 then
116 decho "pass is 'NULL' for user '${user}', ignoring"
117 else
118 control_client "${serial}" set system.passwd "${user}" "${pass}"
119 fi
120 done
121 }
122
123 push_firstboot_10_system_passwd()
124 {
125 local serial="$1"
126 local i
127 local auth
128
129 # now setup some empty database entries if the does not exist
130 for i in user root
131 do
132 auth=$(mysqldo "select ${i} from client_auth where serial=${serial};")
133 if [[ -z ${auth} ]] || [[ ${auth} = NULL ]]
134 then
135 decho "set empty ${i} pass"
136 import_resource client_auth "${serial}" "${i}" ""
137 fi
138 done
139 }