如果这条信息在这里不太合适,我提前表示歉意,但我相信这是一个好地方。
当我执行 bash 脚本时出现这个奇怪的错误:
./cluster_bootstrap.sh
./cluster_bootstrap.sh: line 15: $'\r': command not found
./cluster_bootstrap.sh: line 91: warning: here-document at line 37 delimited by end-of-file (wanted `EOF')
./cluster_bootstrap.sh: line 92: syntax error: unexpected end of file
同时,当我将脚本复制粘贴到我的 shell 中时,一切似乎都正确。您对这种奇怪的行为有什么看法?
PS:这是我的脚本:
address=192.168.1.101
# DNS (Celui du FAI est: 80.10.246.130 ; tandis que celui de google est 8.8.8.8)
nameserver=8.8.8.8
#Hostname
hostname=slave1
#Hosts
hostname_master=master
address_master=192.168.1.100
hostname_slave1=slave1
address_slave1=192.168.1.101
hostname_slave2=slave2
address_slave2=192.168.1.102
#__I) ________ Configuration d'une ip statique pour le bridge Network__________
#0) Install ifupdown et resolvconf
if [ -z `which resolvconf` ]
then
echo "sudo apt install resolvconf is required"
sudo apt install resolvconf
else
echo "resolvconf is already installed!"
fi
if [ -z `which ifup` ]
then
echo "sudo apt install ifupdown is required"
sudo apt install resolvconf
else
echo "ifupdown is already installed!"
echo "Super!"
fi
#1) Configurer l'adresse statique
#cat << EOF | sudo tee /etc/network/interfaces
sudo tee /etc/network/interfaces << EOF
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
auto enp0s3
iface enp0s3 inet static
address $address
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
EOF
sudo ifup enp0s3
#2) Configurer le DNS
sudo tee /etc/resolvconf/resolv.conf.d/tail << EOF
nameserver $nameserver
EOF
#3)
#sudo reboot
#__II) ________ Configuration de clés ssh_________
#1) hostname
echo "hostname=$hostname"
echo "$hostname " | sudo tee /etc/hostname
#2) hosts
sudo tee /etc/hosts << EOF
127.0.0.1 localhost
$address_master $hostname_master
$address_slave1 $hostname_slave1
$address_slave2 $hostname_slave2
EOF