Changeset 848f309 for debian/i2p.init


Ignore:
Timestamp:
Dec 26, 2011 6:42:13 PM (9 years ago)
Author:
kytv <kytv@…>
Branches:
master
Children:
7b49493
Parents:
d9e4c4d
Message:

initscript improvements

  • move router.ping to /var/run/i2p
  • move temp files to /var/tmp/i2p
  • Since gaps are allowed in the numbering with newer wrapper versions, start *.adddional.# numbering at 10
  • redirect errors to stderr
File:
1 edited

Legend:

Unmodified
Added
Removed
  • debian/i2p.init

    rd9e4c4d r848f309  
    22
    33### BEGIN INIT INFO
    4 # Provides:             i2p i2p-router
    5 # Required-Start:       $remote_fs $syslog $named $network $time
    6 # Required-Stop:        $remote_fs $syslog $named $network
    7 # Default-Start:        2 3 4 5
    8 # Default-Stop:         0 1 6
    9 # Short-Description:    start and stop the i2p router
    10 # Description:          i2p is a load-balanced unspoofable packet switching network
     4# Provides: i2p i2p-router
     5# Required-Start: $remote_fs $syslog $named $network $time
     6# Required-Stop: $remote_fs $syslog $named $network
     7# Default-Start: 2 3 4 5
     8# Default-Stop: 0 1 6
     9# Short-Description: start and stop the i2p router
     10# Description: i2p is a load-balanced unspoofable packet switching network
    1111### END INIT INFO
    1212
    1313# Check permissions
    1414if [ "`id -ur`" != '0' ]; then
    15    echo 'Error: you must be root.'
     15   echo 'ERROR: You must be root to start this service.' >&2
    1616   echo
    1717   exit 1
     
    2626JVMPIDFILE="$RUN/routerjvm.pid"
    2727I2P="/usr/share/i2p"
    28 I2PTEMP="/tmp/"
     28I2PTEMP="/var/tmp/$NAME"
    2929WRAPPERLOG="/var/log/i2p/wrapper.log"
    3030
    3131# Don't touch these, edit /etc/default/i2p
    3232RUN_DAEMON="False"
    33 NICE=
     33NICE=0
    3434I2PUSER="i2psvc"
    3535
    3636I2P_ARGS="/etc/i2p/wrapper.config \
    3737 wrapper.java.additional.1=-DloggerFilenameOverride=/var/log/i2p/log-router-@.txt \
    38  wrapper.java.additional.5=-Dwrapper.logfile=$WRAPPERLOG \
     38 wrapper.java.additional.10=-Dwrapper.logfile=$WRAPPERLOG \
     39 wrapper.java.additional.11=-Di2p.dir.pid=$RUN \
     40 wrapper.java.additional.12=-Di2p.dir.temp=$I2PTEMP \
    3941 wrapper.logfile=$WRAPPERLOG \
    4042 wrapper.pidfile=$PIDFILE \
     
    6668
    6769if [ -z "$RUN_DAEMON" ]; then
    68         echo "/etc/default/$NAME is not set. Aborting."
    69         exit 1
     70    echo "/etc/default/$NAME is not properly configured. Aborting." >&2
     71    exit 1
    7072fi
    7173
     
    7779esac
    7880
     81# We need the wrapper. If it's not found, abort.
     82[ -x $DAEMON ] || exit 1
    7983
    80 # is the wrapper from the service-wrapper package even installed?
    81 # if not, bail NOW
    82 
    83 [ -x $DAEMON ] || exit 0
    84 
    85 # Ditto for i2prouter. Even though this script doesn't call it,
    86 # if it's not found the package probably hasn't been installed.
    87 
    88 [ -r /usr/bin/i2prouter ] || exit 0
     84# Even though this script doesn't call it, check for i2prouter.  If it's not
     85# found, it probably means that the package isn't installed anymore.
     86[ -x /usr/bin/i2prouter ] || exit 1
    8987
    9088do_start()
    9189{
    92         start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null\
    93                 || return 1
    94         [ -d $RUN ] || mkdir $RUN
    95         [ -r $PIDFILE ] || touch $PIDFILE
    96         [ -r $JVMPIDFILE ] || touch $JVMPIDFILE
    97         [ -d $I2PTEMP ] || mkdir $I2PTEMP
    98         chown -Rf $I2PUSER:$I2PUSER  $I2PTEMP/*i2p* $I2PTEMP/router.ping $RUN > /dev/null 2>&1
    99         chown -f -R $I2PUSER:adm /var/log/$NAME
    100         TZ=UTC start-stop-daemon --start --quiet -c $I2PUSER --pidfile $PIDFILE --exec $DAEMON $NICE -- \
    101                 $I2P_ARGS || return 2
     90    start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null 2>&1 \
     91        || return 1
     92    [ -d $RUN ] || mkdir $RUN > /dev/null 2>&1
     93    [ -d $I2PTEMP ] || mkdir $I2PTEMP > /dev/null 2>&1
     94    if [ -r $PIDFILE ]; then
     95        PID="$(cat ${PIDFILE})"
     96        if ! kill -0 $PID > /dev/null 2>&1; then
     97                rm "$PIDFILE" "$JVMPIDFILE"
     98        else
     99                # we shouldn't get here, but...
     100                echo "ERROR: Another instance of $DESC is already running." >&2
     101                return 1
     102        fi
     103    fi
     104    chown -Rf $I2PUSER:$I2PUSER  $I2PTEMP $RUN > /dev/null 2>&1
     105    chown -f -R $I2PUSER:adm /var/log/$NAME > /dev/null 2>&1
     106    TZ=UTC start-stop-daemon --start --quiet -c $I2PUSER --pidfile $PIDFILE --exec $DAEMON -n $NICE -- \
     107        $I2P_ARGS || return 2
    102108}
    103109
    104110do_stop()
    105111{
    106         start-stop-daemon --stop --quiet --retry=TERM/15/KILL/5 --pidfile $PIDFILE -u $I2PUSER
    107         RETVAL="$?"
    108         [ "$RETVAL" = 2 ] && return 2
     112    start-stop-daemon --stop --quiet --retry=TERM/60/KILL/20 --pidfile $PIDFILE -u $I2PUSER
     113    RETVAL="$?"
     114    [ "$RETVAL" = 2 ] && return 2
    109115
    110 #       start-stop-daemon --stop --quiet --oknodo --retry=TERM/15/KILL/5 -u $I2PUSER
     116    start-stop-daemon --stop --quiet --oknodo --retry=0/60/KILL/20 --exec $DAEMON
    111117
    112         start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
    113 
    114         rm -f "$PIDFILE" "$JVMPIDFILE"
    115         [ -d $RUN ] && rmdir $RUN
     118    rm -rf "$I2PTEMP" > /dev/null 2>&1
     119    [ -d "$RUN" ] && rmdir "$RUN" 2>&1
    116120}
    117121
    118122do_dump()
    119123{
    120         start-stop-daemon --stop --quiet -s 3 --pidfile $PIDFILE -u $I2PUSER
    121         RETVAL="$?"
    122         [ "$RETVAL" = 2 ] && return 2
     124    start-stop-daemon --stop --quiet -s 3 --pidfile $PIDFILE -u $I2PUSER
     125    RETVAL="$?"
     126    [ "$RETVAL" = 2 ] && return 2
    123127}
    124128
     
    141145        ;;
    142146  stop)
    143         log_daemon_msg "Stopping $DESC" "$NAME"
     147    log_daemon_msg "Stopping $DESC" "$NAME"
    144148        do_stop
    145149        case "$?" in
     
    150154  status)
    151155       status_of_proc -p $PIDFILE "$DAEMON" "$NAME" && exit 0 || exit $?
    152         ;;
     156    ;;
    153157 restart|force-reload)
    154158        log_daemon_msg "Restarting $DESC" "$NAME"
     
    170174        ;;
    171175*)
    172         N=/etc/init.d/$NAME
    173         echo "Usage: $N {start|stop|dump|status|restart|force-reload}" >&2
    174         exit 3
    175         ;;
     176    N=/etc/init.d/$NAME
     177    echo "Usage: $N {start|stop|dump|status|restart|force-reload}" >&2
     178    exit 3
     179    ;;
    176180
    177181
Note: See TracChangeset for help on using the changeset viewer.