<commit_before>#!/bin/sh
### BEGIN INIT INFO
# Provides:          
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       Enable service provided by daemon.
### END INIT INFO

dir="<%= @dir %>"
user="<%= @user %>"
cmd="<%= @cmd %>"

name=`basename $0`
pid_file="/var/run/$name.pid"
stdout_log="/var/log/$name.log"
stderr_log="/var/log/$name.err"

get_pid() {
    cat "$pid_file"    
}

is_running() {
    [ -f "$pid_file" ] && ps `get_pid` > /dev/null 2>&1
}

case "$1" in
    start)
	if is_running; then
	    echo "Already started"
	else
	    echo "Starting $name"
	    cd "$dir"
            sudo -u "$user" $cmd > "$stdout_log" 2> "$stderr_log" \
		& echo $! > "$pid_file"
	    if ! is_running; then
		echo "Unable to start, see $stdout_log and $stderr_log"
		exit 1
	    fi
	fi
	;;
    stop)
	if is_running; then
	    echo "Stopping $name"
	    kill `get_pid`
	    rm "$pid_file"
	else
	    echo "Not running"
	fi
	;;
    restart)
	$0 stop
	$0 start
	;;
    status)
	if is_running; then
	    echo "$name is running"
	else
	    echo "$name is stopped"
	    exit 1
	fi
	;;
    *)<commit_msg>Updated IPython public notebook init.d script<commit_after>#!/bin/sh
### BEGIN INIT INFO
# Provides:          
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       Enable service provided by daemon.
### END INIT INFO

dir="<%= @dir %>"
user="<%= @user %>"
cmd="<%= @cmd %>"

name=`basename $0`
pid_file="/var/run/$name.pid"
stdout_log="/var/log/$name.log"
stderr_log="/var/log/$name.err"

get_pid() {
    cat "$pid_file"    
}

is_running() {
    [ -f "$pid_file" ] && ps `get_pid` > /dev/null 2>&1
}

case "$1" in
    start)
	if is_running; then
	    echo "Already started"
	else
	    echo "Starting $name"
            su "$user" -c "cd $dir && $cmd" > "$stdout_log" 2> "$stderr_log" \
		& echo $! > "$pid_file"
	    if ! is_running; then
		echo "Unable to start, see $stdout_log and $stderr_log"
		exit 1
	    fi
	fi
	;;
    stop)
	if is_running; then
	    echo "Stopping $name"
	    kill `get_pid`
	    rm "$pid_file"
	else
	    echo "Not running"
	fi
	;;
    restart)
	$0 stop
	$0 start
	;;
    status)
	if is_running; then
	    echo "$name is running"
	else
	    echo "$name is stopped"
	    exit 1
	fi
	;;
    *)
{'fraction_non_alphanumeric': 0.1541832669322709, 'fraction_numerical': 0.012749003984063745, 'mean_word_length': 2.5718349928876245, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 19, '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': '2368916', 'n_tokens_mistral': 1008, 'n_tokens_neox': 947, 'n_words': 271}