Magellan Linux

Diff of /mcore-src/trunk/mcore-tools/src/modules/basic-system/system.client.class.in

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

revision 1262 by niro, Fri Feb 4 20:05:37 2011 UTC revision 2090 by niro, Fri May 10 13:37:51 2013 UTC
# Line 1  Line 1 
1  # $Id$  # $Id$
2    
3  provide basic-system  provide basic-system
4    require basic-init
5    
6  help_system_reboot()  help_system_reboot()
7  {  {
# Line 23  help_system_shutdown() Line 24  help_system_shutdown()
24  # set_system_shutdown  # set_system_shutdown
25  set_system_shutdown()  set_system_shutdown()
26  {  {
27   halt   poweroff
28  }  }
29    
30  help_system_console()  help_system_console()
# Line 31  help_system_console() Line 32  help_system_console()
32   mecho "set system.console [user]"   mecho "set system.console [user]"
33   mecho " Opens a console with user or root privileges."   mecho " Opens a console with user or root privileges."
34   mecho " Known users:"   mecho " Known users:"
35   mecho "   mcore  - mcore standard user only with user privileges"   mecho "   ${MCORE_UNPRIV_USER}  - mcore standard user only with user privileges"
36   mecho "   root   - mcore root user with full system privileges"   mecho "   root   - mcore root user with full system privileges"
37  }  }
38    
39  help_system_passwd()  help_system_autologon()
40  {  {
41   mecho "set system.passwd [user] [password]"   mecho "get system.autologon"
42   mecho " Sets a system password for given user."   mecho "  Shows the state of autlogon"
43   mecho "  Allowed users: mcore, root"   mecho
44   mecho "  If password is empty, the current password will be deleted."   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()  set_system_console()
# Line 48  set_system_console() Line 53  set_system_console()
53   local user="$1"   local user="$1"
54   [[ -z ${user} ]] && help_system_console && return 1   [[ -z ${user} ]] && help_system_console && return 1
55    
56     if [[ -n ${MROOT} ]] && [[ ${MROOT} != / ]]
57     then
58     eecho "command not available while \$MROOT is set."
59     return 1
60     fi
61    
62   case "${user}" in   case "${user}" in
63   mcore) x11runas "rxvt &" ;;   ${MCORE_UNPRIV_USER}) x11runas "rxvt &" ;;
64   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' &" ;;
65   *)     help_system_console && return 1 ;;   *)     help_system_console && return 1 ;;
66   esac   esac
# Line 57  set_system_console() Line 68  set_system_console()
68    
69  help_system_service()  help_system_service()
70  {  {
71     mecho "get system.service [command] [service]"
72     mecho " Status information of system services."
73     mecho " Commands:"
74     mecho "   status   - prints status of given service"
75     mecho "   enabled  - check whether a service was enabled"
76     mecho "   runlevel - print current system runlevel"
77     mecho
78   mecho "set system.service [command] [service] [opts]"   mecho "set system.service [command] [service] [opts]"
79   mecho " Controls system services."   mecho " Controls system services."
80   mecho " Commands:"   mecho " Commands:"
81   mecho "   start   - starts given service"   mecho "   start    - starts given service"
82   mecho "   stop    - stops given service"   mecho "   stop     - stops given service"
83   mecho "   restart - restart given service"   mecho "   restart  - restart given service"
84   mecho "   reload  - reloads given service if possible"   mecho "   reload   - reloads given service if possible"
85   mecho "   add     - adds a service to default runlevels"   mecho "   enable   - adds a service to default runlevels"
86   mecho "   del     - deletes a service from all runlevels"   mecho "   disable  - deletes a service from all runlevels"
87  }  }
88    
89  set_system_service()  help_system_passwd()
90  {  {
91   local command="$1"   mecho "set system.passwd [user] [password]"
92   local service="$2"   mecho " Sets a system password for given user."
93   local opts="$3"   mecho "  Allowed users: ${MCORE_UNPRIV_USER}, root"
94     mecho "  If password is empty, the current password will be deleted."
  [[ -z ${command} ]] && help_system_service && return 1  
  [[ -z ${service} ]] && help_system_service && return 1  
   
  if [[ ! -x /etc/rc.d/init.d/${service} ]]  
  then  
  mecho "Service '${service}' unkown!"  
  fi  
   
  case "${command}" in  
  start) /etc/rc.d/init.d/"${service}" start ;;  
  stop) /etc/rc.d/init.d/"${service}" stop ;;  
  restart) /etc/rc.d/init.d/"${service}" restart ;;  
  reload) /etc/rc.d/init.d/"${service}" reload ;;  
  add) rc-config add "${service}" ;;  
  del) rc-config del "${service}" ;;  
  *) help_system_service && return ;;  
  esac  
95  }  }
96    
97  set_system_passwd()  set_system_passwd()
# Line 101  set_system_passwd() Line 102  set_system_passwd()
102   [[ -z ${user} ]] && help_system_passwd && return 1   [[ -z ${user} ]] && help_system_passwd && return 1
103   [[ -z ${pass} ]] && mecho "deleting password!"   [[ -z ${pass} ]] && mecho "deleting password!"
104    
105     local chrooted
106     if [[ -n ${MROOT} ]] && [[ ${MROOT} != / ]]
107     then
108     chrooted="system_chroot"
109     fi
110    
111   case "${user}" in   case "${user}" in
112   root|mcore) (echo "${pass}"; sleep 0.1; echo "${pass}") | passwd "${user}" ;;   root|${MCORE_UNPRIV_USER}) (echo "${pass}"; sleep 0.1; echo "${pass}") | ${chrooted} passwd "${user}" ;;
113   *) help_system_passwd && return 1 ;;   *) help_system_passwd && return 1 ;;
114   esac   esac
115  }  }
# Line 134  get_system_vt() Line 141  get_system_vt()
141  {  {
142   local tty   local tty
143   tty="$(fgconsole)"   tty="$(fgconsole)"
144   mecho "${tty}"   rvecho "${tty}"
145    }
146    
147    get_system_autologon()
148    {
149     local var
150     var=$(grep auto_login ${MROOT}/etc/slim.conf | sed 's:auto_login.*\([yn].*\):\1:')
151     case "${var}" in
152     yes) mecho "autologon currently enabled"; rvecho "1" ;;
153     no) mecho "autologon currently disabled"; rvecho "0" ;;
154     *) eecho "unkown state" ;;
155     esac
156    }
157    
158    set_system_autologon()
159    {
160     local action="$1"
161     [[ -z ${action} ]] && help_system_autologon && return 1
162    
163     ## splash X11 tty too?
164    
165     case "${action}" in
166     enable)
167     sed -i 's:^\(auto_login\).*:\1\tyes:' ${MROOT}/etc/slim.conf
168     mecho "autologon enabled"
169     ;;
170     disable)
171     sed -i 's:^\(auto_login\).*:\1\tno:' ${MROOT}/etc/slim.conf
172     mecho "autologon disabled"
173     ;;
174     *) help_system_autologon && return 1 ;;
175     esac
176  }  }

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