• 0

    posted a message on [Multi World] Minecraft Server Control Script
    Quote from sandain »
    I think I found and fixed the problem. Since the script runs as a daemon, it needs to know a little bit about the user environment to send messages to it: the user name and display. I added these variables to the top of the script so that you can easily change them to match your system.

    Let me know if this works for you. It worked for me on one of my two test systems (the other one is misconfigured I think).

    I hard-coded my username into that setting and it works! Will confirm later if the display part was the larger issue by seeing if the "minecraft" user will also let it display...

    Thanks again!
    Posted in: Server Support and Administration
  • 0

    posted a message on [Multi World] Minecraft Server Control Script
    Quote from deMangler »
    I get the libnotify popups fine. I am using xfce under slackware 13.1.

    On occasion libnotify will crash. This is unrelated to this script I think - but it may be why you are not getting popups.
    dM

    Hmm. That's interesting. I'm also running xfce (xubuntu, but I compiled 4.8 recently), and I get popups from other apps consistently (sometimes during the time I should be getting them from the server log). I can't think of a time I've missed a popup from another program, and I definitely haven't ever gotten one from the server, so I don't think that's the issue. I guess it's helpful to know it's something on my system, though. I'll try to dig further....
    Posted in: Server Support and Administration
  • 0

    posted a message on [Multi World] Minecraft Server Control Script
    I'm using the Feb 1st update, and it has the MOTD part in it for sure.

    You can check ~/.cache/notify-osd.log for testing without needing to actually see if the popup fires (hopefully saving you a trip?). Please don't hassle yourself to fix this...it's totally non-critical.

    I tried to think of a way to debug this myself, but couldn't come up with anything productive.
    Posted in: Server Support and Administration
  • 0

    posted a message on [Multi World] Minecraft Server Control Script
    Is anyone successfully using the libnotify switch? I've got it set to 1 but haven't seen any popups, and there's nothing in the notify-osd log....

    The logged in users are getting written to the .users files, so the parsing isn't the problem. Is anyone else having an issue?
    Posted in: Server Support and Administration
  • 0

    posted a message on [Multi World] Minecraft Server Control Script
    Played with multiple worlds today and ran into a fringe use-case that I wasn't sure how to handle. Is there a way to comment out worlds in the worlds.conf file? It didn't appear that there was....
    Posted in: Server Support and Administration
  • 0

    posted a message on [Multi World] Minecraft Server Control Script
    Quote from sandain »
    You can do pretty much anything you want to do in Dash without resorting to using a Bash specific extension with very little effort as I've so far found.

    According to this, the replacement for my simple Bash substring operation is to use sed or awk, which I couldn't make work for the life of me the first time around. I will bow out and just wait to see what you come up with....

    Congrats on the minecart station!
    Posted in: Server Support and Administration
  • 0

    posted a message on [Multi World] Minecraft Server Control Script
    Strike that about the chats. Potentially better idea:

    1. Parse log for "<*>" lines, strip timestamp, write to chat.log file as they come in
    2. Follow chat.log and grep -v yourself (hardcoded variable in script? read from admin file?)
    3. libnotify the lines that are left

    No need to follow log in/out, and seems like much simpler logic to structure. What do you think?
    Posted in: Server Support and Administration
  • 0

    posted a message on [Multi World] Minecraft Server Control Script
    I don't know why I didn't think of this sooner:
    ## Line 387
          # Show the status of each world requested.
          for WORLD in $WORLDS; do
             printf "  $WORLD > status: "
             if [ $(serverRunning $WORLD) = 1 ]; then
                printf "running.\n"
                sendCommand $WORLD "list"
                printf "  $WORLD > connected players: "
                PLAYERLIST=`eval tail -n1 $WORLDS_LOCATION/$WORLD/server.log | grep --line-buffered "players:"`
                if [ ${#PLAYERLIST} == "46" ]; then
                  printf "none\n"
                else
                  printf "${PLAYERLIST:46}\n"
                fi
             else
                printf "not running.\n"
             fi
          done

    Instead of writing the log in/out states to a file, you can just send the list command and immediately tail the log for the connected players. (This will report "none" if something else is concurrently logged and the last line isn't the connected players list. Not sure how likely this is. Tried implementing a check for zero length on $PLAYERLIST and running the list/tail again if it was, but didn't want to structure that into a loop, so just pulled the check out....)

    One benefit from doing it the way you wanted (current list of logged in players in a separate file), though, is that having that info handy would make listening for chats in the log easier (grep "<$1>|<$2>|..." -> though I'm not sure how best to structure that code on account of ther ebeing a variable number of usernames).... But it sounds a lot more complicated.

    The above works great on my end, but I had to change your script to execute as BASH instead of just SH in line 1. Apparently SH doesn't support the substring syntax and I couldn't find a reference anywhere for relevant operations. No noticeable impact elsewhere for the change, but I'm a little wary. Did you use SH for any explicit reasons?

    Also, this means I can probably put the libnotify stuff from before in the script proper (inelegant though it is), since the trim function was the likely cause of the errors there, too. Will have to roll up my sleeves and more properly parse the log to keep notifications down....

    As ever: thank you and you rock.
    Posted in: Server Support and Administration
  • 0

    posted a message on [Multi World] Minecraft Server Control Script
    Ran into a new bug today. I ran "update" through your script, but something failed silently. Server said it restarted (I think.... If there was an error, it didn't stick out), so I left it alone. Tried to log in a few hours later and nothing was connecting.

    Turns out the server.jar was 0b. Ran "update" again and it actually pulled the new file and now everything is great again.

    Two things, then:

    * Update routine should check for http errors and/or make sure the server software isn't 0 bytes. If an error like that occurs, print a message and don't attempt to restart the server (maybe?).

    * Server "start" routine could either have a quick error case for problems with the file itself and then try to update it (like on first run, but for errors like this), or at least print a message. With my 0 byte server.jar it would just say "starting the server" and then nothing else would happen. It wasn't too hard to find the problem, so this isn't a big deal, but it occurred to me that calling out the file as the problem would be somewhat helpful (though maybe not worth the extra weight in the code?), and that in doing so, the redownload could actually be cleverly automated....
    Posted in: Server Support and Administration
  • 0

    posted a message on [Multi World] Minecraft Server Control Script
    Your recent changes are all really wonderful. Great work.

    I like the new send command, too. Coupled with the new "list" server command, there's some potentially really useful information to be had here. From what I can tell, though, the server only outputs the connected players to the log, so log parsing is still needed to really make sense of the info.

    I added a quick couple lines to the "status" case in your script since I've got my hacky log notifications anyway, so I can see the results of the list at least. Doesn't seem to be an elegant way to pull this off for real, though. You'd have to parse the log completely and have a test case for when no one is connected (the console just returns nothing rather than a message about no one being connected), and then do heavy lifting on the log to output the names into the terminal into a list of their own where the "status" command was likely run. So close, and yet....
    Posted in: Server Support and Administration
  • 0

    posted a message on [Multi World] Minecraft Server Control Script
    I had to register to say thank you for this excellent script. I was really excited to find it and have been really enjoying using it.

    I have a few quick bits of feedback:

    * The date_time variable is slightly wrong. You've used a capital M for minutes in the date string where you should have a small m for month:

    line 188:
    - DATE_TIME=$(date +%Y-%M-%d-%H:%M:%S)
    + DATE_TIME=$(date +%Y-%m-%d-%H:%M:%S)

    Obviously this isn't critical, but is an easy enough fix to be worthwhile.

    * The map function fails silently if the required folders don't already exist. The "maps" folder is made, but if the underlying "WORLDNAME" folders aren't already there, nothing happens. I manually made the folders and it's fine now; not sure if this is a quirk on my system or an oversight....

    * Would you consider adding a function to the backup routine that purges existing backups that are x days old, or only keeping the most recent x number of backups? I know this is a really non-trivial change, but would be super convenient....

    Also, I wrote a quick and dirty command that uses Ubuntu's native notification system to alert me when players log in or send messages (my server is just for myself and two RL friends, so it's not overwhelming to plug into all this activity and there's utility in knowing when my friends sign in). I'd love to be able to incorporate this into your service so it starts (and stops) with the server itself, but I've had no luck at all. I apologize that this is more of a vanity request, but it's possible someone else might find it useful (and I banged my head against getting it work for entirely too long):

    tail -n0 -f $WORLDS_LOCATION/$1/server.log | grep --line-buffered -v "<my_username>" | while read line; do notify-send "Minecraft Server:" "${line:20}" -i $LOCATION/osd-icon.png; done

    You will instantly see how this works because you are a genius, but for anyone (like me) following along at home, I'll explain what happens there:

    "tail -f" follows the server log, which gets you easy access to login/logout and all chat console messages
    "grep -v "<username>"" will filter out lines from the log that you type into the chat console (becomes overwhelming without this and the messages are not important to see in the notification area)
    "while read line" simple loop to send the notification for each line as it comes in
    "notify-send" is the Ubuntu notification bubbles (see here for details)
    "${line:20}" this just trims the line in question of the first 20 characters to remove the timestamps when popping up the notification. Fancier sed regexps could net you more or less information, but this works well for me.
    "osd-icon.png" is whatever you want the icon to be inside the bubble. I used the 32px one from here and it's an excellent fit.

    Curiously, this works when pasted into the terminal directly (with hardcoded values for the paths, natch), but fails when called as a bash script. Apparently I am full of fail.

    I'm sure this isn't useful widely enough to warrant inclusion in your script, but if you could provide some guidance on how to hack it in, I'd be super grateful.... I've tried a number of ways, but each of them broke the service.

    Anyway, thanks so much for posting this in the first place. I'm really surprised there aren't more comments here; you did a great job.
    Posted in: Server Support and Administration
  • To post a comment, please or register a new account.