Skip to content

Instantly share code, notes, and snippets.

@cnaude
Last active November 20, 2016 01:13
Show Gist options
  • Save cnaude/aba38e9e04d2482f8b6560ca07f38cb7 to your computer and use it in GitHub Desktop.
Save cnaude/aba38e9e04d2482f8b6560ca07f38cb7 to your computer and use it in GitHub Desktop.
minecraft irc announcer
#!/bin/bash
#
SVRMSG=$1
USERNAME='mc'
BOT='AardMC'
CHANNEL='#minecraft'
SERVICE='AardMC.jar'
SCREEN='mc'
ME=`whoami`
as_user() {
if [ $ME == $USERNAME ] ; then
bash -c "$1"
else
su - $USERNAME -c "$1"
fi
}
mc_msg() {
if ps awwx | grep -v grep | grep -v -i SCREEN | grep $SERVICE > /dev/null
then
if [ "x$SVRMSG" != "x" ]; then
as_user "screen -p 0 -S ${SCREEN} -X eval 'stuff \"irc say ${BOT} ${CHANNEL} ${SVRMSG}\"\015'"
else
echo "Usage: $0 \"IRC message\""
fi
else
echo "Minecraft server is not running..."
fi
}
mc_msg
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment