msmhq / msm

An init script for managing Minecraft servers
http://msmhq.com
GNU General Public License v3.0
1.22k stars 225 forks source link

msm-server-ports #341

Open ksmathers opened 8 years ago

ksmathers commented 8 years ago

I find that I'm frequently adding and removing servers and need a way of figuring out which server ports are available and which are in use, so this is an enhancement request. Something like the following would be useful: cd /opt/msm/servers && find . -name server.properties | xargs grep server-port | perl -nle 'printf( "%-5s %s\n",$2,$1) if /\/(\w+)\/.*port=(\d+)/' | sort -n

morbeo commented 8 years ago

@ksmathers the provided command will output a list of the server ports without information for which server they are. Similarly the msm command msm all config server-port will show only the port numbers without information about the server. Please provide an example of the expected output i.e.

vanilla server-port 25565 bukkit server-port 25567

or however you like it to look like.

Sidenote: such excessive piping is unnecessary imo. I would use something in the vein of

find /opt/msm/servers/ -name server.properties \
-exec awk -F= '/server-port/ {printf "%-5s %s\n",$2,$1}' {} \;

One command and one subcommand.

M-D-M commented 7 years ago

Awk has a built-in FILENAME variable that could help get the path of the config file -- this could be fun to build into msm.