我目前正在编写一个安装脚本来自动安装Hadoop主站和从站。由于我有时需要用户输入来配置 IP 地址等,因此我在安装脚本中安装了"对话框"。但是,脚本会跳过对话框并继续。为什么?
#!/bin/bash
if [ $(whoami) != "root" ];
then
echo "Must be run as root."
exit 1
fi
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get install -y dialog
choice=`dialog --clear --backtitle -"bla bla" --radiolist "Hadoop Install" 10 40 3 1 "Master" on "Slave" off 3>&1 1>&2 2>&3`
dialog --clear
clear
TYPE="hadoopmaster"
case $choice in
1) echo "Master"
TYPE="hadoopmaster";;
2) number=`dialog --clear --backtitle -"blaa" --
inputbox "Slave Number" 0 0 "" 3>&1 1>&2 2>&3`
dialog --clear
clear
TYPE="hadoopslave"$number;;
esac
apt-get update
apt-get install -y curl
apt-get install -y git
正确的命令是:
choice=`dialog --clear --backtitle -"bla bla" --radiolist "Hadoop Install" 10 40 3 1 "Master" on 2 "Slave" off 3>&1 1>&2 2>&3`
谢谢大家!