<commit_before>#!/bin/sh
#
# This file is managed by Puppet and local changes
# may be overwritten
#
#    /etc/rc.d/init.d/<servicename>
#
#    Daemon for <%= @title %>
#
# chkconfig: 2345 97 15
# description: Docker container for <%= @title %>

### BEGIN INIT INFO
## Provides:       docker-<%= @title %>
## Required-Start: $network docker
## Required-Stop: $network docker
## Should-Start:
## Should-Stop:
## Default-Start: 2 3 4 5
## Default-Stop:  0 1 6
## Short-Description: start and stop docker container for <%= @title %>
## Description: Docker container for <%= @title %>
#### END INIT INFO

if [ -e /etc/init.d/functions ]; then
    . /etc/init.d/functions
elif [ -e /lib/lsb/init-functions ]; then
    . /lib/lsb/init-functions

    failure() {
        log_failure_msg "$@"
        return 1
    }
    success() {
        log_success_msg "$@"
        return 0
    }
else
    failure() {
        echo "fail: $@" >&2
        exit 1
    }
    success() {
        echo "success: $@" >&2
        exit 0
    }
fi

docker="/usr/bin/<%= docker_command %>"
prog="docker-<%= @title %>"
cidfile="/var/run/$prog.cid"

if [ -d /var/lock/subsys ]; then
    lockfile="/var/lock/subsys/$prog"
else
    unset lockfile
fi

start() {
    [ -x $docker ] || exit 5

    if [ -f $cidfile ]; then
        cid="$(cat $cidfile)"
        if [ -n "$cid" ]; then
            $docker ps --no-trunc=true|grep $cid
            retval=$?
            if [ $retval -eq 0 ]; then
                failure
                echo
                printf "Container $cid is still running.\n"
                exit 7
            else
                rm -f $lockfile $cidfile
            fi
        fi
    fi

    printf "Starting $prog:\t"
    $docker run --cidfile=$cidfile -d=true \
        <% if @username %>-u '<%= @username %>' <% end %> \
        <% if @hostname %>-h '<%= @hostname %>'<% end %> \
        <% if @disable_network %>-n false<% end %> \
        <% if @privileged %>--privileged<% end %> \
        <% if @dns %><% @dns_array.each do |address| %> \
            --dns <%= address %><% end %> \
        <% end %> \
        <% if @env %><% @env_array.each do |env| %> \
            -e <%= env %><% end %> \
        <% end %> \
        <% if @ports %><% @ports_array.each do |port| %> \
            -p <%= port %><% end %> \
        <% end %> \
        <% if @expose %><% @expose_array.each do |expose_port| %> \
            --expose=<%= expose_port %><% end %> \
        <% end %> \
        <% if @volumes %><% @volumes_array.each do |volume| %> \
            -v <%= volume %><% end %> \
        <% end %> \
        <% if @volumes_from %> --volumes-from <%= @volumes_from %><% end %> \
        <% if @net %>--net <%= @net %><% end %> \
        <% if @lxc_conf_array %><% @lxc_conf_array.each do |lxcconf| %> \
            --lxc-conf="<%=lxcconf%>"<% end %> \
        <% end %> \
        -m <%= @memory_limit %> \
        <% if @links %><%= @links_array.map {|link| \
            "--link #{link}" }.join(' ') %> \
        <% end %> \
        <% if @use_name %>--name <%= @name %><% end %> \
        <%= @image %> \
        <% if @extra_parameters %><% @extra_parameters_array.each do |param| %>  \
            <%= param %> <% end %> \
        <% end -%> \
        <% if @command %> <%= @command %><% end %>
    retval=$?
    echo
    if [ $retval -eq 0 ]; then
        [ -n "$lockfile" ] && touch $lockfile
        success
    else
        failure
    fi
}

stop() {
    if ! [ -f $cidfile ]; then
        failure
        echo
        printf "$cidfile does not exist.\n"
        exit 7
    else
        cid="$(cat $cidfile)"
        if [ -n $cid ]; then
            echo -n $"Stopping $prog: "
            $docker stop $(cat $cidfile)
            retval=$?
            [ $retval -eq 0 ] && rm -f $lockfile $cidfile
            return $retval
        else
            rm $cidfile
        fi
    fi
}

case "$1" in
    start)
    start
    ;;
    stop)
    stop
    ;;
    status)
    docker inspect $(cat $cidfile)
    ;;
    restart|reload)
    stop
    start
    ;;
    condrestart)
    [ -f /var/lock/subsys/$prog ] && restart || :
    ;;
    *)
    echo "Usage: $0 [start|stop|status|reload|restart|probe]"
    exit 1
    ;;
esac
exit $?
<commit_msg>Make sysvinit script have proper status<commit_after>#!/bin/sh
#
# This file is managed by Puppet and local changes
# may be overwritten
#
#    /etc/rc.d/init.d/<servicename>
#
#    Daemon for <%= @title %>
#
# chkconfig: 2345 97 15
# description: Docker container for <%= @title %>

