Last active
November 20, 2016 01:13
-
-
Save cnaude/aba38e9e04d2482f8b6560ca07f38cb7 to your computer and use it in GitHub Desktop.
minecraft irc announcer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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