Jump to content

Need help with Debian Start Script

Go to solution Solved by manikyath,

your options, for future reference, and people who randomly find this in google search, theres a few -very- easy options:

 

option 1: you have no experience in scripting, arent very into the whole linux world, and just want your server to be able to managed remotely

 

try MineOS: https://github.com/hexparrot/mineos

its absolute shit, but it works, is user friendly and powerful.

its basicly a web frontend that does the same thing as the (actually good) management panels that the big mc hosting companies use, and is free and opensource.

 

option 2: you got your linuxy penguinfeet a bit wet, got the hang of it and are ready to learn

 

(spoilered because mucho info)

try writing your own scripts (doesnt only apply to minecraft here, use this for any kind of server software)

first off, make a directory for your scripts, like ~/starters (~ = home directory, for example /home/manikyath) DO NOT USE ROOT FOR YOUR SERVER SOFTWARE, EVER.

second, install "screen" using the package manager for your distro ("apt-get install screen" for the debian/ubuntu folks, "pacman -Syu screen" for the arch folks, etc)

screen allows you to attach and detach terminal sessions, you'll read why you need this later.

next make your scripts in your scripts directory, according to what you need, examples follow:

 

what i called the "enter" script, this prints the available commands, and removes the need to type "./" before your commands. please note, "subfolder" is a replacement for an actual useful subfolder name, please replace, add or remove as needed.

#!/bin/bashcd ~/startersexport PATH=$PATH:.echo --{commands}----------------------lsecho --{subfolder commands}---------ls subfolder

the next script is what i've used for minecraft, gmod and a few other games for a while, all in the same basic format:

theres a tag where you can start a session detached, i personally choose not to, because i like to confirm my server is starting fine.

#!/bin/bashcd <insert server folder here, if minecraft server is located in /home/manikyath/servers/minecraft, thats exactly what needs to be typed here>screen -S <name of session, put something you'll recognise here, example: MC1710> <launch command, example: java -Xms256M -Xmx4G -jar minecraft1710.jar>

next a utility i like to keep around:

"clearCache", a script to free up as much ram as possible, handy if your server has very little available resources.

#!/bin/bashsudo sh -c "sync; echo 3 > /proc/sys/vm/drop_caches"

finally i should explain how to use screen:

to make a session, you use screen -S <session name>

to detach from a session, hold left contol, then press A followed by D

to reattach to a detached session type screen -r <session name> (session name not required if only one session is running, screen is really smart at figuring out where you want to be)

to see the running sessions, type screen -ls

 

to exit a session, type exit. a session that was given a command at opening (like in the script we wrote) will exit automagicly when the command finishes.

 

---

 

now, you are gonna ask two things:

1: well, how do i manage my servers with this?

simple, you reattach to the server session, and are presented with full console access, and can detach when you're done.

2: how do i do this remotely?

install an SSD daemon on your server (opensssh-server for example, can be pre-installed on debian and ubuntu server)

use putty (http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html) to connect to your server.

whatever the linuxy folks say, i like putty, because it does what i need it to.

 

 

option 3: you know your way around linux (then you'd probably not be here, but you never know)

 

dig into the script pahimar uses on forgecraft, it does some pretty fancy voodoo, and i suggest digging into it if you want some advanced automation features.

https://github.com/pahimar/ForgeCraft-Script

Well, it doesn't start and now I am clueless, help? :o The MC folder belongs to user "lars", but I made it with rood and used chown -R lars to change the owner.

 

 

#!/bin/sh
# chkconfig: 2345 99 10
USER="lars"
Minecraft='/home/mc'
STARTSCRIPT="/start.sh"
cd $lars
case "$1" in
'start')
su $USER -c "$STARTSCRIPT start"
;;
'stop')
su $USER -c "$STARTSCRIPT stop"
;;
'restart')
su $USER -c "$STARTSCRIPT restart"
;;
'status')
su $USER -c "$STARTSCRIPT status"
;;
*)

echo "Usage $0 start|stop|restart|status"
esac

 

YsPq6Kb.png

Intel 4790k | Asus Z97 Maximus VII Impact | Corsair Vengeance Pro Series 16 GB 1866Mhz | Asus Strix GTX 980 | CoolerMaster G550 |Samsung Evo 250GB | Synology DS215j (NAS) | Logitech G502 |

 

Link to comment
Share on other sites

Link to post
Share on other sites

so.. my knowledge of this corner of linux is a tad rusty, but what you're trying to achieve here completely blows my mind...

 

