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 2767 - (show annotations) (download)
Wed Feb 10 15:26:23 2016 UTC (8 years, 4 months ago) by niro
File size: 2469 byte(s)
-added the read_cmdline() function and updated system classes to get cmdline information of a client
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 push_config_10_system_passwd()
88 {
89 local serial="$1"
90 local user
91 local pass
92 local column
93
94 for user in root ${MCORE_UNPRIV_USER}
95 do
96 case "${user}" in
97 root) column="root" ;;
98 ${MCORE_UNPRIV_USER}) column="user" ;;
99 esac
100
101 pass=$(mysqldo "select ${column} from client_auth where serial='${serial}'")
102 if [[ ${pass} = NULL ]]
103 then
104 decho "pass is 'NULL' for user '${user}', ignoring"
105 else
106 control_client "${serial}" set system.passwd "${user}" "${pass}"
107 fi
108 done
109 }
110
111 push_firstboot_10_system_passwd()
112 {
113 local serial="$1"
114 local i
115 local auth
116
117 # now setup some empty database entries if the does not exist
118 for i in user root
119 do
120 auth=$(mysqldo "select ${i} from client_auth where serial=${serial};")
121 if [[ -z ${auth} ]] || [[ ${auth} = NULL ]]
122 then
123 decho "set empty ${i} pass"
124 import_resource client_auth "${serial}" "${i}" ""
125 fi
126 done
127 }