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 1345 by niro, Thu Feb 17 21:16:24 2011 UTC revision 2061 by niro, Wed May 8 12:57:23 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 72  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 80  help_system_service() Line 81  help_system_service()
81   mecho "   del     - deletes a service from all runlevels"   mecho "   del     - deletes a service from all runlevels"
82  }  }
83    
84  set_system_service()  helper_system_service_sysvinit()
85  {  {
86   local command="$1"   local command="$1"
87   local service="$2"   local service="$2"
# Line 89  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     return 1
97   fi   fi
98    
99   case "${command}" in   case "${command}" in
# Line 99  set_system_service() Line 101  set_system_service()
101   stop) /etc/rc.d/init.d/"${service}" stop ;;   stop) /etc/rc.d/init.d/"${service}" stop ;;
102   restart) /etc/rc.d/init.d/"${service}" restart ;;   restart) /etc/rc.d/init.d/"${service}" restart ;;
103   reload) /etc/rc.d/init.d/"${service}" reload ;;   reload) /etc/rc.d/init.d/"${service}" reload ;;
104     status) /etc/rc.d/init.d/"${service}" status ;;
105   add) rc-config add "${service}" ;;   add) rc-config add "${service}" ;;
106   del) rc-config del "${service}" ;;   del) rc-config del "${service}" ;;
107   *) help_system_service && return ;;   *) help_system_service && return ;;
108   esac   esac
109  }  }
110    
111    helper_system_service_systemd()
112    {
113     local command="$1"
114     local service="$2"
115     local opts="$3"
116    
117     [[ -z ${command} ]] && help_system_service && return 1
118     [[ -z ${service} ]] && help_system_service && return 1
119    
120     if [[ -n $(systemctl status ${service} | grep 'Reason: No such file or directory') ]]
121     then
122     eecho "Service '${service}' unkown!"
123     return 1
124     fi
125    
126     case "${command}" in
127     start) systemctl start "${service}" ;;
128     stop) systemctl stop "${service}" ;;
129     restart) systemctl try-restart "${service}" ;;
130     reload) systemctl reload-or-try-restart "${service}" ;;
131     status) systemctl status "${service}" ;;
132     add) systemctl enable "${service}" ;;
133     del) systemctl disable "${service}" ;;
134     *) help_system_service && return ;;
135     esac
136    }
137    
138    set_system_service()
139    {
140     if [[ -x $(type -P systemctl) ]]
141     then
142     helper_system_service_systemd $*
143     else
144     helper_system_service_sysvinit $*
145     fi
146    }
147    
148  set_system_passwd()  set_system_passwd()
149  {  {
150   local user="$1"   local user="$1"
# Line 146  get_system_vt() Line 186  get_system_vt()
186  {  {
187   local tty   local tty
188   tty="$(fgconsole)"   tty="$(fgconsole)"
189   mecho "${tty}"   rvecho "${tty}"
190  }  }
191    
192  get_system_autologon()  get_system_autologon()
# Line 154  get_system_autologon() Line 194  get_system_autologon()
194   local var   local var
195   var=$(grep auto_login /etc/slim.conf | sed 's:auto_login.*\([yn].*\):\1:')   var=$(grep auto_login /etc/slim.conf | sed 's:auto_login.*\([yn].*\):\1:')
196   case "${var}" in   case "${var}" in
197   yes) mecho "autologon currently enabled" ;;   yes) mecho "autologon currently enabled"; rvecho "1" ;;
198   no) mecho "autologon currently disabled" ;;   no) mecho "autologon currently disabled"; rvecho "0" ;;
199   *) eecho "unkown state" ;;   *) eecho "unkown state" ;;
200   esac   esac
201  }  }

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