also, i'm pretty sure it's DANG flippin' hard to control minecraft like this, pahimar did it, and i'm not even close to grasping how he achieved the voodoo within his forgecraft scripts.

Link to comment
Share on other sites

Link to post
Share on other sites

so.. my knowledge of this corner of linux is a tad rusty, but what you're trying to achieve here completely blows my mind...

 

also, i'm pretty sure it's DANG flippin' hard to control minecraft like this, pahimar did it, and i'm not even close to grasping how he achieved the voodoo within his forgecraft scripts.

 

ok, turns out what I tried is BS and will not work in a 100 years. :ph34r:

Intel 4790k | Asus Z97 Maximus VII Impact | Corsair Vengeance Pro Series 16 GB 1866Mhz | Asus Strix GTX 980 | CoolerMaster G550 |Samsung Evo 250GB | Synology DS215j (NAS) | Logitech G502 |

 

Link to comment
Share on other sites

Link to post
Share on other sites

ok, turns out what I tried is BS and will not work in a 100 years. :ph34r:

i know what your end goal is, i'm guessing you want to control your minecraft server trough SSH? (or remotely in general)

theres a few options you could have a go at.

Link to comment
Share on other sites

Link to post
Share on other sites

your options, for future reference, and people who randomly find this in google search, theres a few -very- easy options:

 

option 1: you have no experience in scripting, arent very into the whole linux world, and just want your server to be able to managed remotely

 

try MineOS: https://github.com/hexparrot/mineos

its absolute shit, but it works, is user friendly and powerful.

its basicly a web frontend that does the same thing as the (actually good) management panels that the big mc hosting companies use, and is free and opensource.

 

option 2: you got your linuxy penguinfeet a bit wet, got the hang of it and are ready to learn

 

(spoilered because mucho info)

try writing your own scripts (doesnt only apply to minecraft here, use this for any kind of server software)

first off, make a directory for your scripts, like ~/starters (~ = home directory, for example /home/manikyath) DO NOT USE ROOT FOR YOUR SERVER SOFTWARE, EVER.

second, install "screen" using the package manager for your distro ("apt-get install screen" for the debian/ubuntu folks, "pacman -Syu screen" for the arch folks, etc)

screen allows you to attach and detach terminal sessions, you'll read why you need this later.

next make your scripts in your scripts directory, according to what you need, examples follow:

 

what i called the "enter" script, this prints the available commands, and removes the need to type "./" before your commands. please note, "subfolder" is a replacement for an actual useful subfolder name, please replace, add or remove as needed.

#!/bin/bashcd ~/startersexport PATH=$PATH:.echo --{commands}----------------------lsecho --{subfolder commands}---------ls subfolder

the next script is what i've used for minecraft, gmod and a few other games for a while, all in the same basic format:

theres a tag where you can start a session detached, i personally choose not to, because i like to confirm my server is starting fine.

#!/bin/bashcd <insert server folder here, if minecraft server is located in /home/manikyath/servers/minecraft, thats exactly what needs to be typed here>screen -S <name of session, put something you'll recognise here, example: MC1710> <launch command, example: java -Xms256M -Xmx4G -jar minecraft1710.jar>

next a utility i like to keep around:

"clearCache", a script to free up as much ram as possible, handy if your server has very little available resources.

#!/bin/bashsudo sh -c "sync; echo 3 > /proc/sys/vm/drop_caches"

finally i should explain how to use screen:

to make a session, you use screen -S <session name>

to detach from a session, hold left contol, then press A followed by D

to reattach to a detached session type screen -r <session name> (session name not required if only one session is running, screen is really smart at figuring out where you want to be)

to see the running sessions, type screen -ls

 

to exit a session, type exit. a session that was given a command at opening (like in the script we wrote) will exit automagicly when the command finishes.

 

---

 

now, you are gonna ask two things:

1: well, how do i manage my servers with this?

simple, you reattach to the server session, and are presented with full console access, and can detach when you're done.

2: how do i do this remotely?

install an SSD daemon on your server (opensssh-server for example, can be pre-installed on debian and ubuntu server)

use putty (http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html) to connect to your server.

whatever the linuxy folks say, i like putty, because it does what i need it to.

 

 

option 3: you know your way around linux (then you'd probably not be here, but you never know)

 

dig into the script pahimar uses on forgecraft, it does some pretty fancy voodoo, and i suggest digging into it if you want some advanced automation features.

https://github.com/pahimar/ForgeCraft-Script

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×