* moving wrapper scripts to installer/resources

* added wrapper files to the 'installer' target of the global build.xml
This commit is contained in:
hypercubus
2004-08-24 12:25:46 +00:00
committed by zzz
parent 30ce04bc84
commit c88c245094
8 changed files with 9 additions and 132 deletions

View File

@ -1,338 +0,0 @@
#! /bin/sh
#
# Skeleton sh script suitable for starting and stopping
# wrapped Java apps on the Solaris platform.
#
# Make sure that PIDFILE points to the correct location,
# if you have changed the default location set in the
# wrapper configuration file.
#
#-----------------------------------------------------------------------------
# These settings can be modified to fit the needs of your application
# Application
APP_NAME="i2p"
APP_LONG_NAME="I2P Service"
# Wrapper
WRAPPER_CMD="i2psvc"
WRAPPER_CONF="wrapper.conf"
# Priority at which to run the wrapper. See "man nice" for valid priorities.
# nice is only used if a priority is specified.
PRIORITY=
# Location of the pid file.
PIDDIR="."
# If uncommented, causes the Wrapper to be shutdown using an anchor file.
# When launched with the 'start' command, it will also ignore all INT and
# TERM signals.
#IGNORE_SIGNALS=true
# If specified, the Wrapper will be run as the specified user when the 'start'
# command is passed to this script. When running with the 'console' command
# the current user will be used.
# IMPORTANT - Make sure that the user has the required privileges to write
# the PID file and wrapper.log files. Failure to be able to write the log
# file will cause the Wrapper to exit without any way to write out an error
# message.
# NOTE - This will set the user which is used to run the Wrapper as well as
# the JVM and is not useful in situations where a privileged resource or
# port needs to be allocated prior to the user being changed.
#RUN_AS_USER=
# Do not modify anything beyond this point
#-----------------------------------------------------------------------------
# Get the fully qualified path to the script
case $0 in
/*)
SCRIPT="$0"
;;
*)
PWD=`pwd`
SCRIPT="$PWD/$0"
;;
esac
# Change spaces to ":" so the tokens can be parsed.
SCRIPT=`echo $SCRIPT | sed -e 's; ;:;g'`
# Get the real path to this script, resolving any symbolic links
TOKENS=`echo $SCRIPT | sed -e 's;/; ;g'`
REALPATH=
for C in $TOKENS; do
REALPATH="$REALPATH/$C"
while [ -h "$REALPATH" ] ; do
LS="`ls -ld "$REALPATH"`"
LINK="`expr "$LS" : '.*-> \(.*\)$'`"
if expr "$LINK" : '/.*' > /dev/null; then
REALPATH="$LINK"
else
REALPATH="`dirname "$REALPATH"`""/$LINK"
fi
done
done
# Change ":" chars back to spaces.
REALPATH=`echo $REALPATH | sed -e 's;:; ;g'`
# Change the current directory to the location of the script
cd "`dirname "$REALPATH"`"
# Process ID
ANCHORFILE="$PIDDIR/$APP_NAME.anchor"
PIDFILE="$PIDDIR/$APP_NAME.pid"
pid=""
# Resolve the location of the 'ps' command
PSEXE="/usr/bin/ps"
if [ ! -x $PSEXE ]
then
PSEXE="/bin/ps"
if [ ! -x $PSEXE ]
then
echo "Unable to locate 'ps'."
echo "Please report this with the location on your system."
exit 1
fi
fi
# Build the nice clause
if [ "X$PRIORITY" = "X" ]
then
CMDNICE=""
else
CMDNICE="nice -$PRIORITY"
fi
# Check the configured user
if [ "X$RUN_AS_USER" != "X" ]
then
if [ "`id -u -n`" = "$RUN_AS_USER" ]
then
# Already running as the configured user. Avoid password prompts by not calling su.
RUN_AS_USER=""
fi
fi
getpid() {
if [ -f $PIDFILE ]
then
if [ -r $PIDFILE ]
then
pid=`cat $PIDFILE`
if [ "X$pid" != "X" ]
then
# Verify that a process with this pid is still running.
pid=`$PSEXE -p $pid | grep $pid | grep -v grep | awk '{print $1}' | tail -1`
if [ "X$pid" = "X" ]
then
# This is a stale pid file.
rm -f $PIDFILE
echo "Removed stale pid file: $PIDFILE"
fi
fi
else
echo "Cannot read $PIDFILE."
exit 1
fi
fi
}
testpid() {
pid=`$PSEXE -p $pid | grep $pid | grep -v grep | awk '{print $1}' | tail -1`
if [ "X$pid" = "X" ]
then
# Process is gone so remove the pid file.
rm -f $PIDFILE
fi
}
console() {
echo "Running $APP_LONG_NAME..."
getpid
if [ "X$pid" = "X" ]
then
if [ "X$IGNORE_SIGNALS" = "X" ]
then
exec $CMDNICE $WRAPPER_CMD $WRAPPER_CONF i2psvc.pidfile=$PIDFILE
else
exec $CMDNICE $WRAPPER_CMD $WRAPPER_CONF i2psvc.pidfile=$PIDFILE wrapper.anchorfile=$ANCHORFILE
fi
else
echo "$APP_LONG_NAME is already running."
exit 1
fi
}
start() {
echo "Starting $APP_LONG_NAME..."
getpid
if [ "X$pid" = "X" ]
then
if [ "X$IGNORE_SIGNALS" = "X" ]
then
if [ "X$RUN_AS_USER" = "X" ]
then
exec $CMDNICE $WRAPPER_CMD $WRAPPER_CONF i2psvc.pidfile=$PIDFILE wrapper.daemonize=TRUE
else
su -m $RUN_AS_USER -c "exec $CMDNICE $WRAPPER_CMD $WRAPPER_CONF i2psvc.pidfile=$PIDFILE wrapper.daemonize=TRUE"
fi
else
if [ "X$RUN_AS_USER" = "X" ]
then
exec $CMDNICE $WRAPPER_CMD $WRAPPER_CONF i2psvc.pidfile=$PIDFILE wrapper.anchorfile=$ANCHORFILE wrapper.ignore_signals=TRUE wrapper.daemonize=TRUE
else
su -m $RUN_AS_USER -c "exec $CMDNICE $WRAPPER_CMD $WRAPPER_CONF i2psvc.pidfile=$PIDFILE wrapper.anchorfile=$ANCHORFILE wrapper.ignore_signals=TRUE wrapper.daemonize=TRUE"
fi
fi
else
echo "$APP_LONG_NAME is already running."
exit 1
fi
}
stopit() {
echo "Stopping $APP_LONG_NAME..."
getpid
if [ "X$pid" = "X" ]
then
echo "$APP_LONG_NAME was not running."
else
if [ "X$IGNORE_SIGNALS" = "X" ]
then
# Running so try to stop it.
kill $pid
if [ $? -ne 0 ]
then
# An explanation for the failure should have been given
echo "Unable to stop $APP_LONG_NAME."
exit 1
fi
else
rm -f $ANCHORFILE
if [ -f $ANCHORFILE ]
then
# An explanation for the failure should have been given
echo "Unable to stop $APP_LONG_NAME."
exit 1
fi
fi
# We can not predict how long it will take for the wrapper to
# actually stop as it depends on settings in wrapper.conf.
# Loop until it does.
savepid=$pid
CNT=0
TOTCNT=0
while [ "X$pid" != "X" ]
do
# Loop for up to 5 minutes
if [ "$TOTCNT" -lt "300" ]
then
if [ "$CNT" -lt "5" ]
then
CNT=`expr $CNT + 1`
else
echo "Waiting for $APP_LONG_NAME to exit..."
CNT=0
fi
TOTCNT=`expr $TOTCNT + 1`
sleep 1
testpid
else
pid=
fi
done
pid=$savepid
testpid
if [ "X$pid" != "X" ]
then
echo "Timed out waiting for $APP_LONG_NAME to exit."
echo " Attempting a forced exit..."
kill -9 $pid
fi
pid=$savepid
testpid
if [ "X$pid" != "X" ]
then
echo "Failed to stop $APP_LONG_NAME."
exit 1
else
echo "Stopped $APP_LONG_NAME."
fi
fi
}
status() {
getpid
if [ "X$pid" = "X" ]
then
echo "$APP_LONG_NAME is not running."
exit 1
else
echo "$APP_LONG_NAME is running ($pid)."
exit 0
fi
}
dump() {
echo "Dumping $APP_LONG_NAME..."
getpid
if [ "X$pid" = "X" ]
then
echo "$APP_LONG_NAME was not running."
else
kill -3 $pid
if [ $? -ne 0 ]
then
echo "Failed to dump $APP_LONG_NAME."
exit 1
else
echo "Dumped $APP_LONG_NAME."
fi
fi
}
case "$1" in
'console')
console
;;
'start')
start
;;
'stop')
stopit
;;
'restart')
stopit
start
;;
'status')
status
;;
'dump')
dump
;;
*)
echo "Usage: $0 { console | start | stop | restart | status | dump }"
exit 1
;;
esac
exit 0

View File

@ -1,40 +0,0 @@
@echo off
setlocal
rem
rem Java Service Wrapper general startup script
rem
rem
rem Resolve the real path of the Wrapper.exe
rem For non NT systems, the _REALPATH and _WRAPPER_CONF values
rem can be hard-coded below and the following test removed.
rem
if "%OS%"=="Windows_NT" goto nt
echo This script only works with NT-based versions of Windows.
goto :eof
:nt
rem
rem Find the application home.
rem
rem %~dp0 is location of current script under NT
set _REALPATH=%~dp0
set _WRAPPER_EXE=%_REALPATH%I2Psvc.exe
rem
rem Find the wrapper.conf
rem
:conf
set _WRAPPER_CONF="%~f1"
if not %_WRAPPER_CONF%=="" goto startup
set _WRAPPER_CONF="%_REALPATH%wrapper.conf"
rem
rem Start the Wrapper
rem
:startup
"%_WRAPPER_EXE%" -c %_WRAPPER_CONF%
if not errorlevel 1 goto :eof
pause

View File

@ -1,116 +0,0 @@
#!/bin/sh
# I2P Installer - Installs and pre-configures I2P.
#
# install_i2p_service_unix
# 2004 The I2P Project
# http://www.i2p.net
# This code is public domain.
#
# author: hypercubus
#
# Installs I2P as a service on various *nix systems using Wrapper. This script
# must be run as root.
#
# Wrapper can be found at:
# http://wrapper.tanukisoftware.org/doc/english/introduction.html
if [ $UID -ne 0 ]; then
echo 'Sorry, you need root privileges to install services.'
exit 1
fi
HOST_OS=`uname -a`
if [ ! '$HOST_OS' ]; then
echo 'Cannot determine operating system type. Aborting service installation.'
exit 1
fi
# The following are several different service installation methods covering some
# of the major *nix operating systems. Most *nix OSes should be able to use one
# of these styles. TODO: AIX, HP-UX, HP-UX/64, IRIX, OSF/1.
install_bsd()
{
ln -sf `pwd`/i2psvc /usr/local/etc/rc.d/i2psvc.sh
}
install_debian()
{
ln -sf `pwd`/i2psvc /etc/init.d/i2psvc
update-rc.d i2psvc start 20 2 3 4 5 . stop 20 0 1 6 .
}
install_gentoo()
{
ln -sf `pwd`/i2psvc /etc/init.d/i2psvc
rc-update add i2psvc default
}
install_redhat()
{
ln -sf `pwd`/i2psvc /etc/rc.d/init.d/i2psvc
chkconfig --level 345 i2psvc on
}
install_sysv()
{
ln -sf `pwd`/i2psvc /etc/init.d/i2psvc
ln -sf /etc/init.d/i2psvc /etc/rc0.d/K20i2psvc
ln -sf /etc/init.d/i2psvc /etc/rc1.d/K20i2psvc
ln -sf /etc/init.d/i2psvc /etc/rc2.d/S20i2psvc
ln -sf /etc/init.d/i2psvc /etc/rc3.d/S20i2psvc
}
if [[ `echo "$HOST_OS" | grep Darwin` || `echo "$HOST_OS" | grep Macintosh` ]]; then
install_bsd
exit 0
fi
if [[ `echo "$HOST_OS" | grep FreeBSD` ]]; then
install_bsd
exit 0
fi
if [[ `echo "$HOST_OS" | grep Linux` ]]; then
LINUX_DISTRO=`cat /proc/version`
if [[ `echo "$LINUX_DISTRO" | grep Debian` ]]; then
install_debian
exit 0
fi
if [[ `echo "$LINUX_DISTRO" | grep Fedora` ]]; then
install_redhat
exit 0
fi
if [[ `echo "$LINUX_DISTRO" | grep Gentoo` ]]; then
install_gentoo
exit 0
fi
if [[ `echo "$LINUX_DISTRO" | grep Mandrake` ]]; then
install_redhat
exit 0
fi
if [[ `echo "$LINUX_DISTRO" | grep "Red Hat"` ]]; then
install_redhat
exit 0
fi
if [[ `echo "$LINUX_DISTRO" | grep Suse` ]]; then
install_redhat
exit 0
fi
fi
if [[ `echo "$HOST_OS" | grep Solaris` ]]; then
install_sysv()
exit 0
fi
echo 'Cannot determine operating system type. Aborting service installation.'
exit 1

View File

@ -1,35 +0,0 @@
@echo off
setlocal
rem
rem Java Service Wrapper general NT service install script
rem
if "%OS%"=="Windows_NT" goto nt
echo This script only works with NT-based versions of Windows.
goto :eof
:nt
rem
rem Find the application home.
rem
rem %~dp0 is location of current script under NT
set _REALPATH=%~dp0
set _WRAPPER_EXE=%_REALPATH%I2Psvc.exe
rem
rem Find the wrapper.conf
rem
:conf
set _WRAPPER_CONF="%~f1"
if not %_WRAPPER_CONF%=="" goto startup
set _WRAPPER_CONF="%_REALPATH%wrapper.conf"
rem
rem Install the Wrapper as an NT service.
rem
:startup
"%_WRAPPER_EXE%" -i %_WRAPPER_CONF%
if not errorlevel 1 goto :eof
pause

View File

@ -1,116 +0,0 @@
#!/bin/sh
# I2P Installer - Installs and pre-configures I2P.
#
# uninstall_i2p_service_unix
# 2004 The I2P Project
# http://www.i2p.net
# This code is public domain.
#
# author: hypercubus
#
# Uninstalls the Wrapper-based I2P service on various *nix systems. This script
# must be run as root.
#
# Wrapper can be found at:
# http://wrapper.tanukisoftware.org/doc/english/introduction.html
if [ $UID -ne 0 ]; then
echo 'Sorry, you need root privileges to uninstall services.'
exit 1
fi
HOST_OS=`uname -a`
if [ ! '$HOST_OS' ]; then
echo 'Cannot determine operating system type. Please uninstall the service manually.'
exit 1
fi
# The following are several different service installation methods covering some
# of the major *nix operating systems. Most *nix OSes should be able to use one
# of these styles. TODO: AIX, HP-UX, HP-UX/64, IRIX, OSF/1.
uninstall_bsd()
{
rm /usr/local/etc/rc.d/i2psvc.sh
}
uninstall_debian()
{
rm /etc/init.d/i2psvc
update-rc.d -f i2psvc remove
}
uninstall_gentoo()
{
rm /etc/init.d/i2psvc
rc-update del i2psvc default
}
uninstall_redhat()
{
rm /etc/rc.d/init.d/i2psvc
chkconfig --level 345 i2psvc off
}
uninstall_sysv()
{
rm /etc/init.d/i2psvc
rm /etc/rc0.d/K20i2psvc
rm /etc/rc1.d/K20i2psvc
rm /etc/rc2.d/S20i2psvc
rm /etc/rc3.d/S20i2psvc
}
if [[ `echo "$HOST_OS" | grep Darwin` || `echo "$HOST_OS" | grep Macintosh` ]]; then
uninstall_bsd
exit 0
fi
if [[ `echo "$HOST_OS" | grep FreeBSD` ]]; then
uninstall_bsd
exit 0
fi
if [[ `echo "$HOST_OS" | grep Linux` ]]; then
LINUX_DISTRO=`cat /proc/version`
if [[ `echo "$LINUX_DISTRO" | grep Debian` ]]; then
uninstall_debian
exit 0
fi
if [[ `echo "$LINUX_DISTRO" | grep Fedora` ]]; then
uninstall_redhat
exit 0
fi
if [[ `echo "$LINUX_DISTRO" | grep Gentoo` ]]; then
uninstall_gentoo
exit 0
fi
if [[ `echo "$LINUX_DISTRO" | grep Mandrake` ]]; then
uninstall_redhat
exit 0
fi
if [[ `echo "$LINUX_DISTRO" | grep "Red Hat"` ]]; then
uninstall_redhat
exit 0
fi
if [[ `echo "$LINUX_DISTRO" | grep Suse` ]]; then
uninstall_redhat
exit 0
fi
fi
if [[ `echo "$HOST_OS" | grep Solaris` ]]; then
uninstall_sysv()
exit 0
fi
echo 'Cannot determine operating system type. Please uninstall the service manually.'
exit 1

View File

@ -1,35 +0,0 @@
@echo off
setlocal
rem
rem Java Service Wrapper general NT service uninstall script
rem
if "%OS%"=="Windows_NT" goto nt
echo This script only works with NT-based versions of Windows.
goto :eof
:nt
rem
rem Find the application home.
rem
rem %~dp0 is location of current script under NT
set _REALPATH=%~dp0
set _WRAPPER_EXE=%_REALPATH%I2Psvc.exe
rem
rem Find the wrapper.conf
rem
:conf
set _WRAPPER_CONF="%~f1"
if not %_WRAPPER_CONF%=="" goto startup
set _WRAPPER_CONF="%_REALPATH%wrapper.conf"
rem
rem Uninstall the Wrapper as an NT service.
rem
:startup
"%_WRAPPER_EXE%" -r %_WRAPPER_CONF%
if not errorlevel 1 goto :eof
pause

View File

@ -1,131 +0,0 @@
#********************************************************************
# Wrapper Properties
#********************************************************************
# Java Application
wrapper.java.command=java
# Java Main class. This class must implement the WrapperListener interface
# or guarantee that the WrapperManager class is initialized. Helper
# classes are provided to do this for you. See the Integration section
# of the documentation for details.
wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp
# Java Classpath (include wrapper.jar) Add class path elements as
# needed starting from 1
wrapper.java.classpath.1=lib/ant.jar
wrapper.java.classpath.2=lib/heartbeat.jar
wrapper.java.classpath.3=lib/i2p.jar
wrapper.java.classpath.4=lib/i2ptunnel.jar
wrapper.java.classpath.5=lib/jasper-compiler.jar
wrapper.java.classpath.6=lib/jasper-runtime.jar
wrapper.java.classpath.7=lib/javax.servlet.jar
wrapper.java.classpath.8=lib/jnet.jar
wrapper.java.classpath.9=lib/mstreaming.jar
wrapper.java.classpath.10=lib/netmonitor.jar
wrapper.java.classpath.11=lib/org.mortbay.jetty.jar
wrapper.java.classpath.12=lib/router.jar
wrapper.java.classpath.13=lib/routerconsole.jar
wrapper.java.classpath.14=lib/sam.jar
wrapper.java.classpath.15=lib/wrapper.jar
wrapper.java.classpath.16=lib/xercesImpl.jar
wrapper.java.classpath.17=lib/xml-apis.jar
wrapper.java.classpath.18=lib/jbigi.jar
# Java Library Path (location of Wrapper.DLL or libwrapper.so)
wrapper.java.library.path.1=.
wrapper.java.library.path.2=lib
# Java Additional Parameters
wrapper.java.additional.1=-DloggerFilenameOverride=logs/log-router-@.txt
# Initial Java Heap Size (in MB)
#wrapper.java.initmemory=4
# Maximum Java Heap Size (in MB)
#wrapper.java.maxmemory=32
# Application parameters. Add parameters as needed starting from 1
wrapper.app.parameter.1=net.i2p.router.Router
#********************************************************************
# Wrapper Logging Properties
#********************************************************************
# Format of output for the console. (See docs for formats)
wrapper.console.format=PM
# Log Level for console output. (See docs for log levels)
wrapper.console.loglevel=INFO
# Log file to use for wrapper output logging.
wrapper.logfile=logs/wrapper.log
# Format of output for the log file. (See docs for formats)
wrapper.logfile.format=LPTM
# Log Level for log file output. (See docs for log levels)
wrapper.logfile.loglevel=INFO
# Maximum size that the log file will be allowed to grow to before
# the log is rolled. Size is specified in bytes. The default value
# of 0, disables log rolling. May abbreviate with the 'k' (kb) or
# 'm' (mb) suffix. For example: 10m = 10 megabytes.
wrapper.logfile.maxsize=1m
# Maximum number of rolled log files which will be allowed before old
# files are deleted. The default value of 0 implies no limit.
wrapper.logfile.maxfiles=2
# Log Level for sys/event log output. (See docs for log levels)
wrapper.syslog.loglevel=NONE
# choose what to do if the JVM kills itself based on the exit code
wrapper.on_exit.default=SHUTDOWN
wrapper.on_exit.0=SHUTDOWN
wrapper.on_exit.1=SHUTDOWN
# OOM
wrapper.on_exit.10=RESTART
# graceful shutdown
wrapper.on_exit.2=SHUTDOWN
# hard shutdown
wrapper.on_exit.3=SHUTDOWN
# the router may take a few seconds to save state, etc
wrapper.jvm_exit.timeout=60
# the router may take a few seconds to save state, etc
wrapper.jvm_exit.timeout=30
# give the OS 30s to clear all the old sockets / etc before restarting
#wrapper.restart.delay=30
# use the wrapper's internal timer thread. otherwise this would
# force a restart of the router during daylight savings time as well
# as any time that the OS clock changes
wrapper.use_system_time=false
#********************************************************************
# Wrapper NT Service Properties
#********************************************************************
# WARNING - Do not modify any of these properties when an application
# using this configuration file has been installed as a service.
# Please uninstall the service before modifying this section. The
# service can then be reinstalled.
# Name of the service
wrapper.ntservice.name=i2p
# Display name of the service
wrapper.ntservice.displayname=I2P Service
# Description of the service
wrapper.ntservice.description=The I2P router service
# Service dependencies. Add dependencies as needed starting from 1
wrapper.ntservice.dependency.1=
# Mode in which the service is installed. AUTO_START or DEMAND_START
wrapper.ntservice.starttype=AUTO_START
# Allow the service to interact with the desktop.
wrapper.ntservice.interactive=true