Sonntag, 29. Mai 2011

A fast and easy way to install the Minecraft server in Ubuntu Linux

All you've got to do in order to install the minecraft server is follow these instructions.
Or you can use a shell script i wrote:
  1. download
  2. make it executable ( chmod a+x minecraft_server_setup.sh )
  3. execute it( ./minecraft_server_setup.sh )
show me the magic
#!/bin/bash
echo -n 'Do you want to (i)nstall or (s)tart the minecraft server?'
read watdo
startit(){ 
 if [ -d ~/.minecraft\ server/ ]; then
  cd ~/.minecraft\ server/
  echo -n "Do you have more than 1024MB of RAM?
  (y)es or (n)o"
  read watram
  echo -n "Do you want to start the server with a GUI?
   (y)es or (n)o"
  read watgui
  case "$watram" in 
   y|Y|Yes)
    case "$watgui" in
     y|Y|Yes)
      java -jar minecraft_server.jar
     ;;
     n|N|no|No)
      java -jar minecraft_server.jar nogui
     ;;
     *) echo "Unknown Parameter"
     read ''
     ;;
    esac 
   ;;
   n|N|no|No)
    case "$watgui" in
     y|Y|Yes)
      java -Xmx1024M -Xms1024M -jar minecraft_server.jar
     ;;
     n|N|no|No)
      java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui
     ;;
     *) echo "Unknown Parameter" 
     read ''
     ;;
    esac 
   ;;
   *) echo "Unknown Parameter" 
   read ''
   ;;
  esac
 else
  echo "You don't seem to have the Minecraft server installed.
Do you want to install it now?
(y)es or (n)o"
  read watdo
  installit
 fi
 
}
installit(){
 case "$watdo" in
 y|Y|yes|Yes|i|I|install|Install) 
 if [ ! -d ~/.minecraft\ server/ ]; then
  mkdir ~/.minecraft\ server
  cd ~/.minecraft\ server/
  wget http://www.minecraft.net/download/minecraft_server.jar
  chmod a+x minecraft_server.jar
  echo -n "Do you want to start the server now?
   (y)es or (n)o"
  read startnow
  case "$startnow" in
  y|Y|Yes)
   startit
  ;;
  *)  
  ;;
  esac
 else
  echo "The Minecraft Server seems to be installed.
Do you want to start it now?
(y)es or (n)o"
  read watnowdo
  case "$watnowdo" in
  y|Y|yes|Yes)
   startit
  ;;
  *)
  ;;
  esac
 fi
 ;;
 s|S|start|Start)
  startit
 ;;
 n|N|no|No)
  exit 0
 ;;
 *) 
  echo "Unknown Parameter" 
  read ''
 ;;
esac
}
installit
exit 0

I know the code is pretty messy, but it's the first shell script i've written so I'm OK with it ;)

2 Kommentare:

Michael hat gesagt…

Installing.

Agent 001 hat gesagt…

nice man im lovin your tips!

Kommentar veröffentlichen