#!/bin/sh # Start/stop i2p service. i2p_start() { # Check if router is up first! /bin/su - -c "( export PATH=\"$PATH:/usr/lib/java/bin:/usr/lib/java/jre/bin\"; directory status )" > /dev/null if [ $? -eq 0 ] ; then { # I2p is already running, so tell the user. echo "I2P is already running..." i2p_status } else { # Just in-case there are leftover junk in /tmp... rm -Rf `grep /tmp/hsperfdata_root/* -le i2p` /tmp/i2p-*.tmp /tmp/router.ping # Now that all junk is cleaned up, start. /bin/su - -c "( export PATH=\"$PATH:/usr/lib/java/bin:/usr/lib/java/jre/bin\"; directory start )" } fi } i2p_stop() { /bin/su - -c "( export PATH=\"$PATH:/usr/lib/java/bin:/usr/lib/java/jre/bin\"; directory stop )" rm -Rf `grep /tmp/hsperfdata_root/* -le i2p` /tmp/i2p-*.tmp /tmp/router.ping } i2p_restart() { # We want a FULL cycle here, not the wrappers idea of this! i2p_stop i2p_start } i2p_status() { /bin/su - -c "( export PATH=\"$PATH:/usr/lib/java/bin:/usr/lib/java/jre/bin\"; directory status )" } i2p_console() { /bin/su - -c "( export PATH=\"$PATH:/usr/lib/java/bin:/usr/lib/java/jre/bin\"; directory console )" } i2p_dump() { /bin/su - -c "( export PATH=\"$PATH:/usr/lib/java/bin:/usr/lib/java/jre/bin\"; directory dump )" } case "$1" in 'start') i2p_start ;; 'stop') i2p_stop ;; 'restart') i2p_restart ;; 'status') i2p_status ;; 'console') i2p_console ;; 'dump') i2p_dump ;; *) echo "usage $0 start|stop|restart|status|console|dump" ;; esac