Magellan Linux

Annotation of /mcore-src/trunk/mcore-tools/daemon/client/include/system.client.class

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2079 - (hide annotations) (download)
Fri May 10 11:37:38 2013 UTC (11 years 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 niro 1248 # $Id$
2    
3     provide basic-system
4 niro 2079 require basic-init
5 niro 1248
6     help_system_reboot()
7     {
8     mecho "set system.reboot"
9 niro 1262 mecho " Reboots the system."
10 niro 1248 }
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 niro 1262 mecho " Shuts the system down."
22 niro 1248 }
23    
24     # set_system_shutdown
25     set_system_shutdown()
26     {
27 niro 2057 poweroff
28 niro 1248 }
29    
30     help_system_console()
31     {
32 niro 1262 mecho "set system.console [user]"
33     mecho " Opens a console with user or root privileges."
34     mecho " Known users:"
35 niro 1336 mecho " ${MCORE_UNPRIV_USER} - mcore standard user only with user privileges"
36 niro 1262 mecho " root - mcore root user with full system privileges"
37 niro 1248 }
38    
39 niro 1329 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 niro 1248 set_system_console()
52     {
53 niro 1262 local user="$1"
54     [[ -z ${user} ]] && help_system_console && return 1
55    
56     case "${user}" in
57 niro 1336 ${MCORE_UNPRIV_USER}) x11runas "rxvt &" ;;
58 niro 1262 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 niro 1248 }
62    
63 niro 1262 help_system_service()
64 niro 1248 {
65 niro 2075 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 niro 1262 mecho "set system.service [command] [service] [opts]"
73     mecho " Controls system services."
74     mecho " Commands:"
75 niro 2075 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 niro 1248 }
82    
83 niro 2079 help_system_passwd()
84 niro 1248 {
85 niro 2079 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 niro 1248 }
90 niro 1262
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 niro 1336 root|${MCORE_UNPRIV_USER}) (echo "${pass}"; sleep 0.1; echo "${pass}") | passwd "${user}" ;;
101 niro 1262 *) 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 niro 1648 rvecho "${tty}"
133 niro 1262 }
134 niro 1329
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 niro 1648 yes) mecho "autologon currently enabled"; rvecho "1" ;;
141     no) mecho "autologon currently disabled"; rvecho "0" ;;
142 niro 1329 *) eecho "unkown state" ;;
143     esac
144     }
145    
146     set_system_autologon()
147     {
148 niro 1345 local action="$1"
149 niro 1329 [[ -z ${action} ]] && help_system_autologon && return 1
150    
151     ## splash X11 tty too?
152    
153     case "${action}" in
154     enable)
155 niro 1345 sed -i 's:^\(auto_login\).*:\1\tyes:' /etc/slim.conf
156 niro 1329 mecho "autologon enabled"
157     ;;
158     disable)
159 niro 1345 sed -i 's:^\(auto_login\).*:\1\tno:' /etc/slim.conf
160 niro 1329 mecho "autologon disabled"
161     ;;
162     *) help_system_autologon && return 1 ;;
163     esac
164     }