knowndead
knowndead

Reputation: 80

Using screen to startup a minecraft server(linux debian)

I tried alot of things and got alot of errors, what i try to do is open a screen session on startup, start a minecraft server in it and then detach it so i can SSH to it with screen -r.

The first command works fine, the problem is after the first command is executed i must press spacebar twice before i can actually use the code to start the server i tried that with xdotool without succes i got the error(over SSH) when typing xdotool key SpaceBar

Error: Can't open display: (null)
Failed creating new xdo instance

The fix is supposed to be export DISPLAY=:0.0 which doesn't work for me.

my current startup script is.

#!/bin/bash
# /etc/init.d/mcstartup.script
# version 0.3.9 2012-08-13 (YYYY-MM-DD)

### BEGIN INIT INFO
# Provides:   minecraft
# Required-Start: $local_fs $remote_fs
# Required-Stop:  $local_fs $remote_fs
# Should-Start:   $network
# Should-Stop:    $network
# Default-Start:  2 3 4 5
# Default-Stop:   0 1 6
# Short-Description:    Minecraft server
# Description:    Starts the minecraft server
### END INIT INFO
sleep 20
echo "5"
sleep 1
echo "4"
sleep 1
echo "3"
sleep 1
echo "2"
sleep 1
echo "1"
sleep 1
echo "0"
sleep 1
screen
sleep 5
xdotool keydown SpaceBar
sleep 3
xdotool keydown SpaceBar
sleep 5
xdotool type ’Hello world!’
sleep 5
sudo /opt/jdk1.8.0/bin/java -Xms256M -Xmx496M -jar /home/pi/craftbukkit.jar nogui
xdotool keydown Control_L+A
xdotool keydown D

There are alot of unneeded echo's in it, and alot of unneeded sleep commands, mainly for testing purpose.

If someone knows how to fix either xdotool to work the right way or another way to start a mc server on startup on another session(my raspberry pi doesn't have a keyboard attached) that would really be helpful.

Upvotes: 0

Views: 750

Answers (1)

funivan
funivan

Reputation: 3433

Try export display

export DISPLAY=:0.0

Then you will be able to run xdotool commands

Upvotes: 1

Related Questions