Contents of /mcore-src/trunk/mcore-tools/daemon/client/include/system.client.class
Parent Directory | Revision Log
Revision 2079 -
(show annotations)
(download)
Fri May 10 11:37:38 2013 UTC (11 years, 1 month ago) by niro
File size: 3767 byte(s)
Fri May 10 11:37:38 2013 UTC (11 years, 1 month ago) by niro
File size: 3767 byte(s)
-split systemd, sysvinit, fbsplash and plymouth functions in single classes so no runtime checks are required and the correct version get installed right away
1 | # $Id$ |
2 | |
3 | provide basic-system |
4 | require basic-init |
5 | |
6 | help_system_reboot() |
7 | { |
8 | mecho "set system.reboot" |
9 | mecho " Reboots the system." |
10 | } |
11 | |
12 | # set_system_reboot |
13 | set_system_reboot() |
14 | { |
15 | reboot |
16 | } |
17 | |
18 | help_system_shutdown() |
19 | { |
20 | mecho "set system.shutdown" |
21 | mecho " Shuts the system down." |
22 | } |
23 | |
24 | # set_system_shutdown |
25 | set_system_shutdown() |
26 | { |
27 | poweroff |
28 | } |
29 | |
30 | help_system_console() |
31 | { |
32 | mecho "set system.console [user]" |
33 | mecho " Opens a console with user or root privileges." |
34 | mecho " Known users:" |
35 | mecho " ${MCORE_UNPRIV_USER} - mcore standard user only with user privileges" |
36 | mecho " root - mcore root user with full system privileges" |
37 | } |
38 | |
39 | help_system_autologon() |
40 | { |
41 | mecho "get system.autologon" |
42 | mecho " Shows the state of autlogon" |
43 | mecho |
44 | mecho "set system.autologon [action]" |
45 | mecho " Enables or disables X11 autologins of the mcore user." |
46 | mecho " Available actions:" |
47 | mecho " enable - enables autologon" |
48 | mecho " disable - disables autologon" |
49 | } |
50 | |
51 | set_system_console() |
52 | { |
53 | local user="$1" |
54 | [[ -z ${user} ]] && help_system_console && return 1 |
55 | |
56 | case "${user}" in |
57 | ${MCORE_UNPRIV_USER}) x11runas "rxvt &" ;; |
58 | root) x11runas "rxvt -T 'Login as root' -e /bin/bash -c 'echo \"Login as root\";exec /bin/login root' &" ;; |
59 | *) help_system_console && return 1 ;; |
60 | esac |
61 | } |
62 | |
63 | help_system_service() |
64 | { |
65 | mecho "get system.service [command] [service]" |
66 | mecho " Status information of system services." |
67 | mecho " Commands:" |
68 | mecho " status - prints status of given service" |
69 | mecho " enabled - check whether a service was enabled" |
70 | mecho " runlevel - print current system runlevel" |
71 | mecho |
72 | mecho "set system.service [command] [service] [opts]" |
73 | mecho " Controls system services." |
74 | mecho " Commands:" |
75 | mecho " start - starts given service" |
76 | mecho " stop - stops given service" |
77 | mecho " restart - restart given service" |
78 | mecho " reload - reloads given service if possible" |
79 | mecho " add - adds a service to default runlevels" |
80 | mecho " del - deletes a service from all runlevels" |
81 | } |
82 | |
83 | help_system_passwd() |
84 | { |
85 | mecho "set system.passwd [user] [password]" |
86 | mecho " Sets a system password for given user." |
87 | mecho " Allowed users: ${MCORE_UNPRIV_USER}, root" |
88 | mecho " If password is empty, the current password will be deleted." |
89 | } |
90 | |
91 | set_system_passwd() |
92 | { |
93 | local user="$1" |
94 | local pass="$2" |
95 | |
96 | [[ -z ${user} ]] && help_system_passwd && return 1 |
97 | [[ -z ${pass} ]] && mecho "deleting password!" |
98 | |
99 | case "${user}" in |
100 | root|${MCORE_UNPRIV_USER}) (echo "${pass}"; sleep 0.1; echo "${pass}") | passwd "${user}" ;; |
101 | *) help_system_passwd && return 1 ;; |
102 | esac |
103 | } |
104 | |
105 | help_system_vt() |
106 | { |
107 | mecho "get system.vt" |
108 | mecho " Prints tty number of the current vt terminal." |
109 | mecho |
110 | mecho "set system.vt [tty]" |
111 | mecho " Change current vt terminal to given tty." |
112 | mecho " Valid tty numbers are 1-9." |
113 | } |
114 | |
115 | set_system_vt() |
116 | { |
117 | local tty="$1" |
118 | [[ -z ${tty} ]] && help_system_vt && return 1 |
119 | case "${tty}" in |
120 | [1-9]) |
121 | chvt "${tty}" |
122 | mecho "current vt changed to ${tty}." |
123 | ;; |
124 | *) help_system_vt && return 1 ;; |
125 | esac |
126 | } |
127 | |
128 | get_system_vt() |
129 | { |
130 | local tty |
131 | tty="$(fgconsole)" |
132 | rvecho "${tty}" |
133 | } |
134 | |
135 | get_system_autologon() |
136 | { |
137 | local var |
138 | var=$(grep auto_login /etc/slim.conf | sed 's:auto_login.*\([yn].*\):\1:') |
139 | case "${var}" in |
140 | yes) mecho "autologon currently enabled"; rvecho "1" ;; |
141 | no) mecho "autologon currently disabled"; rvecho "0" ;; |
142 | *) eecho "unkown state" ;; |
143 | esac |
144 | } |
145 | |
146 | set_system_autologon() |
147 | { |
148 | local action="$1" |
149 | [[ -z ${action} ]] && help_system_autologon && return 1 |
150 | |
151 | ## splash X11 tty too? |
152 | |
153 | case "${action}" in |
154 | enable) |
155 | sed -i 's:^\(auto_login\).*:\1\tyes:' /etc/slim.conf |
156 | mecho "autologon enabled" |
157 | ;; |
158 | disable) |
159 | sed -i 's:^\(auto_login\).*:\1\tno:' /etc/slim.conf |
160 | mecho "autologon disabled" |
161 | ;; |
162 | *) help_system_autologon && return 1 ;; |
163 | esac |
164 | } |