Yannick
2012-06-20 07:53:20 UTC
Here is the code can you try to find where the error comes from?
The scipt:
#!/bin/bash
#Please don't redistribute this script
#This script need some php scripts for browser based plugin and server settings uploading
#function for plugin config at start :)
function plugin_cfgstart {
if [ $1 = "restore"]
then
restore_backup()
fi
cp -f /minecraftserver /var/www/plugin_edit/minecraftserver
#call plugin manager
plugin_mgr()
}
#function plugin manager :D
function plugin_mgr {
#Copy all plugins to bukkit plugin dir
if [ -f /var/www/plugin_upload/*.jar ]
then
echo 'Handeling plugins...'
cp /var/www/plugin_upload/*.jar /minecraftserver/plugins/
fi
#if there is a file called hello.jar.delete inside '/var/www/plugin_delete', it will cut off the .delete extention and delete /minecraftserver/plugins/hello.jar
if [ -f /var/www/plugin_delete/*.jar.delete ]
then
#it will do it for every file in /var/www/plugin_delete (a do for loop)
for f in /var/www/plugin_delete/*.jar.delete ; do STRDEL="${FILE%.*}"
echo "Deleting plugin $STRDEL..."
rm "/minecraftserver/plugins/$STRDEL"
rm "/var/www/plugin_delete/$STRDEL.delete"
done
fi
#if there is a file called hello.jar.update inside '/var/www/plugin_update', it will cut off the .update extention and replace the /minecraftserver/plugins/hello.jar
if [ -f /var/www/plugin_update/*.jar.update ]
then
#another do for loop
for f in /var/www/plugin_update/*.jar.update ; do STRUPDATE="${FILE%.*}"
echo "Updating plugin $STRUPDATE..."
mv "/var/www/plugin_update/$STRUPDATE" /minecraftserver/plugins/
done
fi
#start function start server
start()
}
#function start server
function start {
#start the craftbukkit.jar
cd minecraftserver
java -Xmx1024M -Xms1024M -jar craftbukkit.jar
echo 'Server stopped!'
quit()
}
#final function: quit?
function quit {
#set a variable choice to 4
choice=4
# Print to console
echo "Do you want to restart?"
echo "1. yes"
echo "2. no"
echo -n "Please choose [1 or 2]? "
# Loop while the variable choice is equal 4
while [ $choice -eq 4 ]; do
# read user input
read choice
#if choice is equal to 1
if [ $choice -eq 1 ] ; then
echo "restarting..."
#load plugin config :D
plugin_cfgend()
plugin_cfgstart()
fi
#if choice is equal to 2 exit script
if [ $choice -eq 2 ] ; then
cp -r /minecraft/plugins /var/www/plugin_edit/
echo "Closing serverscript..."
plugin_cfgend()
exit
fi
}
#restore from backup
function restore_backup {
tar xvfz MCBackup.tar.gz
}
#function plugin config on the end
function plugin_cfgend {
echo 'backing up original...'
echo 'installing new'
mv -f /var/www/plugin_edit/minecraftserver /minecraftserver
}