Skip to content

Commit

Permalink
Fix to control terminal echo silently
Browse files Browse the repository at this point in the history
  • Loading branch information
iliajie committed Sep 22, 2024
1 parent 2484cc4 commit e297fe6
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions slib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#------------------------------------------------------------------------------
cleanup () {
exit_code=$1
stty echo
stty echo 1>/dev/null 2>&1
echo
# Make super duper sure we reap all the spinners
# This is ridiculous, and I still don't know why spinners stick around.
Expand Down Expand Up @@ -346,7 +346,7 @@ run_ok () {
CHECK='\u2714'
BALLOT_X='\u2718'
if [ "${INTERACTIVE_MODE}" != "off" ];then
stty -echo
stty -echo 1>/dev/null 2>&1
spinner &
spinpid=$!
allpids="$allpids $spinpid"
Expand All @@ -358,7 +358,7 @@ run_ok () {
env sleep .4 # It's possible to have a race for stdout and spinner clobbering the next bit
# Just in case the spinner survived somehow, kill it.
if [ "${INTERACTIVE_MODE}" != "off" ];then
stty echo
stty echo 1>/dev/null 2>&1
pidcheck=$(ps --no-headers ${spinpid})
if [ -n "$pidcheck" ]; then
echo "$log_pref Made it here...why?" >> ${RUN_LOG}
Expand Down Expand Up @@ -423,21 +423,21 @@ yesno () {
echo "Never run this script on a system already running Virtualmin."
return 1
fi
stty echo
stty echo 1>/dev/null 2>&1
while read -r line; do
stty -echo
stty -echo 1>/dev/null 2>&1
case $line in
y|Y|Yes|YES|yes|yES|yEs|YeS|yeS) return 0
;;
n|N|No|NO|no|nO) return 1
;;
*)
stty echo
stty echo 1>/dev/null 2>&1
printf "\\n${YELLOW}Please enter ${CYAN}[y]${YELLOW} or ${CYAN}[n]${YELLOW}:${NORMAL} "
;;
esac
done
stty -echo
stty -echo 1>/dev/null 2>&1
}

# mkdir if it doesn't exist
Expand Down Expand Up @@ -478,9 +478,9 @@ detect_ip () {
else
log_warning "Unable to determine IP address of primary interface."
echo "Please enter the name of your primary network interface: "
stty echo
stty echo 1>/dev/null 2>&1
read -r primaryinterface
stty -echo
stty -echo 1>/dev/null 2>&1
#primaryaddr=`/sbin/ifconfig $primaryinterface|grep 'inet addr'|cut -d: -f2|cut -d" " -f1`
primaryaddr=$(/sbin/ip -f inet -o -d addr show dev "$primaryinterface" | head -1 | awk '{print $4}' | head -1 | cut -d"/" -f1)
if [ "$primaryaddr" = "" ]; then
Expand Down Expand Up @@ -521,9 +521,9 @@ set_hostname () {
name=$(hostname -f)
log_error "Your system hostname $name is not fully qualified."
printf "Please enter a fully qualified hostname (e.g.: host.example.com): "
stty echo
stty echo 1>/dev/null 2>&1
read -r line
stty -echo
stty -echo 1>/dev/null 2>&1
else
log_debug "Setting hostname to $forcehostname"
line=$forcehostname
Expand Down Expand Up @@ -775,11 +775,11 @@ serial_ok () {
# Ask the user for a new serial number and license key
get_serial () {
printf "${YELLOW}Please enter your serial number or 'GPL': ${NORMAL}"
stty echo
stty echo 1>/dev/null 2>&1
read -r serial_num
stty -echo
stty -echo 1>/dev/null 2>&1
printf "${YELLOW}Please enter your license key or 'GPL': ${NORMAL}"
stty echo
stty echo 1>/dev/null 2>&1
read -r license_key
stty -echo
stty -echo 1>/dev/null 2>&1
}

0 comments on commit e297fe6

Please sign in to comment.