Coder Social home page Coder Social logo

hexparrot / mineos-node Goto Github PK

View Code? Open in Web Editor NEW
332.0 30.0 166.0 5.29 MB

node.js implementation of mineos minecraft management

License: GNU General Public License v3.0

JavaScript 71.05% CSS 13.33% HTML 14.86% Shell 0.64% Dockerfile 0.09% Makefile 0.03%

mineos-node's Introduction

Node.JS MineOS

MineOS is a server front-end to ease managing Minecraft administrative tasks. This iteration using Node.js aims to enhance previous MineOS scripts (Python-based), by leveraging the event-triggering, asyncronous model of Node.JS and websockets.

This allows the front-end to provide system health, disk and memory usage, and logging in real-time.

This has been tested on Debian, Ubuntu, ArchLinux, and FreeBSD and should work on all variants, Linux or BSD.

Installation

MineOS is distributed through github and downloads its dependencies with npm.

MineOS requires root-privileges, as the authentication relies on the underlying system's /etc/shadow.

Do not install this atop an existing MineOS system (using the Python-based webui), since the installation location is the same /usr/games/minecraft. Following are steps for installing MineOS on an apt-get based distribution, such as Debian or Ubuntu. These instructions are detailed further (as well as for additional distributions) on the MineOS wiki.

Using an apt-get based Linux distribution:

curl -sL https://deb.nodesource.com/setup_8.x | bash -
apt-get update
apt-get install -y nodejs git rdiff-backup screen build-essential openjdk-8-jre-headless
mkdir -p /usr/games
cd /usr/games
git clone https://github.com/hexparrot/mineos-node.git minecraft
cd minecraft
chmod +x generate-sslcert.sh
./generate-sslcert.sh
cp mineos.conf /etc/mineos.conf
npm install

For hosts using 'upstart':

cp /usr/games/minecraft/init/upstart_conf /etc/init/mineos.conf
start mineos

For hosts using 'supervisor':

cp /usr/games/minecraft/init/supervisor_conf /etc/supervisor/conf.d/mineos.conf
supervisorctl reread
supervisorctl update
supervisorctl start mineos

For hosts using 'systemd':

cp /usr/games/minecraft/init/systemd_conf /etc/systemd/system/mineos.service
systemctl enable mineos
systemctl start mineos

To use the webui as a background daemon:

node service.js [start|stop|restart|status]

To start the webui in the foreground:

node webui.js

Things to watch out for

On FreeBSD, you will need to mount a Linux-compatible /proc filesystem, i.e., linprocfs, at /usr/compat/linux/proc in order for the web-ui to work. In addition, where CLANG is default for your system, you'll need to build the NPM modules differently:

echo "CXX=c++ npm install" | sh

Mineos-node requires rsync 3.1.x or later, 3.0.x does not have the ability to chown on copy, which is essential for profiles. Depending on your distribution, you may need to build it from source.

Developing and Contributing

I'd love to get contributions from you! Whether you are most comfortable writing HTML, CSS, or Javascript (either Nodejs or Angular), feel free to reach out to me about some of my design goals and we'll see where your efforts can best be used.

License

See LICENSE.md file.

Support

Create an issue in github or start a post on the MineOS support forums.

CURRENTLY WORKING

The Angular.JS-based web user interface capable of:

  • creating and deleting servers,
  • starting, restarting, killing and stopping servers
  • backup, archive, wait-for-stop-and-backup
  • reading ingame console in real-time and submitting commands
  • create cronjobs for the most common tasks
  • adding and modifying server.properties
  • delete previous archives and restore poitns to free up space
  • restore server from previous restore point
  • see filesystem usage of live server files, archives, and restore points
  • authentication via shadow passwords (/etc/shadow) of underlying Linux system
  • logs all user actions to file
  • cronjobs saved to portable format cron.config
  • server can be daemonized to background
  • upstart/supervisord restart process on unhandled exceptions
  • easy selection of server packs from FTB or Mojang official jars
  • PHAR support for Pocketmine servers
  • Support for BungeeCord servers
  • command-line interface for scripting

