这是该计划的来源,但当我尝试启动它时,我出错了:
#!/bin/bash
########################## help #############################
#
# -njc (Do not crawl if java is installed)
#
#
#
#############################################################
#function
function pause(){
read -p "$*"
}
## echo info
warn="\e[39m[\e[33mWarn\e[39m]"
error="\e[39m[\e[91mERROr\e[39m]"
info="\e[39m[\e[34mInfo\e[39m]"
quest="\e[39m[\e[32mQuestion\e[39m]"
###------------------------------
## check java
if ! echo "-njc" | grep -q "$*"; then ## se non attivato fai:
if type -p java; then
_java=java
elif [ -n "$JAVA_HOME" ] && [ -x "$JAVA_HOME/bin/java" ]; then
_java="$JAVA_HOME/bin/java"
else
echo -e $warn "No java version found. Please install java and try again."
echo
pause 'Press [Enter] key to continue...'
exit
fi
fi
clear
#------------question
##Create server directory
echo -e $quest "Enter the name of the folder where the server will be created. [Default is NewServer]"
read namedir
if [ -z "$namedir" ]; then
mkdir NewServer > /dev/null
cd NewServer > /dev/null
else
mkdir $namedir > /dev/null
cd $namedir > /dev/null
fi
echo -e $quest "Choose the spigot version. [Default is Latest]"
echo
echo ".----List of verion----."
echo "| 1) Latest |"
echo "| |"
echo "| 2) 1.11 |"
echo "| 3) 1.10 |"
echo "| 4) 1.9.4 |"
echo "| 5) 1.9.2 |"
echo "| 6) 1.9 |"
echo "| 7) 1.8.8 |"
echo "| 8) 1.8.7 |"
echo "| 9) 1.8.3 |"
echo "| 10) 1.8 |"
echo "#----------------------#"
echo
read ver
if [ -z "$ver" ]; then
version="latest"
elif [ $ver == 1]; then
version="latest"
elif [ $ver == 2]; then
version="1.11"
elif [ $ver == 3]; then
version="1.10"
elif [ $ver == 4]; then
version="1.9.4"
elif [ $ver == 5]; then
version="1.9.2"
elif [ $ver == 6]; then
version="1.9"
elif [ $ver == 7]; then:
version="1.8.8"
elif [ $ver == 8]; then
version="1.8.7"
elif [ $ver == 9]; then
version="1.8.3"
elif [ $ver == 10]; then
version="1.8"
else
echo -e $warn "The choice is invalid."
echo
pause 'Press [Enter] key to continue...'
exit
fi
echo -e $info "Java found"
## Download BuildTools.jar and remove old version
echo -e $info "Removing old versions of BuildTools.jar"
rm BuildTools.jar > /dev/null
echo -e $info "Downloading the latest version of BuildTools.jar. Please wait."
wget https://hub.spigotmc.org/jenkins/job/BuildTools/lastCompletedBuild/artifact/target/BuildTools.jar
echo -e $info "Download finished"
## Starting BuildTools.jar
echo -e $info "Spigot download has begun. Please wait"
sleep 3
java -jar BuildTools.jar --rev $version
echo -e $info "The spigot download is finished."
Pause 'Press [Enter] key to continue...'
当我从这个错误开始时:
./newscript.sh: line 89: syntax error near unexpected token `elif'
./newscript.sh: line 89: ` elif [ $ver == 8]; then'
我已经设置了chmod,并且已经使用dos2unix进行了转换
我也尝试了命令:cat Spigot-Install.sh | sed '/\015/d' >newscript.sh
我该如何解决?
答案 0 :(得分:1)
elif [ $ver == 7]; then:
version="1.8.8"
elif [ $ver == 8]; then
version="1.8.7"`
在elif [$ver == 7]; then:
行之后你有:
之后导致错误。只需删除:
并在条件中的每个]
之前放置空格。