diff options
| author | Mattias Andrée <maandree@operamail.com> | 2013-09-30 03:09:49 +0200 |
|---|---|---|
| committer | Mattias Andrée <maandree@operamail.com> | 2013-09-30 03:09:49 +0200 |
| commit | 71ae0af4bad2fd38ded15bcb643f0ad73232c480 (patch) | |
| tree | ffed6e53674e5b62f5a439a867be4bd9df64c5f1 | |
| parent | misc fixes (diff) | |
| download | gates-of-tartaros-71ae0af4bad2fd38ded15bcb643f0ad73232c480.tar.gz gates-of-tartaros-71ae0af4bad2fd38ded15bcb643f0ad73232c480.tar.bz2 gates-of-tartaros-71ae0af4bad2fd38ded15bcb643f0ad73232c480.tar.xz | |
get rid of python
Signed-off-by: Mattias Andrée <maandree@operamail.com>
| -rw-r--r-- | Makefile | 14 | ||||
| -rw-r--r-- | README | 2 | ||||
| -rwxr-xr-x | got | 45 | ||||
| -rwxr-xr-x | got.py | 47 | ||||
| -rw-r--r-- | gotrc | 23 |
5 files changed, 50 insertions, 81 deletions
@@ -2,38 +2,29 @@ PREFIX = SYSCONF = /etc BIN = /bin SBIN = /sbin -LIBEXEC = /libexec LICENSES = /usr/share/licenses COMMAND = got PKGNAME = gates-of-tartaros BASH_SHEBANG = /usr/bin/env bash -PY3_SHEBANG = /usr/bin/env python3 - -all: got.install got.py.install got-cmd.install +all: got.install got-cmd.install got.install: got cp "$<" "$@" sed -i 's:#!/usr/bin/env bash:#!$(BASH_SHEBANG):g' "$@" sed -i 's:@prefix@:$(PREFIX):g' "$@" sed -i 's:@etc@:$(SYSCONF):g' "$@" - sed -i 's:@libexec@:$(LIBEXEC):g' "$@" sed -i 's:@command@:$(COMMAND):g' "$@" -got.py.install: got.py - cp "$<" "$@" - sed -i 's:#!/usr/bin/env python3:#!$(PY3_SHEBANG):g' "$@" - got-cmd.install: got-cmd cp "$<" "$@" sed -i 's:#!/usr/bin/env bash:#!$(BASH_SHEBANG):g' "$@" -install: got.install got.py.install got-cmd.install +install: got.install got-cmd.install install -Dm755 -- "got.install" "$(DESTDIR)$(PREFIX)$(SBIN)/got" - install -Dm755 -- "got.py.install" "$(DESTDIR)$(PREFIX)$(LIBEXEC)/got.py" install -Dm755 -- "got-cmd.install" "$(DESTDIR)$(PREFIX)$(BIN)/got-cmd" install -Dm644 -- "gotrc" "$(DESTDIR)$(SYSCONF)/gotrc.examples/lower-left-ponysay" install -d -- "$(DESTDIR)$(LICENSES)/$(PKGNAME)" @@ -42,7 +33,6 @@ install: got.install got.py.install got-cmd.install uninstall: -rm -- "$(DESTDIR)$(PREFIX)$(SBIN)/got" - -rm -- "$(DESTDIR)$(PREFIX)$(LIBEXEC)/got.py" -rm -- "$(DESTDIR)$(PREFIX)$(BIN)/got-cmd" -rm -- "$(DESTDIR)$(SYSCONF)/gotrc.examples/lower-left-ponysay" -rm -- "$(DESTDIR)$(LICENSES)/$(PKGNAME)/COPYING" @@ -1,5 +1,5 @@ Minimal replacement for agetty written in -Bash and Python with support for SSH. +GNU Bash with support for remote SSH login. En example /etc/gotrc file is included, it requires ponysay, util-say and KMS @@ -18,30 +18,53 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. -if [ "$1" = "---" ]; then +if [ "$1" = "-" ]; then tty="$2" shift 2 + export "$@" + + function _login + { + read user + if [ ! "${user/@/}" = "${user}" ]; then + export GOT_COMMAND="ssh ${user}" + login -p -f sshlogin + elif [ "${user::1}" = "-" ]; then + stty -icanon -echo -isig -ix{on,off,any} + echo $'\e[01;31mNice try! Sleeping for 10 minutes...\e[00m' + sleep 600 + else + login -- "${user}" + fi + } + + function _display + { + echo -en '\e[H\e[2J' + echo -e "\e[${ANSI_COLOR}m${NAME} (${tty})\e[00m" + echo + echo -n 'Login: ' + } + NAME="$(uname -o)" ANSI_COLOR='01;34' # must be exactly ANSI_COLOR as it is defined in /etc/os-release if [ -f "@etc@/os-release" ]; then . "@etc@/os-release" fi - if [ -f "@etc@/@command@rc" ]; then . "@etc@/@command@rc" - else - echo -en '\e[H\e[2J' - echo -e "\e[${ANSI_COLOR}m${NAME} (${tty})\e[00m" - echo - echo -n 'Login: ' fi - tty_settings="$(stty --save)" - @prefix@@libexec@/@command@.py "$@" - stty "${tty_settings}" + _display + _login else + # cannot get any other solution to work with `login` + # then to spawn a new process with pipes preset + tty="/dev/$1" - "$0" --- "$@" > "${tty}" 2> "${tty}" < "${tty}" + tty_settings="$(stty --save)" + "$0" - "$@" > "${tty}" 2> "${tty}" < "${tty}" + stty "${tty_settings}" fi @@ -1,47 +0,0 @@ -#!/usr/bin/env python3 -''' -gates-of-tartaros – Minimal replacement for agetty with SSH support - -Copyright © 2013 Mattias Andrée (maandree@member.fsf.org) - -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 -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see <http://www.gnu.org/licenses/>. -''' - - -import os -import sys -import time -from subprocess import Popen - - -for arg in sys.argv[1:]: - if "=" in arg: - os.putenv(arg.split("=")[0], "=".join(arg.split("=")[1:])) - -def spawn(cmd): - Popen(cmd, stdin = sys.stdin, stdout = sys.stdout, stderr = sys.stderr).wait() - - -user = input() -if "@" in user: - os.putenv("GOT_COMMAND", "ssh " + user) - spawn(["login", "-p", "-f", "sshlogin"]) -else: - if user.startswith("-"): - spawn(["stty", "-icanon", "-echo", "-isig", "-ixon", "-ixoff", "-ixany"]) - print("\033[01;31mNice try! Sleeping for 10 minutes...\033[00m") - time.sleep(10 * 60) - else: - spawn(["login", user]) - @@ -1,13 +1,16 @@ # -*- shell-script -*- -PALETTE=$'\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\e[?8c' -pony="$(PONYSAY_SHELL_LINES=5 PONYSAY_KMS_PALETTE="${PALETTE}" ponysay -o <&2)" -lines=$(wc -l <<< "${pony}") -height=$(stty size | cut -d ' ' -f 1) -echo -n $'\e['"$(( $height - $lines + 1 ));1H$(sed -e 's:\x1b\[H\x1b\[2J::' <<< "${pony}")${PALETTE}"$'\e[H' -echo -e "\e[${ANSI_COLOR}m${NAME} (${tty})\e[00m" -echo -echo -n 'Login: ' +function _display +{ + PALETTE=$'\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\e[?8c' + pony="$(PONYSAY_SHELL_LINES=5 PONYSAY_KMS_PALETTE="${PALETTE}" ponysay -o <&2)" + lines=$(wc -l <<< "${pony}") + height=$(stty size | cut -d ' ' -f 1) + echo -n $'\e['"$(( $height - $lines + 1 ));1H$(sed -e 's:\x1b\[H\x1b\[2J::' <<< "${pony}")${PALETTE}"$'\e[H' + echo -e "\e[${ANSI_COLOR}m${NAME} (${tty})\e[00m" + echo + echo -n 'Login: ' +} |
