# $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() { halt } help_system_console() { 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 " 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, root" mecho " If password is empty, the current password will be deleted." } set_system_console() { local user="$1" [[ -z ${user} ]] && help_system_console && return 1 case "${user}" in mcore) 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 " 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 /etc/rc.d/init.d/${service} ]] then mecho "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 } 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) (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)" mecho "${tty}" }