forked from opendedup/CopyCat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.oddcopycat
97 lines (73 loc) · 2.41 KB
/
init.oddcopycat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#! /bin/sh
# /etc/init.d/oddcopycat
# chkconfig: 235 77 01
# description: ODDCOPYCAT
### BEGIN INIT INFO
# Provides: oddcopycat
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Short-Description: Starts the OpenDedupe Copycat service
# Description: This file is used to start the CopyCat daemon
# and should be placed in /etc/init.d
### END INIT INFO
# Author: Sam Silverberg <sam.silverberg[at]gmail.com>
# Url: www.opendedup.org
# Date: 9/01/2018
NAME="oddcopycat"
DESC="CopyCat service"
# The path to Jsvc
EXEC="/usr/share/sdfs/jsvc"
# The path to the folder containing MyDaemon.jar
FILE_PATH="/usr/share/sdfs/$NAME"
# The path to the folder containing the java runtime
JAVA_HOME="/usr/share/sdfs/bin/jre/"
# Our classpath including our jar file and the Apache Commons Daemon library
CLASS_PATH="$FILE_PATH/cc.jar"
# The fully qualified name of the class to execute
CLASS="com.datish.copycat.ServerService"
# Any command line arguments to be passed to the our Java Daemon implementations init() method
ARGS="/etc/sdfs/copycat.json"
#The user to run the daemon as
USER="root"
# The file that will contain our process identification number (pid) for other scripts/programs that need to access it.
PID="/var/run/$NAME.pid"
# System.out writes to this file...
LOG_OUT="$FILE_PATH/log/$NAME.out"
# System.err writes to this file...
LOG_ERR="$FILE_PATH/err/$NAME.err"
jsvc_exec()
{
cd $FILE_PATH
$EXEC -home $JAVA_HOME -cp $CLASS_PATH -user $USER -outfile $LOG_OUT -errfile $LOG_ERR -pidfile $PID $1 $CLASS $ARGS
}
case "$1" in
start)
echo "Starting the $DESC..."
# Start the service
jsvc_exec
echo "The $DESC has started."
;;
stop)
echo "Stopping the $DESC..."
# Stop the service
jsvc_exec "-stop"
echo "The $DESC has stopped."
;;
restart)
if [ -f "$PID" ]; then
echo "Restarting the $DESC..."
# Stop the service
jsvc_exec "-stop"
# Start the service
jsvc_exec
echo "The $DESC has restarted."
else
echo "Daemon not running, no action taken"
exit 1
fi
;;
*)
echo "Usage: /etc/init.d/$NAME {start|stop|restart}" >&2
exit 3
;;
esac