# $Id$ provide basic-system help_system_reboot() { mecho "set system.reboot" mecho " Reboots the system." } # set_system_reboot set_system_reboot() { reboot } help_system_shutdown() { mecho "set system.shutdown" mecho " Shuts the system down." } # set_system_shutdown set_system_shutdown() { poweroff } help_system_console() { mecho "set system.console [user]" mecho " Opens a console with user or root privileges." mecho " Known users:" mecho " ${MCORE_UNPRIV_USER} - mcore standard user only with user privileges" 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" 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_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 } help_system_service() { 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" mecho " reload - reloads given service if possible" mecho " add - adds a service to default runlevels" mecho " del - deletes a service from all runlevels" } set_system_service() { 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!" 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 } set_system_passwd() { local user="$1" local pass="$2" [[ -z ${user} ]] && help_system_passwd && return 1 [[ -z ${pass} ]] && mecho "deleting password!" case "${user}" in root|${MCORE_UNPRIV_USER}) (echo "${pass}"; sleep 0.1; echo "${pass}") | passwd "${user}" ;; *) help_system_passwd && return 1 ;; esac } help_system_vt() { mecho "get system.vt" mecho " Prints tty number of the current vt terminal." mecho mecho "set system.vt [tty]" mecho " Change current vt terminal to given tty." mecho " Valid tty numbers are 1-9." } set_system_vt() { local tty="$1" [[ -z ${tty} ]] && help_system_vt && return 1 case "${tty}" in [1-9]) chvt "${tty}" mecho "current vt changed to ${tty}." ;; *) help_system_vt && return 1 ;; esac } get_system_vt() { local tty tty="$(fgconsole)" 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 }