TODO

  • macro often-repeated tasks from web-ui
  • more fully document functions

EVENTUALLY

  • implement previous_versions: functionality to roll back or view particular files' previous state
  • identify java versions in web-ui, allow choice of utilized jvm

mineos-node's People

Contributors

4o66 avatar alexdicy avatar aliquid avatar beepbeepmeepdeep avatar bottmint avatar brandonmcclure avatar budulinek avatar cross avatar dependabot[bot] avatar dreamwraith avatar eggallocationservice avatar flareofghast avatar hexparrot avatar imelsom avatar itomten avatar jsegaert avatar kayoticsully avatar kz5ee avatar leeo97one avatar mjeries avatar mrbretze avatar saumdev avatar scebbers avatar siliconheart avatar snyk-community avatar thesymbol avatar tucks avatar wchill avatar zebaker98 avatar zsub avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mineos-node's Issues

webui doesn't connect to nsp if server name matches previously deleted one

If a server is created, then deleted, then created again with the exact same name, the webui does not reconnect to the namespace and does not receive updates from the io room.

This is because nsp.on('connection') doesn't trigger from the recreation of the server as setup() would expect. The socket is maintained, regardless of whether this server exists (because the / room is still subscribed to).

Perhaps the socket factory needs to disconnect from the unused (because it was deleted) room?

[WEBUI] Received emit command { command: 'create', server_name: 'qqq', properties: {} }
Discovered server: qqq
[qqq] Create tail on logs/latest.log failed
[qqq] Watching for file generation: logs/latest.log
[qqq] Started watch on server.properties
[qqq] Started watch on server.config
[qqq] 129.219.115.215 connected to namespace
[qqq] broadcasting 0 previous notices
[qqq] 129.219.115.215 requesting server at a glance info
[qqq] 129.219.115.215 requesting cron info
[qqq] Server created in filesystem.
[qqq] 129.219.115.215 issued command : "delete"
[qqq] received request "delete"
server_fin { command: 'delete',
  uuid: '6e658ba0-f7fe-11e4-a7b5-c32bf085f380',
  time_initiated: 1431363287386,
  success: true,
  err: undefined,
  time_resolved: 1431363287399 }
Server removed: qqq
[qqq] 129.219.115.215 requesting server at a glance info
[qqq] Heartbeats ceased.
[WEBUI] Received emit command { command: 'create', server_name: 'qqq', properties: {} }
Discovered server: qqq
[qqq] Create tail on logs/latest.log failed
[qqq] Watching for file generation: logs/latest.log
[qqq] Started watch on server.properties
[qqq] Started watch on server.config
[qqq] 129.219.115.215 requesting server at a glance info
[qqq] 129.219.115.215 requesting cron info
[qqq] Server created in filesystem.

Server failed to start, EULA didn't pop up

So, I was just testing the first profile not showing up issue (I deleted /var/games/minecraft) restarted the service, downloaded the 1.8.7 profile, created the test server waited like 30 seconds and it still didn't show. I restarted the mineos service, refreshed the webui page and relogged in. The server was listed, I then clicked on it and picked the profile, change runnable jar to, 1000 1000 for xms xmx. Clicked start - up came your pop up which prompted me to pick the profile, runnable jar and xmx xms, which had maintained my settings so no need to do anything, click OK or whatever and then the server failed to start.
No EULA pop up.
Click the stop button arrow, select accept eula and click start and failed. Nothing helpful about why it failed in the log or webui console when started sudo node webui.js.

info: [test] received request "start"
error: [test] command "start" errored out: command=start, uuid=dbf71a80-1dec-11e5-8d0a-2dcc1a1a01ba, time_initiated=1435533884456, success=false, err=1, time_resolved=1435533884616

also saw

