# $Id$ provide basic-system require basic-init 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_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 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' &" ;; *) help_system_console && return 1 ;; esac } 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 " enable - adds a service to default runlevels" mecho " disable - deletes a service from all runlevels" } 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." } set_system_passwd() { local user="$1" local pass="$2" [[ -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}") | ${chrooted} 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 ${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" ;; *) 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:' ${MROOT}/etc/slim.conf mecho "autologon enabled" ;; disable) sed -i 's:^\(auto_login\).*:\1\tno:' ${MROOT}/etc/slim.conf mecho "autologon disabled" ;; *) help_system_autologon && return 1 ;; esac }