From a6c197569a35b023cb1d681deb3a22fbde82048e Mon Sep 17 00:00:00 2001 From: Jonas Gunz Date: Tue, 24 Mar 2020 20:36:31 +0100 Subject: smaller gaps, sudo write vim --- scripts/system-setup | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100755 scripts/system-setup (limited to 'scripts/system-setup') diff --git a/scripts/system-setup b/scripts/system-setup new file mode 100755 index 0000000..6e2bebe --- /dev/null +++ b/scripts/system-setup @@ -0,0 +1,64 @@ +#!/bin/bash + +#interactive systen setup + +AUTHKEY_FILE_URL="https://jonasgunz.de/authorized_keys" + +if [ $(id -u) -ne 0 ]; then + echo Supposed to run as root. + return 1 +fi + +yes_no() +{ + read -p "$1 (y/[n])" inp + case $inp in + [yY]* ) return 0;; + * ) return 1;; + esac +} + +selector() +{ + local cnt=0 + local regex="^-?[0-9]+\$" + for selection in "$@" + do + echo "$cnt) $selection" + ((cnt=$cnt + 1)) + done + + read -p "(default=0) >" inp + if [[ "$inp" =~ $regex ]] && [ $inp -ge 0 -a $inp -le $# ] + then + return $inp + elif [ -z $inp ] + then + return 0 + else + return -1 + fi +} + +function user_setup() { + while true; do + read -p "Name for new User: " username + if [ ! -z $username ]; then + break; + fi + done +} + +echo "Interactive system setup" + +while true ; do + selector "User setup" "Exit" + case $? in + 0) + user_setup;; + 1) + exit 0;; + *) + echo Wrong input;; + esac +done -- cgit v1.2.3