Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I made a script that runs fine manually, but can't get it to run with the description in How to start a script file on boot?. I have run update-rc.d -f minecraft.start defaults

This is what my /etc/init.d/minecraft.start is like

#!/bin/bash
case "$1" in
  start)
    screen -S minecraft.start /home/phirephoenix/minecraft/bukkitserver/start_server.sh
    echo "Server started on screen minecraft"
    ;;
  stop)
    screen -X -S minecraft.start kill
    echo "Server shutting down"
    ;;
  *)
    echo "Usage: /etc/init.d/minecraft.start {start|stop}"
    exit 1
    ;;

esac

exit 0
~

As the script works, I won't be adding it, since it's the default.

And this is my startup log /var/log/boot.log

Begin: Loading essential drivers ... done.
Begin: Running /scripts/init-premount ... done.
Begin: Mounting root file system ... Begin: Running /scripts/local-top ... done.
Begin: Running /scripts/local-premount ... done.
Begin: Running /scripts/local-bottom ... done.
done.
Begin: Running /scripts/init-bottom ... done.
fsck from util-linux 2.20.1
/dev/sda1: clean, 66452/4325376 files, 1205648/17301248 blocks
 * Starting configure network device [ OK ]
 * Starting Mount network filesystems [ OK ]
 * Starting Failsafe Boot Delay [ OK ]
 * Stopping Mount network filesystems [ OK ]
 * Starting Bridge socket events into upstart [ OK ]
 * Starting SMB/CIFS File Server [ OK ]
 * Starting configure network device [ OK ]
 * Stopping OpenSSH server [ OK ]
 * Starting OpenSSH server [ OK ]
 * Starting NetBIOS name server [ OK ]
 * Starting Mount network filesystems [ OK ]
 * Stopping Failsafe Boot Delay [ OK ]
 * Starting configure network device [ OK ]
 * Starting System V initialisation compatibility [ OK ]
 * Stopping Mount network filesystems [ OK ]
 * Starting SMB/CIFS File and Active Directory Server [ OK ]
 * Stopping cold plug devices [ OK ]
 * Stopping log initial device creation [ OK ]
 * Starting enable remaining boot-time encrypted block devices [ OK ]
 * Starting configure network device security [ OK ]
 * Starting configure virtual network devices [ OK ]
 * Stopping configure virtual network devices [ OK ]
 * Starting save udev log and update rules [ OK ]
 * Stopping save udev log and update rules [ OK ]
Skipping profile in /etc/apparmor.d/disable: usr.sbin.rsyslogd
 * Starting AppArmor profiles [ OK ]
 * Stopping System V initialisation compatibility [ OK ]
 * Starting System V runlevel compatibility [ OK ]
 * Starting ACPI daemon [ OK ]
 * Starting save kernel messages [ OK ]
 * Starting automatic crash report generation [ OK ]
 * Starting regular background program processing daemon [ OK ]
 * Starting deferred execution scheduler [ OK ]
 * Stopping save kernel messages [ OK ]
 * Starting CPU interrupts balancing daemon [ OK ]
 * Starting crash report submission daemon [ OK ]
 * Starting domain name service... bind9 [ OK ]

**<BIG BLANK AREA RIGHT HERE, DON'T GET IT>**

**[screen is terminating]**
**Server started on screen minecraft**
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
 * Starting web server apache2 [ OK ]
 * Stopping System V runlevel compatibility [ OK ]

It does execute the echo inside start, but it also says screen is terminating.

What is causing this problem here? I run Ubuntu Server, it seems screen is installed and working.

So new approach, using the upstart feature (or what I should call it). I kind of understood the runtimelevel things after some short googeling, and it should now start on one of the four runtimelevels i have set, or stop, on halt/reboot etc.

made /etc/init/bukkit.conf much like the one warlock made. All the # are added for commenting here, and are not on the actual script.

description     "Bukktiserver"
author          "jthanto@fixedyour.net"

start on runlevel [2345]
stop on runlevel [016]

pre-start script
    echo " * Bukkitserver started"
    # I don't know if this does anything at all
end script

    exec sudo /home/phirephoenix/minecraft/bukkitserver/start_server.sh
    # Had to sudo, or else it would get permission denied. Any ideas?

Now I can start the server with typing sudo start bukkit, but it still does not run automaticly. bukkit is in my initctl list with bukkit stop/waiting (For everyone wondering bukkit is a minecraft server software.)

So. I use a .conf to make it a upstart service, want the script to run without me having to do anything (automaticly before any logon). Is there a problem with the actuall jarfile to be run is in my homefolder? I can't really remember if my homefolder is encrypted or not, but it might be. Could this be a problem? Will I have to use symlinks or something (if symlinks are almost like shortcuts, but they are not?)

What am I missing here?

Ps: I has also removed the screen startup thingy, with update-rc.d remove.

The solution I ended up using

I should not have relied on stuff in your encrypted homefolder for startup tasks, as this get mounted on logon.

I ended up using the upstart script I posted before. And moved the whole server application to /opt/minecraft/ and alter the script to that. Also removed the sudo as suggested. /opt/ is mounted for boot. I guess screen would work aswell, and I will look into it if I can't find a pleasant way to get into the minecraft server software console.

share|improve this question
    
You don't need sudo since you are already running as root. –  Braiam Jan 21 at 11:54
    
Still won't run at startup though. Now suddenly the process killed itself without me telling it to aswell.. :/ –  PhirePhoenix Jan 21 at 18:16
add comment

1 Answer 1

up vote 1 down vote accepted

I didn't remember screen having a daemon mode, apparently it does. Change the screen line for the following:

screen -dmS minecraft.start /home/phirephoenix/minecraft/bukkitserver/start_server.sh

The new parameter -dmS "Start as daemon: Screen session in detached mode.", which is the combination of -d -m and the -S that you are already using.

share|improve this answer
    
So, i have changed this, and now my boot log seems to be happy, but still no active mc server. Trying to figure out if there is a active "screen" with this running, or where it should be running. But havn't found anything yet. Cause i would guess that the problem is the screen software now right? –  PhirePhoenix Jan 19 at 23:35
    
Now it might be the script actually. Seems like the script got broken somehow.. –  PhirePhoenix Jan 20 at 0:00
    
@PhirePhoenix if you run screen -dmS minecraft.start /home/phirephoenix/minecraft/bukkitserver/start_server.sh in a terminal, manually, does the desired effects happens? –  Braiam Jan 20 at 0:06
    
When I ran the command manually as you asked it does excactly what it is supposed to. It starts the minecraft server in the background and i can close my terminal windows without minecraftserver stopping. What am I missing here? :S (I fixed the .sh script by the way, so that should not be an issue anymore) –  PhirePhoenix Jan 20 at 0:16
    
@PhirePhoenix wait, how exactly doesn't work? –  Braiam Jan 20 at 0:42
show 15 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.