sudo node webui.js 
MineOS webui listening on *:8443
info: [test] Discovered server
error: [test] Create tail on logs/latest.log failed
info: [test] Watching for file generation: logs/latest.log
error: [test] Create tail on server.log failed
info: [test] Watching for file generation: server.log

Webui not working on FreeNAS 9.3

The webgui is not applying the cron tasks to the crontab on FreeBSD
crontab -e returns an empty crontab, while the cron.config in the server folder does contain the information for the cron task.

new server doesn't show up in webui after creation

I run

sudo node webui.js

It seems to create the server fine according to the console output but it doesn't show up in the webui.
Is this because it was created for my user and not root or something? so I would have to re-run but using

node webui.js

in order to see and run the new server? refreshing the page doesn't make it appear either.
I re-ran using the sudo command and it now shows up.

FTB - at least infinity

With the FTB packs, to truely make it "idiot proof" we'd need

if (exists install.sh){
  read $JARFILE from install.sh
  download (or link to) $JARFILE (as ./minecraft_server.${MCVER}.jar)
  download (or link to) $LAUNCHWRAPPER (as libraries/${LAUNCHWRAPPER})
}

I hope you can figure out for yourself what that all means ๐Ÿ˜„

Java version information

I just realised I did this in bash for something else I am working on, maybe it would be of benefit to you.

/usr/libexec/java_home -V 2>&1 | grep 86 | awk -F ":" '{print $1}' > java
# pattern="([0-9] [0-9])"
sed -i -e 's/[ \t]*//' java
IFS=$'\n' read -d '' -r -a newJava < java
rm java


OIFS="$IFS"
IFS=([0-9] [0-9])
newJAVA=""
while [[ $newJAVA = "" ]]; do
        echo "Select your Java version for this instance"
        select newJAVA in ${newJava[@]}; do
                if [[ $newJAVA = "" ]]; then
                        echo "Please enter a valid option. Retry."
                else {
                        export JAVA_HOME=`/usr/libexec/java_home -v $newJAVA` 
                        echo $JAVA_HOME
                        echo `java -version`
                }
                fi
                break
                done
        done
IFS="$OIFS"
# exit 0

It only applies for the current session/terminal unless you run it as "source script.sh"
Hope it helps.

Hidden Passwords - Bug & Feature Request

Hi,

First off, clicking the "Hide password" option appears to have no effect for me.

Second,
I have read the "Stop Password Masking" document, and I humbly offer that it does not apply to this use-case.

I use a password manager, and never have to actually type in my password. Having the password masked prevents casual observers (like my children) from getting my password.

I would like to request a configuration setting which allows the operator to decide whether or not password masking is default-enabled. While I understand that password-masking makes some UI's more difficult to use, there are many cases where it really does enhance security, and I think server owners should be given the option to decide.

latest.log

How often is the latest.log checked for updates? When I last looked at it, it was 20mins behind. I was trying to get some info on why my server wasn't starting. Then the next time I went to it it was all up to date.

Server broadcast across LAN doesn't work with multiple IPs

I have multiple servers running on one machine, but each server is bound to its own IP with the default port. (For background, I used hostnames to make this girlfriend-friendly, she and I found those easier to remember than ports.) Now I'm trying to bring it to the next level with MineOS and I noticed it has a broadcast-function which is really cool.

However, it doesn't work. That is to say, it works for one server because all my servers share the same port. Furthermore, even if I change the ports to non-default, but also bind the servers to different IPs, only one server (the one bound to the same IP as the broadcaster is using) will actually work (even though all three show up in the client).

I can work around this by giving all servers the same IP, but I was wondering if there might be a more robust solution to this, for example by binding the broadcaster socket to other IPs such as may exist in the server.properties for all servers.

Connection Refused - Supervisor Uptime = 12 seconds before restart.

Hello,

I have recently install MineOS-Node from the Turnkey ISO you made available. I was having some issues with the dashboard where socket.io was not communicating successfully. I decided to update the webui files via git and have since been unable to connect to the server. I receive a connection refused message.

