[NF] Creating with screen Session
This commit is contained in:
parent
dc418934e2
commit
2f46fd8d9d
@ -81,6 +81,33 @@
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="control\control.sh">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="control\join.sh">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="control\loop.sh">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="control\restart.sh">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="control\settings.cfg">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="control\start.sh">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="control\stop.sh">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="control\stuff.sh">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="control\view.sh">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Resources\Icon.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
92
Hue-Bot/bin/Release/control/control.sh
Normal file
92
Hue-Bot/bin/Release/control/control.sh
Normal file
@ -0,0 +1,92 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Read Settings
|
||||
DIR=`dirname $0`
|
||||
source $DIR/settings.cfg
|
||||
cd $control_root
|
||||
|
||||
|
||||
for(( ; ; ))
|
||||
do
|
||||
# Test for Running Servers
|
||||
servers=$(./view.sh | grep $screen_name)
|
||||
|
||||
clear
|
||||
|
||||
if [[ -z $servers ]];
|
||||
then
|
||||
echo "Hut-Botr not Running!"
|
||||
echo ""
|
||||
echo "1) Start Hut-Bot"
|
||||
|
||||
else
|
||||
echo "Hut-Bot is Running :)"
|
||||
echo ""
|
||||
echo "2) Stop Hut-Bot"
|
||||
echo "3) Restart Hut-Bot"
|
||||
echo "4) Attach to Servers Screen-Session"
|
||||
echo "5) Put Command to Hut-Bot"
|
||||
fi
|
||||
|
||||
echo "q) Quit"
|
||||
echo ""
|
||||
read -p "Choice: " choice
|
||||
|
||||
case "$choice" in
|
||||
q) #Quit
|
||||
exit 0
|
||||
;;
|
||||
1) #Start Server
|
||||
if [[ -z $servers ]];
|
||||
then
|
||||
echo "Starting Hut-Bot..."
|
||||
./start.sh
|
||||
else
|
||||
echo "Hut-Bot Allready started!"
|
||||
fi
|
||||
;;
|
||||
|
||||
2) #Stop Server
|
||||
if [[ -z $servers ]];
|
||||
then
|
||||
echo "Hut-Bot is not Running!"
|
||||
else
|
||||
echo "Stopping Hut-Bot..."
|
||||
./stop.sh
|
||||
fi
|
||||
;;
|
||||
|
||||
3) #Restart Server
|
||||
if [[ -z $servers ]];
|
||||
then
|
||||
echo "Hut-Bot is not Running!"
|
||||
else
|
||||
echo "Restarting Hut-Bot..."
|
||||
./restart.sh
|
||||
fi
|
||||
;;
|
||||
|
||||
4) #Attach to Screen
|
||||
if [[ -z $servers ]];
|
||||
then
|
||||
echo "Hut-Bot is not Running!"
|
||||
else
|
||||
./join.sh
|
||||
fi
|
||||
;;
|
||||
|
||||
5) #Put Command to Server
|
||||
if [[ -z $servers ]];
|
||||
then
|
||||
echo "Hut-Bot is not Running!"
|
||||
else
|
||||
read -p "Please enter Hut-Bot-Command: " mc_cmd
|
||||
./stuff.sh "$mc_cmd"
|
||||
fi
|
||||
;;
|
||||
|
||||
*) #Invalid Selection
|
||||
echo "Wrong Selection!"
|
||||
;;
|
||||
esac
|
||||
done
|
10
Hue-Bot/bin/Release/control/join.sh
Normal file
10
Hue-Bot/bin/Release/control/join.sh
Normal file
@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Read Settings
|
||||
DIR=`dirname $0`
|
||||
source $DIR/settings.cfg
|
||||
|
||||
echo Press STRG+A then D to detach from Console
|
||||
read -p "Press [Enter] to continue..."
|
||||
|
||||
screen -R $screen_name
|
21
Hue-Bot/bin/Release/control/loop.sh
Normal file
21
Hue-Bot/bin/Release/control/loop.sh
Normal file
@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Read Settings
|
||||
DIR=`dirname $0`
|
||||
source $DIR/settings.cfg
|
||||
|
||||
rm $control_root/stop_server.info
|
||||
|
||||
for(( ; ; ))
|
||||
do
|
||||
if [ ! -e $control_root/stop_server.info ];
|
||||
then
|
||||
cd $mc_root
|
||||
$mc_cmd
|
||||
else
|
||||
echo "Stopped Server!"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
rm $control_root/stop_server.info
|
28
Hue-Bot/bin/Release/control/restart.sh
Normal file
28
Hue-Bot/bin/Release/control/restart.sh
Normal file
@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Read Settings
|
||||
DIR=`dirname $0`
|
||||
source $DIR/settings.cfg
|
||||
cd $control_root
|
||||
|
||||
# Be Shure theere is no Stop-Info
|
||||
rm $control_root/stop_server.info
|
||||
|
||||
echo "Server will be restarted in 5 Seconds..."
|
||||
./stuff.sh "/say ReStarting Server in 5 seconds!"
|
||||
sleep 1
|
||||
echo "4..."
|
||||
./stuff.sh "/say 4..."
|
||||
sleep 1
|
||||
echo "3..."
|
||||
./stuff.sh "/say 3..."
|
||||
sleep 1
|
||||
echo "2..."
|
||||
./stuff.sh "/say 2..."
|
||||
sleep 1
|
||||
echo "1..."
|
||||
./stuff.sh "/say 1..."
|
||||
sleep 1
|
||||
echo "Restarting Server..."
|
||||
./stuff.sh "/say Restart Now!"
|
||||
./stuff.sh "stop"
|
28
Hue-Bot/bin/Release/control/settings.cfg
Normal file
28
Hue-Bot/bin/Release/control/settings.cfg
Normal file
@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
# Minecraft Control-Scripts Config-File
|
||||
|
||||
# (please remember that there are no spaces allowed around the =-Sign
|
||||
# in the config-lines)
|
||||
|
||||
# JAVA-Params
|
||||
CPU_COUNT="1"
|
||||
MAX_MEM="1024M"
|
||||
MIN_MEM="768M"
|
||||
|
||||
# Minecraft-Dir & JAR
|
||||
|
||||
# Directory where minecraft is in
|
||||
mc_root="~/Hue-Bot"
|
||||
|
||||
# Root of Control-Scripts
|
||||
control_root="$mc_root/control"
|
||||
|
||||
|
||||
# MC-Server-Jar (will be executed in mc_root)
|
||||
mc_jar="$mc_root/Hue-Bot.exe"
|
||||
|
||||
# MC-Server Start-Command
|
||||
mc_cmd="mono $mc_jar"
|
||||
|
||||
# Screen
|
||||
screen_name="Hue-Bot"
|
14
Hue-Bot/bin/Release/control/start.sh
Normal file
14
Hue-Bot/bin/Release/control/start.sh
Normal file
@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Read Settings
|
||||
DIR=`dirname $0`
|
||||
source $DIR/settings.cfg
|
||||
|
||||
# Start Loop in Screen
|
||||
screen -A -m -d -S $screen_name $control_root/loop.sh
|
||||
|
||||
# Allow other users to control this screen-Session!
|
||||
screen -r $screen_name -X multiuser on
|
||||
screen -r $screen_name -X addacl www-data
|
||||
screen -r $screen_name -X addacl mc
|
||||
screen -r $screen_name -X addacl mw
|
29
Hue-Bot/bin/Release/control/stop.sh
Normal file
29
Hue-Bot/bin/Release/control/stop.sh
Normal file
@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Read Settings
|
||||
DIR=`dirname $0`
|
||||
source $DIR/settings.cfg
|
||||
cd $control_root
|
||||
|
||||
# Create Stop-Info!
|
||||
touch $control_root/stop_server.info
|
||||
|
||||
echo "Shutting Down Server in 5 Seconds!"
|
||||
./stuff.sh "/say Shutting Down Server in 5 Seconds!"
|
||||
sleep 1
|
||||
echo "4..."
|
||||
./stuff.sh "/say 4..."
|
||||
sleep 1
|
||||
echo "3..."
|
||||
./stuff.sh "/say 3..."
|
||||
sleep 1
|
||||
echo "2..."
|
||||
./stuff.sh "/say 2..."
|
||||
sleep 1
|
||||
echo "1..."
|
||||
./stuff.sh "/say 1..."
|
||||
sleep 1
|
||||
echo "Shuting Down Server..."
|
||||
./stuff.sh "/say Shutdown Now!"
|
||||
./stuff.sh "stop"
|
||||
screen -R $screen_name
|
10
Hue-Bot/bin/Release/control/stuff.sh
Normal file
10
Hue-Bot/bin/Release/control/stuff.sh
Normal file
@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Read Settings
|
||||
DIR=`dirname $0`
|
||||
source $DIR/settings.cfg
|
||||
|
||||
# screen -r $screen_name -X stuff "$1\n"
|
||||
|
||||
screen -p 0 -S $screen_name -X eval "stuff '$1'\015"
|
||||
# as_user "screen -p 0 -S minecraft -X eval 'stuff \"$command\"\015'"
|
3
Hue-Bot/bin/Release/control/view.sh
Normal file
3
Hue-Bot/bin/Release/control/view.sh
Normal file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
screen -ls
|
Binary file not shown.
92
Hue-Bot/control/control.sh
Normal file
92
Hue-Bot/control/control.sh
Normal file
@ -0,0 +1,92 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Read Settings
|
||||
DIR=`dirname $0`
|
||||
source $DIR/settings.cfg
|
||||
cd $control_root
|
||||
|
||||
|
||||
for(( ; ; ))
|
||||
do
|
||||
# Test for Running Servers
|
||||
servers=$(./view.sh | grep $screen_name)
|
||||
|
||||
clear
|
||||
|
||||
if [[ -z $servers ]];
|
||||
then
|
||||
echo "Hut-Botr not Running!"
|
||||
echo ""
|
||||
echo "1) Start Hut-Bot"
|
||||
|
||||
else
|
||||
echo "Hut-Bot is Running :)"
|
||||
echo ""
|
||||
echo "2) Stop Hut-Bot"
|
||||
echo "3) Restart Hut-Bot"
|
||||
echo "4) Attach to Servers Screen-Session"
|
||||
echo "5) Put Command to Hut-Bot"
|
||||
fi
|
||||
|
||||
echo "q) Quit"
|
||||
echo ""
|
||||
read -p "Choice: " choice
|
||||
|
||||
case "$choice" in
|
||||
q) #Quit
|
||||
exit 0
|
||||
;;
|
||||
1) #Start Server
|
||||
if [[ -z $servers ]];
|
||||
then
|
||||
echo "Starting Hut-Bot..."
|
||||
./start.sh
|
||||
else
|
||||
echo "Hut-Bot Allready started!"
|
||||
fi
|
||||
;;
|
||||
|
||||
2) #Stop Server
|
||||
if [[ -z $servers ]];
|
||||
then
|
||||
echo "Hut-Bot is not Running!"
|
||||
else
|
||||
echo "Stopping Hut-Bot..."
|
||||
./stop.sh
|
||||
fi
|
||||
;;
|
||||
|
||||
3) #Restart Server
|
||||
if [[ -z $servers ]];
|
||||
then
|
||||
echo "Hut-Bot is not Running!"
|
||||
else
|
||||
echo "Restarting Hut-Bot..."
|
||||
./restart.sh
|
||||
fi
|
||||
;;
|
||||
|
||||
4) #Attach to Screen
|
||||
if [[ -z $servers ]];
|
||||
then
|
||||
echo "Hut-Bot is not Running!"
|
||||
else
|
||||
./join.sh
|
||||
fi
|
||||
;;
|
||||
|
||||
5) #Put Command to Server
|
||||
if [[ -z $servers ]];
|
||||
then
|
||||
echo "Hut-Bot is not Running!"
|
||||
else
|
||||
read -p "Please enter Hut-Bot-Command: " mc_cmd
|
||||
./stuff.sh "$mc_cmd"
|
||||
fi
|
||||
;;
|
||||
|
||||
*) #Invalid Selection
|
||||
echo "Wrong Selection!"
|
||||
;;
|
||||
esac
|
||||
done
|
10
Hue-Bot/control/join.sh
Normal file
10
Hue-Bot/control/join.sh
Normal file
@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Read Settings
|
||||
DIR=`dirname $0`
|
||||
source $DIR/settings.cfg
|
||||
|
||||
echo Press STRG+A then D to detach from Console
|
||||
read -p "Press [Enter] to continue..."
|
||||
|
||||
screen -R $screen_name
|
21
Hue-Bot/control/loop.sh
Normal file
21
Hue-Bot/control/loop.sh
Normal file
@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Read Settings
|
||||
DIR=`dirname $0`
|
||||
source $DIR/settings.cfg
|
||||
|
||||
rm $control_root/stop_server.info
|
||||
|
||||
for(( ; ; ))
|
||||
do
|
||||
if [ ! -e $control_root/stop_server.info ];
|
||||
then
|
||||
cd $mc_root
|
||||
$mc_cmd
|
||||
else
|
||||
echo "Stopped Server!"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
rm $control_root/stop_server.info
|
28
Hue-Bot/control/restart.sh
Normal file
28
Hue-Bot/control/restart.sh
Normal file
@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Read Settings
|
||||
DIR=`dirname $0`
|
||||
source $DIR/settings.cfg
|
||||
cd $control_root
|
||||
|
||||
# Be Shure theere is no Stop-Info
|
||||
rm $control_root/stop_server.info
|
||||
|
||||
echo "Server will be restarted in 5 Seconds..."
|
||||
./stuff.sh "/say ReStarting Server in 5 seconds!"
|
||||
sleep 1
|
||||
echo "4..."
|
||||
./stuff.sh "/say 4..."
|
||||
sleep 1
|
||||
echo "3..."
|
||||
./stuff.sh "/say 3..."
|
||||
sleep 1
|
||||
echo "2..."
|
||||
./stuff.sh "/say 2..."
|
||||
sleep 1
|
||||
echo "1..."
|
||||
./stuff.sh "/say 1..."
|
||||
sleep 1
|
||||
echo "Restarting Server..."
|
||||
./stuff.sh "/say Restart Now!"
|
||||
./stuff.sh "stop"
|
28
Hue-Bot/control/settings.cfg
Normal file
28
Hue-Bot/control/settings.cfg
Normal file
@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
# Minecraft Control-Scripts Config-File
|
||||
|
||||
# (please remember that there are no spaces allowed around the =-Sign
|
||||
# in the config-lines)
|
||||
|
||||
# JAVA-Params
|
||||
CPU_COUNT="1"
|
||||
MAX_MEM="1024M"
|
||||
MIN_MEM="768M"
|
||||
|
||||
# Minecraft-Dir & JAR
|
||||
|
||||
# Directory where minecraft is in
|
||||
mc_root="~/Hue-Bot"
|
||||
|
||||
# Root of Control-Scripts
|
||||
control_root="$mc_root/control"
|
||||
|
||||
|
||||
# MC-Server-Jar (will be executed in mc_root)
|
||||
mc_jar="$mc_root/Hue-Bot.exe"
|
||||
|
||||
# MC-Server Start-Command
|
||||
mc_cmd="mono $mc_jar"
|
||||
|
||||
# Screen
|
||||
screen_name="Hue-Bot"
|
14
Hue-Bot/control/start.sh
Normal file
14
Hue-Bot/control/start.sh
Normal file
@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Read Settings
|
||||
DIR=`dirname $0`
|
||||
source $DIR/settings.cfg
|
||||
|
||||
# Start Loop in Screen
|
||||
screen -A -m -d -S $screen_name $control_root/loop.sh
|
||||
|
||||
# Allow other users to control this screen-Session!
|
||||
screen -r $screen_name -X multiuser on
|
||||
screen -r $screen_name -X addacl www-data
|
||||
screen -r $screen_name -X addacl mc
|
||||
screen -r $screen_name -X addacl mw
|
29
Hue-Bot/control/stop.sh
Normal file
29
Hue-Bot/control/stop.sh
Normal file
@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Read Settings
|
||||
DIR=`dirname $0`
|
||||
source $DIR/settings.cfg
|
||||
cd $control_root
|
||||
|
||||
# Create Stop-Info!
|
||||
touch $control_root/stop_server.info
|
||||
|
||||
echo "Shutting Down Server in 5 Seconds!"
|
||||
./stuff.sh "/say Shutting Down Server in 5 Seconds!"
|
||||
sleep 1
|
||||
echo "4..."
|
||||
./stuff.sh "/say 4..."
|
||||
sleep 1
|
||||
echo "3..."
|
||||
./stuff.sh "/say 3..."
|
||||
sleep 1
|
||||
echo "2..."
|
||||
./stuff.sh "/say 2..."
|
||||
sleep 1
|
||||
echo "1..."
|
||||
./stuff.sh "/say 1..."
|
||||
sleep 1
|
||||
echo "Shuting Down Server..."
|
||||
./stuff.sh "/say Shutdown Now!"
|
||||
./stuff.sh "stop"
|
||||
screen -R $screen_name
|
10
Hue-Bot/control/stuff.sh
Normal file
10
Hue-Bot/control/stuff.sh
Normal file
@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Read Settings
|
||||
DIR=`dirname $0`
|
||||
source $DIR/settings.cfg
|
||||
|
||||
# screen -r $screen_name -X stuff "$1\n"
|
||||
|
||||
screen -p 0 -S $screen_name -X eval "stuff '$1'\015"
|
||||
# as_user "screen -p 0 -S minecraft -X eval 'stuff \"$command\"\015'"
|
3
Hue-Bot/control/view.sh
Normal file
3
Hue-Bot/control/view.sh
Normal file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
screen -ls
|
Loading…
Reference in New Issue
Block a user