diff options
Diffstat (limited to 'gotrc-examples/commands')
| -rw-r--r-- | gotrc-examples/commands | 82 |
1 files changed, 40 insertions, 42 deletions
diff --git a/gotrc-examples/commands b/gotrc-examples/commands index 0d57eca..6605884 100644 --- a/gotrc-examples/commands +++ b/gotrc-examples/commands @@ -2,7 +2,7 @@ # gates-of-tartaros – Minimal replacement for agetty with SSH support # -# Copyright © 2013, 2014, 2015 Mattias Andrée (maandree@member.fsf.org) +# Copyright © 2013, 2014, 2015 Mattias Andrée (m@maandree.se) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -24,42 +24,41 @@ login_function_commands=$login_function login_function=_login_commands -_login_commands () -{ - if [ ! "${user}" = "" ] && [ "${user%%+*}" = "" ]; then - if [ "${user}" = "+shutdown" ]; then - shutdown -h now - elif [ "${user}" = "+reboot" ]; then - reboot - elif [ "${user}" = "+time" ]; then - echo - date +%Y-\(%m\)%b-%d\ %T,\ %a\ w%W/%V,\ %Z - read __ - elif [ "${user}" = "+battery" ]; then - echo - acpi -V - read __ - elif [ "${user}" = "+backlight" ]; then - if [ "${LANG%UTF-8*}" = "${LANG}" ]; then - export LANG="en_GB.UTF-8" - fi - adjbacklight - elif [ "${user}" = "+keyboard" ]; then - echo "Enter keyboard layout: (e.g. sv-latin1)" - read -r layout - if [ ! "$(echo ${layout})" = "" ]; then - loadkeys -C "/dev/${tty}" -- ${layout} - if [ ! $? = 0 ]; then - echo 'Press ENTER to continue...' - read - fi - fi - elif [ "${user}" = "+1" ]; then - echo "Enter parameters: (e.g. tty7 TERM=linux)" - read -r params - setsid -- "$0" $params & - else - cat <<EOF +_login_commands () { + if test -n "${user}" && test -z "${user%%+*}"; then + if test "${user}" = "+shutdown"; then + shutdown -h now + elif test "${user}" = "+reboot"; then + reboot + elif test "${user}" = "+time"; then + printf '\n' + date +'%Y-(%m)%b-%d %T, %a w%W/%V, %Z' + read __ + elif test "${user}" = "+battery"; then + printf '\n' + acpi -V + read __ + elif test "${user}" = "+backlight"; then + if test "${LANG%UTF-8*}" = "${LANG}"; then + export LANG="en_GB.UTF-8" + fi + adjbacklight + elif test "${user}" = "+keyboard"; then + printf 'Enter keyboard layout: (e.g. sv-latin1)\n' + read -r layout + if test -n "${layout}"; then + loadkeys -C "/dev/${tty}" -- ${layout} + if test ! $? = 0; then + printf 'Press ENTER to continue...\n' + read + fi + fi + elif test "${user}" = "+1"; then + printf 'Enter parameters: (e.g. tty7 TERM=linux)\n' + read -r params + setsid -- "$0" $params & + else + cat <<EOF Command is not recognised. Recognised commands include: @@ -71,10 +70,9 @@ Recognised commands include: +keyboard Select keyboard layout for the TTY (This may effect all TTY:s) +1 Open a new gates-of-tartaros in another TTY EOF - read __ + read __ + fi + else + $login_function_commands fi - else - $login_function_commands - fi } - |