image

When it does accept the main html request, subsequent requests are refused.
errors

Supervisor shows it restarting every 12 seconds, I have attempted to view the logs but nothing of significance is apparent. Is the Master branch currently stable?

image

dgram branch

An issue with your dgram branch is that you haven't followed the format for the broadcast message.

it MUST be

"[MOTD]" + servers[i][0] + "[/MOTD][AD]" + servers[i][1] + "[/AD]"

where servers[i][0] is the servers MOTD and servers[i][1] is the servers port.

I tried implementing myself but I couldn't get the value back for server-port or motd, I'm still a noob. If I manage to get it before you come back online you'll see a pull request.

Load Averages maximum limited to 1.0

Multicore machines frequently go over a load-average of 1.0. The Graph in mineos-node is fixed at a max value of 1.0 in the y-axis. It should auto-adjust, either to the number of cores, or to the most recent max-value.

Environment variables for startup scripts

Currently the upstart startup script uses an absolute path for the MineOS home directory (/usr/games/minecraft). If the user does not want to use this directory, he must edit the startup script.

I would like this to be replaced with an environment variable. If the job fails to start because of an invalid path, the error message should inform the user.

multiple jar arguments makes server start fail

Apparent bug in webui-node
after creating a server when placing additional java arguments, it appears that if you have multiple arguments there that the server will not start. each individual argument works but when placed in a series of 2 or more arguments eg: -XX:+UseLargePages -XX:+AggressiveOpts , it fails to start and also give no feedback that it failed it just sits there doing nothing.

i first found this with an FTB pack but have tested it with a vanila server too.

--Original post by koyetsu

WebUI Crashes when logging in with FreeBSD 9 as a host

I have tried to install MineOS-node on a FreeBSD box in a jail and everything starts up fine and I can access the WebUI login page via https with the ssh keys generated by the script.
But when I enter the correct details the server silently crashes, i do get redirected but during this time the server silently crashes and i get no output in the console either.

Just to add more info when I enter the wrong credentials I get thrown back to the login page no problem there, the server stays up and dosent crash.

I am running a FreeBSD 9 system, I do not know if it is happening on a FreeBSD 10 system but I would suspect it still crashes.

Is there any extra packages i need to install other than the ones that are required for a debian system?

new installation - created server, started, played a little, tried to create second server - not in webui

As the title suggests I have created one server, played it a bit and then come back to the UI to create a new server.

first server is theBoys second is boysCreative.

{"level":"info","message":"[theBoys] Created tail on logs/latest.log","timestamp":"2015-08-22T06:10:16.022Z"}
{"command":"create","server_name":"boysCreative","properties":{"level-name":"creative","level-seed":"lblkvbhl23hrflj23h;iydED@","difficulty":"2","gamemode":"1","generate-structures":true},"level":"info","message":"[WEBUI] Received emit command from 192.168.1.176:peter","timestamp":"2015-08-22T06:30:04.660Z"}
{"level":"info","message":"[boysCreative] Server created in filesystem.","timestamp":"2015-08-22T06:30:04.675Z"}
{"level":"info","message":"[boysCreative] Discovered server","timestamp":"2015-08-22T06:30:05.078Z"}

It's now been several minutes and still not displaying in the UI.

Authentication system with express/socketio

Authentication is probably the biggest hurdle before being able to form a release candidate which admins could put to the test as a development/testing environment.

I understand that the codebase I have created is fairly large and may not be immediately familiar, so the help I'm asking for does not need to--in any way--include, fork, or remotely relate to this git.

I'm hoping to get a working example of Express 4.x + socketio 1.3 that can authenticate a hard-coded user (no need to worry about Linux shadow passwords). Even 'admin:password' would work wonderfully.

Whether you use passport (+passport-local, passport.socketio, etc) or not, any piece of code that can accomplish the following task will greatly push forward the status of this project: I must be able to access the user "admin" (or whatever username) from the socket object.

