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

mcore-src/trunk/mcore-tools/daemon/client/include/system.client.class revision 2061 by niro, Wed May 8 12:57:23 2013 UTC mcore-src/trunk/mcore-tools/src/modules/basic-system/system.client.class.in revision 2199 by niro, Fri Jan 10 14:46:30 2014 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 35  help_system_console() Line 36  help_system_console()
36   mecho "   root   - mcore root user with full system privileges"   mecho "   root   - mcore root user with full system privileges"
37  }  }
38    
 help_system_passwd()  
 {  
  mecho "set system.passwd [user] [password]"  
  mecho " Sets a system password for given user."  
  mecho "  Allowed users: ${MCORE_UNPRIV_USER}, root"  
  mecho "  If password is empty, the current password will be deleted."  
 }  
   
39  help_system_autologon()  help_system_autologon()
40  {  {
41   mecho "get system.autologon"   mecho "get system.autologon"
# Line 60  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_UNPRIV_USER}) 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' &" ;;
# Line 69  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 "   status  - prints status of given service"   mecho "   start    - starts given service"
82   mecho "   start   - starts given service"   mecho "   stop     - stops given service"
83   mecho "   stop    - stops given service"   mecho "   restart  - restart given service"
84   mecho "   restart - restart given service"   mecho "   reload   - reloads given service if possible"
85   mecho "   reload  - reloads given service if possible"   mecho "   enable   - adds a service to default runlevels"
86   mecho "   add     - adds a service to default runlevels"   mecho "   disable  - deletes a service from all runlevels"
  mecho "   del     - deletes a service from all runlevels"  
 }  
   
 helper_system_service_sysvinit()  
 {  
  local command="$1"  
  local service="$2"  
  local opts="$3"  
   
  [[ -z ${command} ]] && help_system_service && return 1  
  [[ -z ${service} ]] && help_system_service && return 1  
   
  if [[ ! -x ${MROOT}/etc/rc.d/init.d/${service} ]]  
  then  
  eecho "Service '${service}' unkown!"  
  return 1  
  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 ;;  
  status) /etc/rc.d/init.d/"${service}" status ;;  
  add) rc-config add "${service}" ;;  
  del) rc-config del "${service}" ;;  
  *) help_system_service && return ;;  
  esac  
 }  
   
 helper_system_service_systemd()  
 {  
  local command="$1"  
  local service="$2"  
  local opts="$3"  
   
  [[ -z ${command} ]] && help_system_service && return 1  
  [[ -z ${service} ]] && help_system_service && return 1  
   
  if [[ -n $(systemctl status ${service} | grep 'Reason: No such file or directory') ]]  
  then  
  eecho "Service '${service}' unkown!"  
  return 1  
  fi  
   
  case "${command}" in  
  start) systemctl start "${service}" ;;  
  stop) systemctl stop "${service}" ;;  
  restart) systemctl try-restart "${service}" ;;  
  reload) systemctl reload-or-try-restart "${service}" ;;  
  status) systemctl status "${service}" ;;  
  add) systemctl enable "${service}" ;;  
  del) systemctl disable "${service}" ;;  
  *) help_system_service && return ;;  
  esac  
87  }  }
88    
89  set_system_service()  help_system_passwd()
90  {  {
91   if [[ -x $(type -P systemctl) ]]   mecho "set system.passwd [user] [password]"
92   then   mecho " Sets a system password for given user."
93   helper_system_service_systemd $*   mecho "  Allowed users: ${MCORE_UNPRIV_USER}, root"
94   else   mecho "  If password is empty, the current password will be deleted."
  helper_system_service_sysvinit $*  
  fi  
95  }  }
96    
97  set_system_passwd()  set_system_passwd()
# Line 153  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_UNPRIV_USER}) (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 192  get_system_vt() Line 147  get_system_vt()
147  get_system_autologon()  get_system_autologon()
148  {  {
149   local var   local var
150   var=$(grep auto_login /etc/slim.conf | sed 's:auto_login.*\([yn].*\):\1:')   var=$(grep auto_login ${MROOT}/etc/slim.conf | sed 's:auto_login.*\([yn].*\):\1:')
151   case "${var}" in   case "${var}" in
152   yes) mecho "autologon currently enabled"; rvecho "1" ;;   yes) mecho "autologon currently enabled"; rvecho "1" ;;
153   no) mecho "autologon currently disabled"; rvecho "0" ;;   no) mecho "autologon currently disabled"; rvecho "0" ;;
# Line 209  set_system_autologon() Line 164  set_system_autologon()
164    
165   case "${action}" in   case "${action}" in
166   enable)   enable)
167   sed -i 's:^\(auto_login\).*:\1\tyes:' /etc/slim.conf   sed -i 's:^\(auto_login\).*:\1\tyes:' ${MROOT}/etc/slim.conf
168   mecho "autologon enabled"   mecho "autologon enabled"
169   ;;   ;;
170   disable)   disable)
171   sed -i 's:^\(auto_login\).*:\1\tno:' /etc/slim.conf   sed -i 's:^\(auto_login\).*:\1\tno:' ${MROOT}/etc/slim.conf
172   mecho "autologon disabled"   mecho "autologon disabled"
173   ;;   ;;
174   *) help_system_autologon && return 1 ;;   *) help_system_autologon && return 1 ;;

Legend:
Removed from v.2061  
changed lines
  Added in v.2199