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 2075 by niro, Fri May 10 10:45:18 2013 UTC mcore-src/trunk/mcore-tools/src/modules/basic-system/system.client.class.in revision 2201 by niro, Fri Jan 10 14:48:40 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' &" ;;
65   *)     help_system_console && return 1 ;;   *) help_system_console && return 1 ;;
66   esac   esac
67  }  }
68    
# Line 83  help_system_service() Line 82  help_system_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"
 }  
   
 helper_set_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 ;;  
  add) rc-config add "${service}" ;;  
  del) rc-config del "${service}" ;;  
  *) help_system_service && return ;;  
  esac  
87  }  }
88    
89  helper_set_system_service_systemd()  help_system_passwd()
 {  
  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}" ;;  
  add) systemctl enable "${service}" ;;  
  del) systemctl disable "${service}" ;;  
  *) help_system_service && return ;;  
  esac  
 }  
   
 set_system_service()  
 {  
  if [[ -x $(type -P systemctl) ]]  
  then  
  helper_set_system_service_systemd $*  
  else  
  helper_set_system_service_sysvinit $*  
  fi  
 }  
   
 helper_get_system_service_sysvinit()  
 {  
  local command="$1"  
  local service="$2"  
   
  [[ -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  
  status) /etc/rc.d/init.d/"${service}" status ;;  
  enabled) rc-config show "${service}" ;;  
  runlevel) eecho "function on todo" ;;  
  *) help_system_service && return ;;  
  esac  
 }  
   
 helper_get_system_service_systemd()  
 {  
  local command="$1"  
  local service="$2"  
   
  [[ -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  
  status) systemctl status "${service}" ;;  
  enabled) systemctl is-enabled "${service}"; rvecho "$?" ;;  
  runlevel) rvecho "$(readline ${MROOT}/etc/systemd/system/default.target)" ;;  
  *) help_system_service && return ;;  
  esac  
 }  
   
 get_system_service()  
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_get_system_service_systemd $*   mecho "  Allowed users: ${MCORE_UNPRIV_USER}, root"
94   else   mecho "  If password is empty, the current password will be deleted."
  helper_get_system_service_sysvinit $*  
  fi  
95  }  }
96    
97  set_system_passwd()  set_system_passwd()
# Line 211  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 250  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}@@SYSCONFDIR@@/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 267  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}@@SYSCONFDIR@@/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}@@SYSCONFDIR@@/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.2075  
changed lines
  Added in v.2201