#!/bin/sh
### BEGIN INIT INFO
# Default-Start: 2 3 4 5
# Default-Stop: S 0 1 6
# Short-Description: Example initscript
# Description: This file should be used to construct scripts to be placed in /etc/init.d.
### END INIT INFO
# Author: jsd03
# Do NOT "set -e"
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/usr/sbin:/usr/bin:/sbin:/bin
COMMANDLINE=/oa/talend/commandline303
CMD_WORKSPACE=$COMMANDLINE"/commandline-workspace"
STARTUP=commandline.sh
USER=cxp
NAME=commandline
PORT=10004
# Read configuration variable file if present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
# Load the VERBOSE setting and other rcS variables
[ -f /etc/default/rcS ] && . /etc/default/rcS
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
#
# Function that starts the daemon/service
#
do_start()
{
echo -n $"Starting commandline service: "
su - $USER -c "rm -Rf $CMD_WORKSPACE"
su - $USER -c "cd $COMMANDLINE && screen -dmS cmdLine ./$STARTUP"
#screen -dmS cmdLine $DAEMON_START
RETVAL=$?
echo
}
#
# Function that stops the daemon/service
#
do_stop()
{
echo -n $"Stopping commandline service: "
su - $USER -c "( echo 'stopServer' ; sleep 2 ) | telnet localhost $PORT"
RETVAL=$?
echo
}
case "$1" in
start)
do_start
;;
stop)
do_stop
;;
*)
echo $"Usage: $0 {start|stop}"
exit 1
esac
exit 0