Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2878 - (hide annotations) (download)
Fri Aug 14 11:35:04 2020 UTC (3 years, 8 months ago) by niro
File size: 2687 byte(s)
-encapsulate all argument variables to control_client() to evaluate them properly later on
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 niro 2878 control_client "${serial}" set system.console "\"${user}\""
43 niro 2531 }
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 niro 2767 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 niro 2878 control_client "${serial}" get system.cmdline "\"${variable}\""
85 niro 2767 }
86    
87 niro 2832 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 niro 2581 push_config_10_system_passwd()
100     {
101     local serial="$1"
102     local user
103 niro 2531 local pass
104     local column
105    
106 niro 2581 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 niro 2531
113 niro 2581 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 niro 2878 control_client "${serial}" set system.passwd "\"${user}\"" "\"${pass}\""
119 niro 2581 fi
120     done
121 niro 2531 }
122 niro 2755
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     }