我有一段代码存在一些严重问题,我希望尽快解决它,但没有人提供任何帮助。我想尝试一些 Ubuntu 用户,因为这是运行脚本的操作系统。
mc_addplugin() {
if pgrep -u $USERNAME -f $SERVICE > /dev/null
then
echo "$SERVICE is running! Please stop the service before adding a plugin."
else
echo "Paste the URL to the .JAR Plugin..."
read JARURL
JARNAME=$(basename "$JARURL")
if [ -d "$TEMPPLUGINS" ]
then
as_user "cd $PLUGINSPATH && wget -r -A.jar $JARURL -o temp_plugins/$JARNAME"
else
as_user "cd $PLUGINSPATH && mkdir $TEMPPLUGINS && wget -r -A.jar $JARURL -o temp_plugins/$JARNAME"
fi
if [ -f "$TMPDIR/$JARNAME" ]
then
if [ -f "$PLUGINSPATH/$JARNAME" ]
then
if `diff $PLUGINSPATH/$JARNAME $TMPDIR/$JARNAME >/dev/null`
then
echo "You are already running the latest version of $JARNAME."
else
NOW=`date "+%Y-%m-%d_%Hh%M"`
echo "Are you sure you want to overwrite this plugin? [Y/n]"
echo "Note: Your old plugin will be moved to the "$TEMPPLUGINS" folder with todays date."
select yn in "Yes" "No"; do
case $yn in
Yes ) as_user "mv $PLUGINSPATH/$JARNAME $TEMPPLUGINS/${JARNAME}_${NOW} && mv $TEMPPLUGINS/$JARNAME $PLUGINSPATH/$JARNAME"; break;;
No ) echo "The plugin has not been installed! Removing temporary plugin and exiting..."
as_user "rm $TEMPPLUGINS/$JARNAME"; exit;;
esac
done
echo "Would you like to start the $SERVICE now? [Y/n]"
select yn in "Yes" "No"; do
case $yn in
Yes ) mc_start; break;;
No ) "$SERVICE not running! To start the service run: /etc/init.d/craftbukkit start"; exit;;
esac
done
fi
else
echo "Are you sure you want to add this new plugin? [Y/n]"
select yn in "Yes" "No"; do
case $yn in
Yes ) as_user "mv $PLUGINSPATH/$JARNAME $TEMPPLUGINS/${JARNAME}_${NOW} && mv $TEMPPLUGINS/$JARNAME $PLUGINSPATH/$JARNAME"; break;;
No ) echo "The plugin has not been installed! Removing temporary plugin and exiting..."
as_user "rm $TEMPPLUGINS/$JARNAME"; exit;;
esac
done
echo "Would you like to start the $SERVICE now? [Y/n]?"
select yn in "Yes" "No"; do
case $yn in
Yes ) mc_start; break;;
No ) "$SERVICE not running! To start the service run: /etc/init.d/craftbukkit start"; exit;;
esac
done
fi
else
echo "Failed to download the plugin from the URL you specified!"
exit;
fi
}
它将其抛到函数末尾的右括号中。
答案1
您缺少一个fi
语句来关闭第一个if
//then
条件else
。