--- mcore-src/trunk/mcore-tools/daemon/client/include/system.client.class 2011/02/04 20:05:37 1262 +++ mcore-src/trunk/mcore-tools/daemon/client/include/system.client.class 2013/05/08 12:02:09 2057 @@ -23,7 +23,7 @@ # set_system_shutdown set_system_shutdown() { - halt + poweroff } help_system_console() @@ -31,7 +31,7 @@ mecho "set system.console [user]" mecho " Opens a console with user or root privileges." mecho " Known users:" - mecho " mcore - mcore standard user only with user privileges" + mecho " ${MCORE_UNPRIV_USER} - mcore standard user only with user privileges" mecho " root - mcore root user with full system privileges" } @@ -39,17 +39,29 @@ { mecho "set system.passwd [user] [password]" mecho " Sets a system password for given user." - mecho " Allowed users: mcore, root" + 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" + mecho " Shows the state of autlogon" + mecho + mecho "set system.autologon [action]" + mecho " Enables or disables X11 autologins of the mcore user." + mecho " Available actions:" + mecho " enable - enables autologon" + mecho " disable - disables autologon" +} + set_system_console() { local user="$1" [[ -z ${user} ]] && help_system_console && return 1 case "${user}" in - mcore) x11runas "rxvt &" ;; + ${MCORE_UNPRIV_USER}) x11runas "rxvt &" ;; root) x11runas "rxvt -T 'Login as root' -e /bin/bash -c 'echo \"Login as root\";exec /bin/login root' &" ;; *) help_system_console && return 1 ;; esac @@ -60,6 +72,7 @@ mecho "set system.service [command] [service] [opts]" mecho " Controls system services." mecho " Commands:" + mecho " status - prints status of given service" mecho " start - starts given service" mecho " stop - stops given service" mecho " restart - restart given service" @@ -77,9 +90,9 @@ [[ -z ${command} ]] && help_system_service && return 1 [[ -z ${service} ]] && help_system_service && return 1 - if [[ ! -x /etc/rc.d/init.d/${service} ]] + if [[ ! -x ${MROOT}/etc/rc.d/init.d/${service} ]] then - mecho "Service '${service}' unkown!" + eecho "Service '${service}' unkown!" fi case "${command}" in @@ -87,6 +100,7 @@ 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 ;; @@ -102,7 +116,7 @@ [[ -z ${pass} ]] && mecho "deleting password!" case "${user}" in - root|mcore) (echo "${pass}"; sleep 0.1; echo "${pass}") | passwd "${user}" ;; + root|${MCORE_UNPRIV_USER}) (echo "${pass}"; sleep 0.1; echo "${pass}") | passwd "${user}" ;; *) help_system_passwd && return 1 ;; esac } @@ -134,5 +148,36 @@ { local tty tty="$(fgconsole)" - mecho "${tty}" + rvecho "${tty}" +} + +get_system_autologon() +{ + local var + var=$(grep auto_login /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" ;; + *) eecho "unkown state" ;; + esac +} + +set_system_autologon() +{ + local action="$1" + [[ -z ${action} ]] && help_system_autologon && return 1 + + ## splash X11 tty too? + + case "${action}" in + enable) + sed -i 's:^\(auto_login\).*:\1\tyes:' /etc/slim.conf + mecho "autologon enabled" + ;; + disable) + sed -i 's:^\(auto_login\).*:\1\tno:' /etc/slim.conf + mecho "autologon disabled" + ;; + *) help_system_autologon && return 1 ;; + esac }