diff options
| author | Mattias Andrée <m@maandree.se> | 2026-02-22 13:50:59 +0100 |
|---|---|---|
| committer | Mattias Andrée <m@maandree.se> | 2026-02-22 13:50:59 +0100 |
| commit | 5593186c998c3f63c7abadd3eaa97e55004fc182 (patch) | |
| tree | 29a236c52d30257ea67d933fbd7bdf14bc400258 /gotrc-examples | |
| parent | Fix issue-file example, it stopped working (diff) | |
| download | gates-of-tartaros-5593186c998c3f63c7abadd3eaa97e55004fc182.tar.gz gates-of-tartaros-5593186c998c3f63c7abadd3eaa97e55004fc182.tar.bz2 gates-of-tartaros-5593186c998c3f63c7abadd3eaa97e55004fc182.tar.xz | |
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'gotrc-examples')
| -rw-r--r-- | gotrc-examples/README | 10 | ||||
| -rw-r--r-- | gotrc-examples/allow-uppercase | 32 | ||||
| -rw-r--r-- | gotrc-examples/baudrate | 14 | ||||
| -rw-r--r-- | gotrc-examples/cerberus | 8 | ||||
| -rw-r--r-- | gotrc-examples/commands | 82 | ||||
| -rw-r--r-- | gotrc-examples/hide-username | 29 | ||||
| -rw-r--r-- | gotrc-examples/issue-file | 15 | ||||
| -rw-r--r-- | gotrc-examples/loadkeys | 34 | ||||
| -rw-r--r-- | gotrc-examples/lower-left-ponysay | 27 | ||||
| -rw-r--r-- | gotrc-examples/no-empty-user | 14 | ||||
| -rw-r--r-- | gotrc-examples/readline | 8 | ||||
| -rw-r--r-- | gotrc-examples/revoke-access | 12 |
12 files changed, 127 insertions, 158 deletions
diff --git a/gotrc-examples/README b/gotrc-examples/README index cdd2d29..1ed40e4 100644 --- a/gotrc-examples/README +++ b/gotrc-examples/README @@ -1,15 +1,9 @@ -These are templates you can used for your gotrc file. +These are templates you can use for your gotrc file. If you are happy with them as is, you can include -them directly in your by gotrc file with for example: +them directly in your gotrc file, for example: . /etc/gotrc-examples/no-empty-user Although, it may be better to copy the ones you are using into a directory named /etc/got.d and include them from there. - -If you create any cool or useful extensions yourself -and do not object to licenses them under the GNU -General Public License version 3, please submit them -to <https://github.com/GNU-Pony/gates-of-tartaros>. - diff --git a/gotrc-examples/allow-uppercase b/gotrc-examples/allow-uppercase index 3bb0db1..556f137 100644 --- a/gotrc-examples/allow-uppercase +++ b/gotrc-examples/allow-uppercase @@ -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,21 +24,19 @@ read_function_allow_uppercase=$read_function read_function=_read_allow_uppercase -_read_allow_uppercase () -{ - $read_function_allow_uppercase - lower="" - for word in $user; do - if [ ! "${word%%-*}" = "" ]; then # This check is done so SSH arguments are not made into lower case - word="$(echo "${word}" | sed -e 'y/QWERTYUIOPASDFGHJKLZXCVBNM/qwertyuiopasdfghjklzxcvbnm/')" +_read_allow_uppercase () { + $read_function_allow_uppercase + lower="" + for word in $user; do + if test -n "${word%%-*}"; then # This check is done so SSH arguments are not made into lower case + word="$(echo "${word}" | sed -e 'y/QWERTYUIOPASDFGHJKLZXCVBNM/qwertyuiopasdfghjklzxcvbnm/')" + fi + lower="${lower} ${word}" + done + lower="${lower# *}" + if test ! "${lower}" = "${user}"; then + #stty olcuc ## Uncomment this if you want to go old-school Unix, too bad + ## it will break colours and only uppercases ASCII letters. + user="${lower}" fi - lower="${lower} ${word}" - done - lower="${lower# *}" - if [ ! "${lower}" = "${user}" ]; then - #stty olcuc ## Uncomment this if you want to go old-school Unix, too bad - ## it will break colours and only uppercases ASCII letters. - user="${lower}" - fi } - diff --git a/gotrc-examples/baudrate b/gotrc-examples/baudrate index 684722f..7fc29aa 100644 --- a/gotrc-examples/baudrate +++ b/gotrc-examples/baudrate @@ -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 @@ -29,11 +29,9 @@ display_function_baudrate=$display_function display_function=_display_baudrate -_display_baudrate () -{ - if [ ! "${BAUDRATE}" = "" ]; then - stty ${BAUDRATE} - fi - $display_function_baudrate +_display_baudrate () { + if test -n "${BAUDRATE}"; then + stty ${BAUDRATE} + fi + $display_function_baudrate } - diff --git a/gotrc-examples/cerberus b/gotrc-examples/cerberus index e0761ca..9efa783 100644 --- a/gotrc-examples/cerberus +++ b/gotrc-examples/cerberus @@ -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 @@ -22,8 +22,6 @@ # cerberus instead of login -_use_login () -{ - exec cerberus -- "${user}" +_use_login () { + exec cerberus -- "${user}" } - 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 } - diff --git a/gotrc-examples/hide-username b/gotrc-examples/hide-username index 05d670f..798fa34 100644 --- a/gotrc-examples/hide-username +++ b/gotrc-examples/hide-username @@ -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 @@ -28,25 +28,22 @@ read_function_hide_username=$read_function read_function=_read_hide_username -_read_hide_username () -{ - local _read_tty_settings - _read_tty_settings="$(stty --save)" - stty -echo - - $read_function_hide_username - - stty "${_read_tty_settings}" - echo +_read_hide_username () { + local _read_tty_settings + _read_tty_settings="$(stty --save)" + stty -echo + + $read_function_hide_username + + stty "${_read_tty_settings}" + printf '\n' } # If you use GNU Bash for gates-of-tartaros, # you can use this instead: -# _read () -# { -# read -s user -# echo +# _read () { +# read -s user +# echo # } - diff --git a/gotrc-examples/issue-file b/gotrc-examples/issue-file index a620117..9fa5dcc 100644 --- a/gotrc-examples/issue-file +++ b/gotrc-examples/issue-file @@ -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 @@ -21,10 +21,9 @@ # Module for using the /etc/issue file -_display () -{ - if [ ! -f "/etc/issue.default" ] || [ ! "$(md5sum < "/etc/issue.default")" = "$(md5sum < "/etc/issue")" ]; then - python3 <<EOF +_display () { + if test ! -f "/etc/issue.default" || test ! "$(md5sum < "/etc/issue.default")" = "$(md5sum < "/etc/issue")"; then + python3 <<EOF import os import sys from subprocess import Popen, PIPE @@ -98,8 +97,6 @@ for i in range(len(data)): sys.stdout.buffer.write(buf.encode('utf-8')) sys.stdout.buffer.flush() EOF - echo - echo -n 'Login: ' - fi + printf '\nLogin: ' + fi } - diff --git a/gotrc-examples/loadkeys b/gotrc-examples/loadkeys index b3b2352..f755656 100644 --- a/gotrc-examples/loadkeys +++ b/gotrc-examples/loadkeys @@ -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 @@ -26,22 +26,20 @@ login_function_loadkeys=$login_function login_function=_login_loadkeys -_login_loadkeys () -{ - if [ "${user}" = "" ]; then - printf '%s' 'Keyboard layout: ' - $read_function - if [ ! "${user}" = "" ]; then - user_="$(printf "%s" "${user}" | sed 's:/::g')" - if [ "${user}" = "${user_}" ]; then - loadkeys -C $(tty) -- ${user} || sleep 2 - else - echo 'Sorry, only installed keymaps!' - sleep 2 - fi +_login_loadkeys () { + if test -z "${user}"; then + printf 'Keyboard layout: ' + $read_function + if test -n "${user}"; then + user_="$(printf "%s" "${user}" | tr -d /)" + if test "${user}" = "${user_}"; then + loadkeys -C $(tty) -- ${user} || sleep 2 + else + printf 'Sorry, only installed keymaps!\n' + sleep 2 + fi + fi + else + $login_function_loadkeys fi - else - $login_function_loadkeys - fi } - diff --git a/gotrc-examples/lower-left-ponysay b/gotrc-examples/lower-left-ponysay index 62da1cc..387665f 100644 --- a/gotrc-examples/lower-left-ponysay +++ b/gotrc-examples/lower-left-ponysay @@ -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 @@ -23,18 +23,15 @@ # as well as set a nice palette to the TTY. -_display () -{ - PALETTE="$(echo -e '\e]P0020840\e]P1CD656C\e]P232A679\e]P3CCAD47\e]P42495BE\e]P5A46EB0\e]P600A09F\e]P7D3D7CF\e]P8555753\e]P9EB5E6A\e]PA0EC287\e]PBF2CA38\e]PC00ACE0\e]PDC473D1\e]PE00C3C7\e]PFEEEEEE')" - echo -n "${PALETTE}" - echo -en '\e[H\e[2J' - pony="$(PONYSAY_SHELL_LINES=5 PONYSAY_KMS_PALETTE="${PALETTE}" ponysay -o <&2)" - lines=$(echo "${pony}" | wc -l) - height=$(stty size | cut -d ' ' -f 1) - echo -en '\e['"$(( $height - $lines + 1 ));1H" - echo -n "$(echo "${pony}" | sed -e 's:\x1b\[H\x1b\[2J::')${PALETTE}" - echo -e "\e[H\e[${ANSI_COLOR}m${NAME} (${tty})\e[00m" - echo - echo -n 'Login: ' +_display () { + PALETTE="$(printf '\033]P0020840\033]P1CD656C\033]P232A679\033]P3CCAD47\033]P42495BE\033]P5A46EB0\033]P600A09F\033]P7D3D7CF\033]P8555753\033]P9EB5E6A\033]PA0EC287\033]PBF2CA38\033]PC00ACE0\033]PDC473D1\033]PE00C3C7\033]PFEEEEEE')" + printf '%s' "${PALETTE}" + printf '\033[H\033[2J' + pony="$(PONYSAY_SHELL_LINES=5 PONYSAY_KMS_PALETTE="${PALETTE}" ponysay -o <&2)" + lines=$(echo "${pony}" | wc -l) + height=$(stty size | cut -d ' ' -f 1) + printf '\033[%s;1H' "$(( $height - $lines + 1 ))" + printf '%s%s' "$(echo "${pony}" | sed -e 's:\x1b\[H\x1b\[2J::')" "${PALETTE}" + echo -e "\033[H\033[%sm%s (%s)\033[0m" "${ANSI_COLOR}" "${NAME}" "${tty}" + printf '\nLogin: ' } - diff --git a/gotrc-examples/no-empty-user b/gotrc-examples/no-empty-user index 4cdec36..074bd14 100644 --- a/gotrc-examples/no-empty-user +++ b/gotrc-examples/no-empty-user @@ -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,11 +24,9 @@ read_function_no_empty_user=$read_function read_function=_read_no_empty_user -_read_no_empty_user () -{ - $read_function_no_empty_user - if [ "${user}" = "" ]; then - exit 0 - fi +_read_no_empty_user () { + $read_function_no_empty_user + if test -z "${user}"; then + exit 0 + fi } - diff --git a/gotrc-examples/readline b/gotrc-examples/readline index e67078c..2c545a5 100644 --- a/gotrc-examples/readline +++ b/gotrc-examples/readline @@ -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 @@ -25,8 +25,6 @@ # line instead of erasing in order to get to the wanted possition. -_read () -{ - read -e user +_read () { + read -e user } - diff --git a/gotrc-examples/revoke-access b/gotrc-examples/revoke-access index e79b9fc..77558c6 100644 --- a/gotrc-examples/revoke-access +++ b/gotrc-examples/revoke-access @@ -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 @@ -25,10 +25,8 @@ display_function_revoke_access=$display_function display_function=_display_revoke_access -_display_revoke_access () -{ - chmod 640 "$(tty)" - chown 0:0 "$(tty)" - $display_function_revoke_access +_display_revoke_access () { + chmod 640 "$(tty)" + chown 0:0 "$(tty)" + $display_function_revoke_access } - |
