Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for 'grep' in mc_start #156

Open
jjarokergc opened this issue Feb 9, 2014 · 0 comments
Open

fix for 'grep' in mc_start #156

jjarokergc opened this issue Feb 9, 2014 · 0 comments

Comments

@jjarokergc
Copy link

Hello, thanks for the script. It did not work for me initially. I noticed that the PID file contained the wrong process ID. It had a '1' appended to the correct value.

I think the grep command you want is 'grep -w [0-9]*.$SCREEN' in the mc_start command. In other words, you should limit the grep match to a word boundary to avoid grabbing the superfluous '1' introduced by the subsequent output in screen. This fix works for me in Debian 7.

Here is the complete code block (ignore my debugging 'log' routines)

mc_start() {
    log "mc_start: Attempting to Start the Service ..."

    servicejar=$MCPATH/$SERVICE
    log "mc_start: servicejar=${servicejar}"

    if [ ! -f "$servicejar" ]
    then
        log "mc_start: Failed to start: Can't find the specified Minecraft jar under $servicejar. Please check your config!" "5"
        exit 1
    fi

    pidfile=${MCPATH}/${SCREEN}.pid
    log "pidfile=${pidfile}"
    check_permissions

    as_user "cd $MCPATH && screen -dmS $SCREEN $INVOCATION"
    as_user "screen -list | grep -w [0-9]*"\.$SCREEN" | cut -f1 -d'.' | tr -d -c 0-9 > $pidfile"

    #
    # Waiting for the server to start
    #
    seconds=0
    until is_running
    do
        sleep 1
        seconds=$seconds+1
        if [[ $seconds -eq 5 ]]
        then
            log "Still not running, waiting a while longer..." '5'
        fi
        if [[ $seconds -ge 120 ]]
        then
            log "Failed to start, aborting." '3'
            exit 1
        fi
    done
    echo "$SERVICE is running."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant