Daemon to manage cuberite and autostart script [info & download]
#1
Hi, i've been redoing my scripts, in order to tidy up all the code, and merge all so I ended up with 2 files, the cuberite.sh with all the functions and the cuberite file to use as daemon, I share it here in case anyone is interested, it doesn't compile the latest source, just use Jenkins builds, is working fine on Raspberry Pi 1 & 2 running Debian Jessie and Ubuntu X64/x86 , it won't work with Odroid.

Im running all the commands under root.

Daemon functions :
 
Code:
   start             -> Starts Cuberite Server.
   stop             -> Stops Cuberite Server.
   restart             -> Restarts Cuberite Server without updating or warning the online users (HARDRESET)
   update             -> Updates Cuberite Server to the latest available build.
   maintenance         -> Restarts Cuberite Server, sends a 5 minute warning to online users and updates Cuberite.
   status             -> Shows the status of the server [online/offline].
   log               -> View the latest logfile from the server.
   live               -> Switch to the current server instance (Real time logs)
   install               -> Install dependencies and Cuberite server.
   help             -> Shows this help page.


Insallation & Config:


Download the script and daemon:

Code:
wget https://www.dropbox.com/s/kp5xkzi2ng29cqk/cuberitedaemon.tar.gz


Extract the file in a folder of your choice:

Code:
tar -xvzf cuberitedaemon.tar.gz

You have to see now, 2 files, one named "cuberite" and another one named "cuberite.sh"


First of all edit cuberite.sh (use the editor that you want):

Code:
nano cuberite.sh


Line 4, modify the last path (after the last : )   /root/cuberite.sh to point to the folder where you have the script:

Code:
##Configuration
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/cuberite.sh



Line 15, modify the variables to point to the location where you want cuberite to be installed, if you already have a working server, backup your folder first in case anything will go wrong, and then modify the variable to point your current server folder.

Code:
## Cuberite Directory
CUBERITEDIR="/root/MCServer/"

Line 17, the cache directory, as before modify it to the folder where you want the cache to be, leave it hidden and outside the Server folder.

Code:
## Cache Directory
CACHEDIR="/root/.cuberiteupdate/"

Save the changes and exit the file.

Now edit the other file named "cuberite":

Code:
nano cuberite

Line 15, change the path to point to the cuberite.sh script

Code:
## Cuberite Directory
SCRIPTPATH="/root/cuberite.sh"


Save and exit.

Move the file to /etc/init.d/:

Code:
mv cuberite /etc/init.d/


Give permissions to the file:

Code:
chmod 775 cuberite


And register the script to start on boot:

Code:
update-rc.d cuberite defaults

And you're done.

Let's install Cuberite now, if this is not a fresh install please make a backup of your server folder before executing the command.

Code:
service cuberite install

This will install screen if you don't have it in your system, and then download the latest build and start the server.

You can stop the server to change the default config files:

Code:
service cuberite stop

And in case you want to switch to the current running server instance, to see the log in real time:

Code:
service cuberite live

This will resume the detached screen session, to get back to your terminal, press Ctrl+a+d in order to return without killing the session.

For other functions take a look at the info in the top of this post, or just type service cuberite help to see the available commands.

Hope it's useful to others, I will update it with more features when I have more time.

   
Reply
Thanks given by:


Messages In This Thread
Daemon to manage cuberite and autostart script [info & download] - by Rekuen - 02-28-2016, 01:29 AM



Users browsing this thread: 1 Guest(s)