85 lines
1.8 KiB
Plaintext
85 lines
1.8 KiB
Plaintext
err() {
|
|
echo $1
|
|
echo "exiting.."
|
|
exit 1
|
|
}
|
|
|
|
input_old() {
|
|
local input
|
|
local found="0"
|
|
echo "$1 $2"
|
|
read input
|
|
for i in $2; do
|
|
if [ "$i" == "$input" ]; then
|
|
found=1
|
|
fi
|
|
done
|
|
if [ "$found" == "0" ]; then
|
|
err "$input: $3"
|
|
return 1
|
|
fi
|
|
output="$input"
|
|
}
|
|
|
|
header() {
|
|
clear
|
|
echo "#### $1"
|
|
}
|
|
|
|
addpkg() {
|
|
for i in $@; do
|
|
pkgs+=( "$i" )
|
|
done
|
|
}
|
|
|
|
enable_service() {
|
|
ln -s /etc/sv/$1 /etc/runit/runsvdir/default/
|
|
}
|
|
|
|
reset() {
|
|
if [ "$1" == "packages" ]; then
|
|
function packages() { :; }
|
|
fi
|
|
}
|
|
|
|
input() {
|
|
output=""
|
|
echo "${1}"
|
|
read -r -p "[${2}]: " output
|
|
test -z "${output}" && output="${2}"
|
|
return 0
|
|
}
|
|
|
|
#multiplechoice "networksystem" "dhcpcd" "networkmanager" "iwd" "none"
|
|
|
|
multiplechoice() {
|
|
output=""
|
|
local done=""
|
|
local input=("${@}")
|
|
#for i in $(seq 1 "$(( ${#input[@]} - 1 ))"); do
|
|
for i in $(seq 0 "$(( ${#input[@]} - 1 ))"); do
|
|
if [[ "${i}" == "0" ]]; then
|
|
choices="${input[$i]}"
|
|
use="${input[$i]}"
|
|
else
|
|
choices="${choices}|${input[$i]}"
|
|
use+=" ${input[$i]}"
|
|
fi
|
|
done
|
|
while input "[${choices}]: " "${input[0]}"; do
|
|
for i in $(seq 0 "${#input[@]}"); do
|
|
if [[ "${output}" == "${input[$i]}" ]] || [[ "${output}" == "${input[$i]:0:2}" ]]; then
|
|
output="${input[$i]}"
|
|
done=1
|
|
fi
|
|
done
|
|
if [[ -z "${done}" ]]; then
|
|
echo wronginput "${output}"
|
|
echo use these: "${use}"
|
|
else
|
|
break
|
|
fi
|
|
|
|
done
|
|
}
|