-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from ljdelight/debianInstaller
Debian installer
- Loading branch information
Showing
4 changed files
with
242 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
build/ | ||
.gradle/ | ||
/bin/ | ||
gen-* | ||
*.deb | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,201 @@ | ||
#!/bin/sh | ||
|
||
### BEGIN INIT INFO | ||
# Provides: rawdisk | ||
# Required-Start: $local_fs $remote_fs $network $syslog $named | ||
# Required-Stop: $local_fs $remote_fs $network $syslog $named | ||
# Default-Start: 2 3 4 5 | ||
# Default-Stop: 0 1 6 | ||
# Short-Description: rawdisk service for remote drive access | ||
# Description: rawdisk service for remote drive access | ||
### END INIT INFO | ||
|
||
set -e | ||
|
||
NAME=rawdisk | ||
DESC=rawdisk | ||
RUN_AS=root | ||
|
||
APP_PATH=/opt/ljdelight/rawdisk/ | ||
DAEMON=/usr/bin/java | ||
DAEMON_OPTS="-classpath /opt/ljdelight/rawdisk/RawDiskService-all.jar com.ljdelight.rawdisk.RawDiskServer 9093" | ||
PID_FILE=/var/run/rawdisk.pid | ||
|
||
readonly EC_INVALID_ARGUMENT=2 | ||
readonly EC_SUPER_USER_ONLY=4 | ||
readonly EC_DAEMON_NOT_FOUND=5 | ||
readonly EC_RELOADING_FAILED=95 | ||
readonly EC_RESTART_STOP_FAILED=96 | ||
readonly EC_RESTART_START_FAILED=97 | ||
readonly EC_START_FAILED=98 | ||
readonly EC_STOP_FAILED=99 | ||
|
||
readonly PRINT=/usr/bin/printf | ||
|
||
log_ok() | ||
{ | ||
[ "${VERBOSE}" != no ] && log_success_msg "${NAME}" "$1" | ||
} | ||
|
||
# Display informational message. | ||
log_info() | ||
{ | ||
[ "${VERBOSE}" != no ] && log_daemon_msg "${NAME}" "$1" | ||
|
||
} | ||
|
||
# Display failure message. | ||
log_fail() | ||
{ | ||
log_failure_msg "${NAME}" "$1" | ||
} | ||
|
||
# Exit the script with an error code. | ||
die() | ||
{ | ||
log_end_msg $1 | ||
exit 1 | ||
} | ||
|
||
# Print usage string. | ||
log_usage() | ||
{ | ||
"${PRINT}" 'Usage: %s {start|stop|restart|try-restart|reload|force-reload|status}\n' "$0" | ||
} | ||
|
||
|
||
|
||
# Check for root and exit if not | ||
check_privileges() | ||
{ | ||
if [ $(id -u) -ne 0 ] | ||
then | ||
log_fail 'super user only' | ||
die ${EC_SUPER_USER_ONLY} | ||
fi | ||
} | ||
|
||
|
||
INCLUDE=/lib/lsb/init-functions | ||
if [ -r "${INCLUDE}" ] | ||
then | ||
. "${INCLUDE}" | ||
else | ||
"${PRINT}" '%s: unable to load LSB functions, cannot start service.\n' "${NAME}" 1>&2 | ||
exit ${EC_DAEMON_NOT_FOUND} | ||
fi | ||
|
||
|
||
|
||
### | ||
# Starts the service. | ||
# | ||
# RETURN: | ||
# 0 - successfully started | ||
# 1 - starting failed | ||
### | ||
start_service() | ||
{ | ||
start-stop-daemon --start --background \ | ||
-d ${APP_PATH} -c ${RUN_AS} \ | ||
--pidfile ${PID_FILE} \ | ||
--make-pidfile \ | ||
--exec ${DAEMON} \ | ||
-- ${DAEMON_OPTS} | ||
} | ||
|
||
|
||
### | ||
# Stops the service. | ||
# | ||
# RETURN: | ||
# 0 - successfully stopped | ||
# 1 - stopping failed | ||
### | ||
stop_service() | ||
{ | ||
start-stop-daemon --stop --signal QUIT --retry=QUIT/10/KILL/5 \ | ||
--pidfile $PID_FILE | ||
rm -f $PID_FILE | ||
} | ||
|
||
|
||
|
||
|
||
|
||
# Make sure only one argument was passed to the script. | ||
if [ $# -ne 1 ] | ||
then | ||
if [ $# -lt 1 -o "$1" = '' ] | ||
then log_fail 'action not specified.' | ||
else log_fail 'too many arguments.' | ||
fi | ||
log_usage 1>&2 | ||
die ${EC_INVALID_ARGUMENT} | ||
fi | ||
readonly ACTION="$1" | ||
|
||
if [ ! -x "${DAEMON}" ] | ||
then | ||
log_fail "executable not found: cannot ${ACTION} service" | ||
die ${EC_DAEMON_NOT_FOUND} | ||
fi | ||
|
||
# Determine the status, 0 means the service is running | ||
STATUS=0 | ||
start-stop-daemon --status --pidfile ${PID_FILE} 2>/dev/null 1>/dev/null || STATUS=$? | ||
|
||
|
||
|
||
case "$1" in | ||
|
||
start) | ||
check_privileges | ||
if [ ${STATUS} -eq 0 ] | ||
then | ||
log_ok 'already started.' | ||
else | ||
log_info 'starting ...' | ||
start_service || die ${EC_START_FAILED} | ||
fi | ||
;; | ||
|
||
stop) | ||
check_privileges | ||
if [ ${STATUS} -eq 0 ] | ||
then | ||
log_info 'stopping ...' | ||
stop_service || die ${EC_STOP_FAILED} | ||
else | ||
log_info 'already stopped.' | ||
fi | ||
;; | ||
|
||
restart|force-reload) | ||
check_privileges | ||
if [ ${STATUS} -eq 0 ] | ||
then | ||
log_info 'stopping service ...' | ||
stop_service || die ${EC_RESTART_STOP_FAILED} | ||
sleep 0.1 | ||
fi | ||
log_info 'starting ...' | ||
start_service || die ${EC_RESTART_START_FAILED} | ||
;; | ||
|
||
status) | ||
status_of_proc "${DAEMON}" "${NAME}" || exit $? | ||
;; | ||
|
||
-h|--help) | ||
log_usage | ||
;; | ||
|
||
*) | ||
log_fail "action '${ACTION}' not recognized." | ||
log_usage 1>&2 | ||
exit ${EC_INVALID_ARGUMENT} | ||
;; | ||
esac | ||
|
||
exit 0 |