Annotation of /mcore-src/trunk/mcore-tools/src/modules/basic-system/system.control.class.in
Parent Directory | Revision Log
Revision 2755 -
(hide annotations)
(download)
Tue Feb 2 14:11:44 2016 UTC (8 years, 3 months ago) by niro
File size: 2205 byte(s)
Tue Feb 2 14:11:44 2016 UTC (8 years, 3 months ago) by niro
File size: 2205 byte(s)
-split firstboot/hardware configuration from hwdetection class to its corresponding module
1 | niro | 2531 | # $Id$ |
2 | |||
3 | niro | 2755 | push_firstboot 10_system_passwd |
4 | |||
5 | niro | 2581 | push_config 10_system_passwd |
6 | |||
7 | niro | 2531 | 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 | niro | 2581 | control_client_system_passwd() |
68 | niro | 2531 | { |
69 | local serial="${CLASS_ARGV[0]}" | ||
70 | niro | 2581 | push_config_10_system_passwd "${serial}" |
71 | } | ||
72 | |||
73 | push_config_10_system_passwd() | ||
74 | { | ||
75 | local serial="$1" | ||
76 | local user | ||
77 | niro | 2531 | local pass |
78 | local column | ||
79 | |||
80 | niro | 2581 | for user in root ${MCORE_UNPRIV_USER} |
81 | do | ||
82 | case "${user}" in | ||
83 | root) column="root" ;; | ||
84 | ${MCORE_UNPRIV_USER}) column="user" ;; | ||
85 | esac | ||
86 | niro | 2531 | |
87 | niro | 2581 | pass=$(mysqldo "select ${column} from client_auth where serial='${serial}'") |
88 | if [[ ${pass} = NULL ]] | ||
89 | then | ||
90 | decho "pass is 'NULL' for user '${user}', ignoring" | ||
91 | else | ||
92 | control_client "${serial}" set system.passwd "${user}" "${pass}" | ||
93 | fi | ||
94 | done | ||
95 | niro | 2531 | } |
96 | niro | 2755 | |
97 | push_firstboot_10_system_passwd() | ||
98 | { | ||
99 | local serial="$1" | ||
100 | local i | ||
101 | local auth | ||
102 | |||
103 | # now setup some empty database entries if the does not exist | ||
104 | for i in user root | ||
105 | do | ||
106 | auth=$(mysqldo "select ${i} from client_auth where serial=${serial};") | ||
107 | if [[ -z ${auth} ]] || [[ ${auth} = NULL ]] | ||
108 | then | ||
109 | decho "set empty ${i} pass" | ||
110 | import_resource client_auth "${serial}" "${i}" "" | ||
111 | fi | ||
112 | done | ||
113 | } |