Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1262 by niro, Fri Feb 4 20:05:37 2011 UTC revision 2057 by niro, Wed May 8 12:02:09 2013 UTC
# Line 23  help_system_shutdown() Line 23  help_system_shutdown()
23  # set_system_shutdown  # set_system_shutdown
24  set_system_shutdown()  set_system_shutdown()
25  {  {
26   halt   poweroff
27  }  }
28    
29  help_system_console()  help_system_console()
# Line 31  help_system_console() Line 31  help_system_console()
31   mecho "set system.console [user]"   mecho "set system.console [user]"
32   mecho " Opens a console with user or root privileges."   mecho " Opens a console with user or root privileges."
33   mecho " Known users:"   mecho " Known users:"
34   mecho "   mcore  - mcore standard user only with user privileges"   mecho "   ${MCORE_UNPRIV_USER}  - mcore standard user only with user privileges"
35   mecho "   root   - mcore root user with full system privileges"   mecho "   root   - mcore root user with full system privileges"
36  }  }
37    
# Line 39  help_system_passwd() Line 39  help_system_passwd()
39  {  {
40   mecho "set system.passwd [user] [password]"   mecho "set system.passwd [user] [password]"
41   mecho " Sets a system password for given user."   mecho " Sets a system password for given user."
42   mecho "  Allowed users: mcore, root"   mecho "  Allowed users: ${MCORE_UNPRIV_USER}, root"
43   mecho "  If password is empty, the current password will be deleted."   mecho "  If password is empty, the current password will be deleted."
44  }  }
45    
46    help_system_autologon()
47    {
48     mecho "get system.autologon"
49     mecho "  Shows the state of autlogon"
50     mecho
51     mecho "set system.autologon [action]"
52     mecho " Enables or disables X11 autologins of the mcore user."
53     mecho "  Available actions:"
54     mecho "      enable  - enables autologon"
55     mecho "      disable - disables autologon"
56    }
57    
58  set_system_console()  set_system_console()
59  {  {
60   local user="$1"   local user="$1"
61   [[ -z ${user} ]] && help_system_console && return 1   [[ -z ${user} ]] && help_system_console && return 1
62    
63   case "${user}" in   case "${user}" in
64   mcore) x11runas "rxvt &" ;;   ${MCORE_UNPRIV_USER}) x11runas "rxvt &" ;;
65   root)  x11runas "rxvt -T 'Login as root' -e /bin/bash -c 'echo \"Login as root\";exec /bin/login root' &" ;;   root)  x11runas "rxvt -T 'Login as root' -e /bin/bash -c 'echo \"Login as root\";exec /bin/login root' &" ;;
66   *)     help_system_console && return 1 ;;   *)     help_system_console && return 1 ;;
67   esac   esac
# Line 60  help_system_service() Line 72  help_system_service()
72   mecho "set system.service [command] [service] [opts]"   mecho "set system.service [command] [service] [opts]"
73   mecho " Controls system services."   mecho " Controls system services."
74   mecho " Commands:"   mecho " Commands:"
75     mecho "   status  - prints status of given service"
76   mecho "   start   - starts given service"   mecho "   start   - starts given service"
77   mecho "   stop    - stops given service"   mecho "   stop    - stops given service"
78   mecho "   restart - restart given service"   mecho "   restart - restart given service"
# Line 77  set_system_service() Line 90  set_system_service()
90   [[ -z ${command} ]] && help_system_service && return 1   [[ -z ${command} ]] && help_system_service && return 1
91   [[ -z ${service} ]] && help_system_service && return 1   [[ -z ${service} ]] && help_system_service && return 1
92    
93   if [[ ! -x /etc/rc.d/init.d/${service} ]]   if [[ ! -x ${MROOT}/etc/rc.d/init.d/${service} ]]
94   then   then
95   mecho "Service '${service}' unkown!"   eecho "Service '${service}' unkown!"
96   fi   fi
97    
98   case "${command}" in   case "${command}" in
# Line 87  set_system_service() Line 100  set_system_service()
100   stop) /etc/rc.d/init.d/"${service}" stop ;;   stop) /etc/rc.d/init.d/"${service}" stop ;;
101   restart) /etc/rc.d/init.d/"${service}" restart ;;   restart) /etc/rc.d/init.d/"${service}" restart ;;
102   reload) /etc/rc.d/init.d/"${service}" reload ;;   reload) /etc/rc.d/init.d/"${service}" reload ;;
103     status) /etc/rc.d/init.d/"${service}" status ;;
104   add) rc-config add "${service}" ;;   add) rc-config add "${service}" ;;
105   del) rc-config del "${service}" ;;   del) rc-config del "${service}" ;;
106   *) help_system_service && return ;;   *) help_system_service && return ;;
# Line 102  set_system_passwd() Line 116  set_system_passwd()
116   [[ -z ${pass} ]] && mecho "deleting password!"   [[ -z ${pass} ]] && mecho "deleting password!"
117    
118   case "${user}" in   case "${user}" in
119   root|mcore) (echo "${pass}"; sleep 0.1; echo "${pass}") | passwd "${user}" ;;   root|${MCORE_UNPRIV_USER}) (echo "${pass}"; sleep 0.1; echo "${pass}") | passwd "${user}" ;;
120   *) help_system_passwd && return 1 ;;   *) help_system_passwd && return 1 ;;
121   esac   esac
122  }  }
# Line 134  get_system_vt() Line 148  get_system_vt()
148  {  {
149   local tty   local tty
150   tty="$(fgconsole)"   tty="$(fgconsole)"
151   mecho "${tty}"   rvecho "${tty}"
152    }
153    
154    get_system_autologon()
155    {
156     local var
157     var=$(grep auto_login /etc/slim.conf | sed 's:auto_login.*\([yn].*\):\1:')
158     case "${var}" in
159     yes) mecho "autologon currently enabled"; rvecho "1" ;;
160     no) mecho "autologon currently disabled"; rvecho "0" ;;
161     *) eecho "unkown state" ;;
162     esac
163    }
164    
165    set_system_autologon()
166    {
167     local action="$1"
168     [[ -z ${action} ]] && help_system_autologon && return 1
169    
170     ## splash X11 tty too?
171    
172     case "${action}" in
173     enable)
174     sed -i 's:^\(auto_login\).*:\1\tyes:' /etc/slim.conf
175     mecho "autologon enabled"
176     ;;
177     disable)
178     sed -i 's:^\(auto_login\).*:\1\tno:' /etc/slim.conf
179     mecho "autologon disabled"
180     ;;
181     *) help_system_autologon && return 1 ;;
182     esac
183  }  }

Legend:
Removed from v.1262  
changed lines
  Added in v.2057