2020-12-29 12:17:11 +01:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
# ×===================================×
|
|
|
|
|
# | bukkit-console by Elias Schriefer |
|
|
|
|
|
# ×===================================×
|
|
|
|
|
|
2022-01-02 18:51:34 +01:00
|
|
|
|
server=""
|
|
|
|
|
|
2020-12-29 12:17:11 +01:00
|
|
|
|
if [ "$1" = "-h" ]
|
|
|
|
|
then
|
|
|
|
|
echo "bukkit-console [option]"
|
|
|
|
|
echo
|
|
|
|
|
echo "Options:"
|
|
|
|
|
echo " -h Show help"
|
|
|
|
|
echo " -f Get screen even if it is"
|
|
|
|
|
echo " already attached"
|
|
|
|
|
echo " -ff Same as -f but detach it first"
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Get the bukkit server status: is it running or stopped?
|
|
|
|
|
# We don't need echo, but thx anyways...
|
2022-01-02 18:51:34 +01:00
|
|
|
|
$server-status > /dev/null
|
2020-12-29 12:17:11 +01:00
|
|
|
|
if [ $? -gt 0 ]
|
|
|
|
|
then
|
|
|
|
|
# If the server is stopped, fukcing start it, man!
|
2022-01-02 18:51:34 +01:00
|
|
|
|
$server-start
|
2020-12-29 12:17:11 +01:00
|
|
|
|
fi
|
|
|
|
|
if [ "$1" = "-f" ]
|
|
|
|
|
then
|
|
|
|
|
# Gimme the console
|
2022-01-02 18:51:34 +01:00
|
|
|
|
sudo screen -xr $server
|
2020-12-29 12:17:11 +01:00
|
|
|
|
# Now gimme my suxesvul eksid koud...
|
|
|
|
|
true
|
|
|
|
|
elif [ "$1" = "-ff" ]
|
|
|
|
|
then
|
|
|
|
|
# Hand me the console over
|
2022-01-02 18:51:34 +01:00
|
|
|
|
sudo screen -dr $server
|
2020-12-29 12:17:11 +01:00
|
|
|
|
# Now gimme my suxesvul eksid koud...
|
|
|
|
|
true
|
|
|
|
|
else
|
|
|
|
|
# Gimme the console, plz...
|
2022-01-02 18:51:34 +01:00
|
|
|
|
sudo screen -rq $server
|
2020-12-29 12:17:11 +01:00
|
|
|
|
if [ $? -gt 0 ]
|
|
|
|
|
then
|
|
|
|
|
# If the console is attached elsewhere, say it
|
|
|
|
|
echo Console is already in use
|
|
|
|
|
# Now gimme my suxesvul eksit koud...
|
|
|
|
|
false
|
|
|
|
|
else
|
|
|
|
|
# or my unsuxesvul eksid koud...
|
|
|
|
|
true
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
# and eksid wif that eksid koud
|
|
|
|
|
exit $?
|