- Joined
- Jan 21, 2013
- Messages
- 215
- Reaction score
- 43
My newest project was born out of the need to access console commands from SSH. After a little searching I was able to adapt a existing script to fit my needs and perhaps the needs of many others. Without further ado, I present Doomsider's Starmade Daemon (DSD).
Verion .13 October 26, 2013
https://drive.google.com/file/d/0B519td3ku8G1bld5OXZ6dFlleTg/edit?usp=sharing
alternative link
ftp://ftp.nasszone.com/daemon/13/starmaded
What do I do with it?
You put it in your /etc/init.d and then
chmod ug+x /etc/init.d/starmaded
to make it executable
What the hell does it do?
Good question, a little of everything here is a quick overview of the commands
All of these commands come at the end of /etc/init.d/starmaded (IE: /etc/init.d/stamaded start)
start - Starts the server
stop - Stops the server with a server message and countdown approx 2 mins
ebrake - Stop the server without a server message approx 30 seconds
destroy - Deletes Server no recovery
install - Download a new starter and do a install
reinstall - Destroys current server and installs new fresh one
smrestore filename - Selected file unzips into the parent folder of starmade
smdo command - Issues a server command. Use quotes if there are spaces
smsay words - Say something as the server. Use quotes if there are spaces
backup - backs up current Starmade directory as zip
backupstar - Stops cron and server, makes backup, restarts cron and server
status - See if server is running
cronstop - Removes all cronjobs
cronrestore - Restores all cronjobs
cronbackup - Backs up your cron file
upgrade - Runs the starters upgrade routine
upgradestar - Stops cron and server, runs upgrade, restarts cron and server
restart - Stops and starts server
smplayermaxset number - Change max players to this setting. Helpful to set to 0 for maintenance
detect - See if the server is frozen and restart if it is
log - Logs admin, chat, player, and kills
screenlog - Starts a screen which starts the log function
check - Checks for new version. If found send message, stop server, backup, download and install new verion
precheck - Checks for new PRE version. if found send message, stop server, backup, download and install new verion
smban - Bans a player by their names and IP address
version .04
Fix for Chat (Schema Changed it to /chat so I fixed it)
smdetect - Detects if the server is frozen by sending the time and date and then checking the outputlog to see if server recieved. This will only work if you use startout to generate a log file
Version .05
Added port option to support running daemon with multiple copies of Starmade on same server. Also added new log function smlog which records Players logged on off, kills, admin commands, chat, and active players. Look forwards to a code rewrite for the next version as things have gotten sloppy.
version .06
I added in a variable for screen names so it will be easier to run multiple copies of starmade on the same server with different daemon scripts. I re-wrote for several hours troubleshooting and making the code more consistent. I improved and altered every function in the script with new routines. I added in path variables for logging and changed the start function to always log. smlog and smdetect are now log and detect respectively. I have several different projects so stay tuned for future developments.
version .07
Added a new command screenlog that starts the logging session in a screen. I fixed the stop routine and start routine to be more accurate in dealing with screens. I addressed a bug that would allow dead screens to prevent the server from starting by adding screen -wipe where needed. I reworked the logging function and removed the script that linked chatID to player name. Chat will still be logged it just won't have the persons name in place of the chatID.
Vesrion .08-.09
Fixed start function by adding in -port:$PORT to allow servers to use other ports
Fixed install function it had a error on a add_user command
Added a routine to screenlog to ensure multiple copies will not run
Changed back to using ps aux to detect servers due to inconsistency with screen
Added in grep for port:$port and grep -v tee to remove fale positives
Fixed Backup to correctly detect is zip has been installed or not
Completely re-did logging to update it to current server output. Added new logging in as well.
Version .10
Fixed ship and station names with a space so they work with logging. Fixed a bug that transposed playername into ship log. Added check and precheck to help automate updates. Added a destroy routine to remove ships and station from their respective logs when they are destroyed or removed. Fixed other minor bugs and reformated script to be more readable. I will go back and add more comments in later to make what the script is doing more clear. Added in chat commands, please see !HELP ingame for a list. Added in a Ranking system to control access to chat commands, you will have to add yourself to rank.log with the chosen RANK5 name to be able to set ranks.
Version .11
Added routine to allow anyone in admins.txt to use !RANKSET. Fixed Shipbuy log. Fixed Chat Import and Despawn commands. Added routine into detect to prevent the server from resetting while repairing the database. Added services into main start line so if you are running a modified or renamed StarMade.jar it will work. Added Chat commands to give players items and cash as well as adding people to whitelist and listing people on whitelist
Version .12
Added a routine to shutdown screenlog in case it was still running. Moved variables from screenlog to the beggining of the daemon to make it more easy to configure. Changed output log variable so it was more consistent. Added a line that can be uncommented right after server start to begin screen logging for admin commands. Added in a !RAKCOMMAND to allow users to see what their ranks can do. Added in ANHAMMER command so a client with the proper rank can now ban a player with name and IP. Added a new function called smban which essentially does the same thing as banhammer only can be used from command line. Fixed some other minor bugs and did some formatting. Still have some concerns about some of the logging function. You can always comment out everything but chat string if you just want chat commands on you server.
Version .13
I decided to rewrite logging directory structure. Screen logging is now default and all logs are dumped into starterpath/logs. At Schema's request jstack does a threaddump.log when ebrake is used for the detect routine. I run the detect routine ever 5 minutes with cronjob to see if the server is reponsive, if not it will restart the server. You can send you threddump.log to Schema so he can troubleshoot the crashes better. I also added a few comments and formatted a bit to make things easier to seperate.
Whats this cron crap?
Since this script was originally written for NASS I had to make sure it would work with the existing cronjobs that keep the server running and start things like backup. You can remove or ignore it if you do not use cronjobs to automate your server
Multi Server Support
The Daemon can assist in running more than one server on the same machine. Just rename the daemon to anything you want and then chenge the path vairables, screen ID, and the port to something different than your current server. Then you can then run either daemon file to control the proper server.
Currently I would suggest running the deamon from the root directory of you Starmade servers and naming each daemon the name of the server it is running. This can greatly help to simplify running more than one server on the same machine.
Anything else?
No not really, be sure to edit this and change the settings at the beggining of the file to match your setup. I designed this Daemon so it can be called from other scripts to make your life easier. Do with it as you please. It is free as in beer - Cheers! (Some people have been confused by this saying, basically it is open source an you can do whatever you want with the code)
Verion .13 October 26, 2013
https://drive.google.com/file/d/0B519td3ku8G1bld5OXZ6dFlleTg/edit?usp=sharing
alternative link
ftp://ftp.nasszone.com/daemon/13/starmaded
What do I do with it?
You put it in your /etc/init.d and then
chmod ug+x /etc/init.d/starmaded
to make it executable
What the hell does it do?
Good question, a little of everything here is a quick overview of the commands
All of these commands come at the end of /etc/init.d/starmaded (IE: /etc/init.d/stamaded start)
start - Starts the server
stop - Stops the server with a server message and countdown approx 2 mins
ebrake - Stop the server without a server message approx 30 seconds
destroy - Deletes Server no recovery
install - Download a new starter and do a install
reinstall - Destroys current server and installs new fresh one
smrestore filename - Selected file unzips into the parent folder of starmade
smdo command - Issues a server command. Use quotes if there are spaces
smsay words - Say something as the server. Use quotes if there are spaces
backup - backs up current Starmade directory as zip
backupstar - Stops cron and server, makes backup, restarts cron and server
status - See if server is running
cronstop - Removes all cronjobs
cronrestore - Restores all cronjobs
cronbackup - Backs up your cron file
upgrade - Runs the starters upgrade routine
upgradestar - Stops cron and server, runs upgrade, restarts cron and server
restart - Stops and starts server
smplayermaxset number - Change max players to this setting. Helpful to set to 0 for maintenance
detect - See if the server is frozen and restart if it is
log - Logs admin, chat, player, and kills
screenlog - Starts a screen which starts the log function
check - Checks for new version. If found send message, stop server, backup, download and install new verion
precheck - Checks for new PRE version. if found send message, stop server, backup, download and install new verion
smban - Bans a player by their names and IP address
version .04
Fix for Chat (Schema Changed it to /chat so I fixed it)
smdetect - Detects if the server is frozen by sending the time and date and then checking the outputlog to see if server recieved. This will only work if you use startout to generate a log file
Version .05
Added port option to support running daemon with multiple copies of Starmade on same server. Also added new log function smlog which records Players logged on off, kills, admin commands, chat, and active players. Look forwards to a code rewrite for the next version as things have gotten sloppy.
version .06
I added in a variable for screen names so it will be easier to run multiple copies of starmade on the same server with different daemon scripts. I re-wrote for several hours troubleshooting and making the code more consistent. I improved and altered every function in the script with new routines. I added in path variables for logging and changed the start function to always log. smlog and smdetect are now log and detect respectively. I have several different projects so stay tuned for future developments.
version .07
Added a new command screenlog that starts the logging session in a screen. I fixed the stop routine and start routine to be more accurate in dealing with screens. I addressed a bug that would allow dead screens to prevent the server from starting by adding screen -wipe where needed. I reworked the logging function and removed the script that linked chatID to player name. Chat will still be logged it just won't have the persons name in place of the chatID.
Vesrion .08-.09
Fixed start function by adding in -port:$PORT to allow servers to use other ports
Fixed install function it had a error on a add_user command
Added a routine to screenlog to ensure multiple copies will not run
Changed back to using ps aux to detect servers due to inconsistency with screen
Added in grep for port:$port and grep -v tee to remove fale positives
Fixed Backup to correctly detect is zip has been installed or not
Completely re-did logging to update it to current server output. Added new logging in as well.
Version .10
Fixed ship and station names with a space so they work with logging. Fixed a bug that transposed playername into ship log. Added check and precheck to help automate updates. Added a destroy routine to remove ships and station from their respective logs when they are destroyed or removed. Fixed other minor bugs and reformated script to be more readable. I will go back and add more comments in later to make what the script is doing more clear. Added in chat commands, please see !HELP ingame for a list. Added in a Ranking system to control access to chat commands, you will have to add yourself to rank.log with the chosen RANK5 name to be able to set ranks.
Version .11
Added routine to allow anyone in admins.txt to use !RANKSET. Fixed Shipbuy log. Fixed Chat Import and Despawn commands. Added routine into detect to prevent the server from resetting while repairing the database. Added services into main start line so if you are running a modified or renamed StarMade.jar it will work. Added Chat commands to give players items and cash as well as adding people to whitelist and listing people on whitelist
Version .12
Added a routine to shutdown screenlog in case it was still running. Moved variables from screenlog to the beggining of the daemon to make it more easy to configure. Changed output log variable so it was more consistent. Added a line that can be uncommented right after server start to begin screen logging for admin commands. Added in a !RAKCOMMAND to allow users to see what their ranks can do. Added in ANHAMMER command so a client with the proper rank can now ban a player with name and IP. Added a new function called smban which essentially does the same thing as banhammer only can be used from command line. Fixed some other minor bugs and did some formatting. Still have some concerns about some of the logging function. You can always comment out everything but chat string if you just want chat commands on you server.
Version .13
I decided to rewrite logging directory structure. Screen logging is now default and all logs are dumped into starterpath/logs. At Schema's request jstack does a threaddump.log when ebrake is used for the detect routine. I run the detect routine ever 5 minutes with cronjob to see if the server is reponsive, if not it will restart the server. You can send you threddump.log to Schema so he can troubleshoot the crashes better. I also added a few comments and formatted a bit to make things easier to seperate.
Whats this cron crap?
Since this script was originally written for NASS I had to make sure it would work with the existing cronjobs that keep the server running and start things like backup. You can remove or ignore it if you do not use cronjobs to automate your server
Multi Server Support
The Daemon can assist in running more than one server on the same machine. Just rename the daemon to anything you want and then chenge the path vairables, screen ID, and the port to something different than your current server. Then you can then run either daemon file to control the proper server.
Currently I would suggest running the deamon from the root directory of you Starmade servers and naming each daemon the name of the server it is running. This can greatly help to simplify running more than one server on the same machine.
Anything else?
No not really, be sure to edit this and change the settings at the beggining of the file to match your setup. I designed this Daemon so it can be called from other scripts to make your life easier. Do with it as you please. It is free as in beer - Cheers! (Some people have been confused by this saying, basically it is open source an you can do whatever you want with the code)