### BEGIN INIT INFO
## Provides:       docker-<%= @title %>
## Required-Start: $network docker
## Required-Stop: $network docker
## Should-Start:
## Should-Stop:
## Default-Start: 2 3 4 5
## Default-Stop:  0 1 6
## Short-Description: start and stop docker container for <%= @title %>
## Description: Docker container for <%= @title %>
#### END INIT INFO

if [ -e /etc/init.d/functions ]; then
    . /etc/init.d/functions
elif [ -e /lib/lsb/init-functions ]; then
    . /lib/lsb/init-functions

    failure() {
        log_failure_msg "$@"
        return 1
    }
    success() {
        log_success_msg "$@"
        return 0
    }
else
    failure() {
        echo "fail: $@" >&2
        exit 1
    }
    success() {
        echo "success: $@" >&2
        exit 0
    }
fi

docker="/usr/bin/<%= docker_command %>"
prog="docker-<%= @title %>"
cidfile="/var/run/$prog.cid"

if [ -d /var/lock/subsys ]; then
    lockfile="/var/lock/subsys/$prog"
else
    unset lockfile
fi

start() {
    [ -x $docker ] || exit 5

    if [ -f $cidfile ]; then
        cid="$(cat $cidfile)"
        if [ -n "$cid" ]; then
            $docker ps --no-trunc=true|grep $cid
            retval=$?
            if [ $retval -eq 0 ]; then
                failure
                echo
                printf "Container $cid is still running.\n"
                exit 7
            else
                rm -f $lockfile $cidfile
            fi
        fi
    fi

    printf "Starting $prog:\t"
    $docker run --cidfile=$cidfile -d=true \
        <% if @username %>-u '<%= @username %>' <% end %> \
        <% if @hostname %>-h '<%= @hostname %>'<% end %> \
        <% if @disable_network %>-n false<% end %> \
        <% if @privileged %>--privileged<% end %> \
        <% if @dns %><% @dns_array.each do |address| %> \
            --dns <%= address %><% end %> \
        <% end %> \
        <% if @env %><% @env_array.each do |env| %> \
            -e <%= env %><% end %> \
        <% end %> \
        <% if @ports %><% @ports_array.each do |port| %> \
            -p <%= port %><% end %> \
        <% end %> \
        <% if @expose %><% @expose_array.each do |expose_port| %> \
            --expose=<%= expose_port %><% end %> \
        <% end %> \
        <% if @volumes %><% @volumes_array.each do |volume| %> \
            -v <%= volume %><% end %> \
        <% end %> \
        <% if @volumes_from %> --volumes-from <%= @volumes_from %><% end %> \
        <% if @net %>--net <%= @net %><% end %> \
        <% if @lxc_conf_array %><% @lxc_conf_array.each do |lxcconf| %> \
            --lxc-conf="<%=lxcconf%>"<% end %> \
        <% end %> \
        -m <%= @memory_limit %> \
        <% if @links %><%= @links_array.map {|link| \
            "--link #{link}" }.join(' ') %> \
        <% end %> \
        <% if @use_name %>--name <%= @name %><% end %> \
        <%= @image %> \
        <% if @extra_parameters %><% @extra_parameters_array.each do |param| %>  \
            <%= param %> <% end %> \
        <% end -%> \
        <% if @command %> <%= @command %><% end %>
    retval=$?
    echo
    if [ $retval -eq 0 ]; then
        [ -n "$lockfile" ] && touch $lockfile
        success
    else
        failure
    fi
}

stop() {
    if ! [ -f $cidfile ]; then
        failure
        echo
        printf "$cidfile does not exist.\n"
        exit 7
    else
        cid="$(cat $cidfile)"
        if [ -n $cid ]; then
            echo -n $"Stopping $prog: "
            $docker stop $(cat $cidfile)
            retval=$?
            [ $retval -eq 0 ] && rm -f $lockfile $cidfile
            return $retval
        else
            rm $cidfile
        fi
    fi
}

case "$1" in
    start)
    start
    ;;
    stop)
    stop
    ;;
    status)
    docker inspect --format='{{ .State.Running }}' $(cat $cidfile) | grep -q 'true'
    ;;
    restart|reload)
    stop
    start
    ;;
    condrestart)
    [ -f /var/lock/subsys/$prog ] && restart || :
    ;;
    *)
    echo "Usage: $0 [start|stop|status|reload|restart|probe]"
    exit 1
    ;;
esac
exit $?

{'fraction_non_alphanumeric': 0.1879171057253249, 'fraction_numerical': 0.007024938531787847, 'mean_word_length': 1.6170343137254901, 'pattern_counts': {'":': 0, '<': 143, '<?xml version=': 0, '>': 147, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4721516', 'n_tokens_mistral': 3178, 'n_tokens_neox': 2868, 'n_words': 724}