The socket object--through middleware--should be able to be modified to contain this (this is the goal of passport.socketio). Again, this code can be 100% without MineOS code or html. Anything that can get the socket object to provide the authenticated username will be the answer to the entire authentication issue and I can adapt it to make it work with the webui.

Server profile not detected after download

Just built up a new server on Ubuntu 14.04.2 and downloaded 1.8.7, created a new server which worked fine and was detected but now it's not picking up the profile.
Restart Mineos service worked.

Install on minimal Centos 7 - can't start mineos service

I have written a guide for a clean minimal install of Centos 7.

The automated install of nodejs uses node as the binary name and not nodejs, changing the mineos.service (systemd.conf) command to use node instead of nodejs solved the issue.

Server that does not create

I'm creating a server under test name and nothing happens, the server does not start and when I deconect reconect me and no server n has been create (I use ubuntu 14.04)

Imports aren't working

Running Ubuntu server 14.04 -2 with the latest git updates. When I go to import an archive it appears to work but never shows the server properties populate or allow me to choose which jar to run. If I restart the process or reload the panel the server import completely disappears. All of the files successfully extract into the server folder but the server won't show in the panel.

repeated tasks not working

im running mineos on freenas.
i want to run a restore point every 45 minutes between 11am and 2am
so my cronjob looks like: */45 11-2 * * *
it runs at 11am but not every 45 minutes after that.

my backup task works flawless ( 0 */2 * * *) it backs up every 2 hour.

it just looks like the same formula doesn't work for minutes . is this a bug

webui silently crashes if server directory owned by bad UID/GID

The webui crashes if a server directory within base_dir is owned by a UID/GID that does not exist on the system:

drwxr-xr-x 2 1001 1001 4096 May 6 14:12 testing

This problem can be reproduced by running sudo nodeunit test/test-mineos.js; the tests will continue until test.chown() at which point if the user that is hardcoded into the test suite does not exist, nodeunit will silently crash.

This is the only test that utilizes (and hardcodes) a UID/GID other than 0, so it should probably check for a valid non-root user before continuing or skip the test automatically.

Subsequent attempts to use the web-ui will also fail when it tries to check the server owner and the web-ui silently crashes to the terminal as well. Deleting the errant server will restore all operation to normal, as will creating user/group 1001.

Cron issues

If you enter an invalid cron expression on a server and try to start it, the mineos-node process gets killed without any error message (even with -D).
Some check for validating the cron expression would be a good solution.
And another minor thing about the cron interface is that you have to manually refresh your browser, since the page do not auto-update when you click submit/start/etc.

Suggestion for server profiles

I'm not sure what you desire to do with the profile page but I think that the page would look better if perhaps the available downloads are in a dropdown list and the installed profiles are in a list on the page. Each type of server in it's own DDL e.g. Vanilla, FTB etc. If there was a method to check if the vanilla server jar is already downloaded and copy or symlink in to the new directory instead of downloading.

Spigot Profile

Hello Everyone,
It would be extremely cool if we could have a spigot profile. I know spigot doesn't release official downloads, but have you had a look at http://getspigot.org/spigot/? It seems cool, and I would appreciate if this was added in at the earliest connivence.

Thank you, and have a good day!

Custom profile

Option to create a custom profile (same of mineos py)

Incompatible with nodejs 4.0.0

This probably isn't news, but figured I would report it as a bit of a PSA. I just upgraded to node v4 by accident in my routine pacman -Syu. For other reasons I need to reinstall MineOS so I re-cloned the repo and my npm install blew up.

This isn't really an issue with MineOS exactly but I'm guessing many of its dependencies are not compatible with Node v4.0.0 yet. I'm also guessing that this should resolve its self as Node v4 was just released today or so.

I reverted back a version and everything works fine. I think mostly time will fix this. But until the dependencies get fixed I'm not sure how to check if MineOS will be compatible either.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.