--- mcore-src/trunk/mcore-tools/daemon/client/include/system.client.class 2011/03/10 18:15:47 1648 +++ mcore-src/trunk/mcore-tools/src/modules/basic-system/system.client.class.in 2014/01/10 14:46:30 2199 @@ -1,6 +1,7 @@ # $Id$ provide basic-system +require basic-init help_system_reboot() { @@ -23,7 +24,7 @@ # set_system_shutdown set_system_shutdown() { - halt + poweroff } help_system_console() @@ -35,14 +36,6 @@ mecho " root - mcore root user with full system privileges" } -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." -} - help_system_autologon() { mecho "get system.autologon" @@ -60,6 +53,12 @@ local user="$1" [[ -z ${user} ]] && help_system_console && return 1 + if [[ -n ${MROOT} ]] && [[ ${MROOT} != / ]] + then + eecho "command not available while \$MROOT is set." + return 1 + fi + case "${user}" in ${MCORE_UNPRIV_USER}) x11runas "rxvt &" ;; root) x11runas "rxvt -T 'Login as root' -e /bin/bash -c 'echo \"Login as root\";exec /bin/login root' &" ;; @@ -69,40 +68,30 @@ help_system_service() { + mecho "get system.service [command] [service]" + mecho " Status information of system services." + mecho " Commands:" + mecho " status - prints status of given service" + mecho " enabled - check whether a service was enabled" + mecho " runlevel - print current system runlevel" + mecho mecho "set system.service [command] [service] [opts]" mecho " Controls system services." mecho " Commands:" - mecho " start - starts given service" - mecho " stop - stops given service" - mecho " restart - restart given service" - mecho " reload - reloads given service if possible" - mecho " add - adds a service to default runlevels" - mecho " del - deletes a service from all runlevels" + mecho " start - starts given service" + mecho " stop - stops given service" + mecho " restart - restart given service" + mecho " reload - reloads given service if possible" + mecho " enable - adds a service to default runlevels" + mecho " disable - deletes a service from all runlevels" } -set_system_service() +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 [[ ! -x /etc/rc.d/init.d/${service} ]] - then - eecho "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 + 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." } set_system_passwd() @@ -113,8 +102,14 @@ [[ -z ${user} ]] && help_system_passwd && return 1 [[ -z ${pass} ]] && mecho "deleting password!" + local chrooted + if [[ -n ${MROOT} ]] && [[ ${MROOT} != / ]] + then + chrooted="system_chroot" + fi + case "${user}" in - 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}" ;; *) help_system_passwd && return 1 ;; esac } @@ -152,7 +147,7 @@ get_system_autologon() { local var - 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:') case "${var}" in yes) mecho "autologon currently enabled"; rvecho "1" ;; no) mecho "autologon currently disabled"; rvecho "0" ;; @@ -169,11 +164,11 @@ case "${action}" in enable) - sed -i 's:^\(auto_login\).*:\1\tyes:' /etc/slim.conf + sed -i 's:^\(auto_login\).*:\1\tyes:' ${MROOT}/etc/slim.conf mecho "autologon enabled" ;; disable) - sed -i 's:^\(auto_login\).*:\1\tno:' /etc/slim.conf + sed -i 's:^\(auto_login\).*:\1\tno:' ${MROOT}/etc/slim.conf mecho "autologon disabled" ;; *) help_system_autologon && return 1 ;;