Files

72 lines
1.4 KiB
Bash

#!/usr/bin/env bash
export DIALOGOPTS='--insecure --no-lines --visit-items'
inputbox() {
local promptText="$1"
local initialValue="${2:-}"
dialog --backtitle "Configure Server" \
--clear \
--inputbox "$promptText" 0 0 "$initialValue" \
3>&1 1>/dev/tty 2>&3
}
passwordbox() {
local promptText="$1"
local initialValue="${2:-}"
dialog --backtitle "Configure Server" \
--clear \
--passwordbox "$promptText" 0 0 "$initialValue" \
3>&1 1>/dev/tty 2>&3
}
msgbox() {
dialog --backtitle "Configure Server" \
--clear \
--msgbox "$*" 10 72 \
> /dev/tty 2>&1
}
yesno() {
if dialog --backtitle "Configure Server" \
--clear \
--yesno "$*" 10 80 \
> /dev/tty 2>&1; then
echo "Yes"
else
echo "No"
fi
}
menulist() {
local promptText="Please select an option"
local menuList=()
local menuItem=""
if [[ "$1" == --prompt ]]; then
promptText="$2"
shift 2
fi
for menuItem in "$@"; do
menuList+=("$menuItem" "$menuItem")
done
dialog --backtitle "Configure Server" \
--clear \
--no-tags \
--menu "$promptText" 0 0 0 "${menuList[@]}" \
3>&1 1>/dev/tty 2>&3
}
textbox() {
local filePath="$1"
dialog --backtitle "Configure Server" \
--clear \
--textbox "$filePath" 0 0 \
> /dev/tty 2>&1
}