From 65b1124d81e58599e50e2535059d4d40529ddc27 Mon Sep 17 00:00:00 2001 From: kytv Date: Thu, 19 Sep 2013 20:56:56 +0000 Subject: [PATCH] various updates to `i2prouter` - check status of i2psvc with ldd - only warn about libiconv in FreeBSD if the package isn't installed. In recent versions of FreeBSD, OpenJDK depends on libiconv so it should always be available. --- debian/patches/0001-path-substitution.patch | 67 ++++++++++++--------- installer/resources/i2prouter | 35 ++++++----- 2 files changed, 61 insertions(+), 41 deletions(-) diff --git a/debian/patches/0001-path-substitution.patch b/debian/patches/0001-path-substitution.patch index 940667df0..6ffa649be 100644 --- a/debian/patches/0001-path-substitution.patch +++ b/debian/patches/0001-path-substitution.patch @@ -71,10 +71,13 @@ Debian wrapper.config to try to prevent confusion. # Priority at which to run the wrapper. See "man nice" for valid priorities. # nice is only used if a priority is specified. -@@ -175,48 +166,6 @@ - # Workaround for Gentoo - JAVABINARY=$(awk -F'=' '/^ *wrapper\.java\.command/{print $2}' "$WRAPPER_CONF") +@@ -172,64 +163,6 @@ + exit 1 + fi +-# Workaround for Gentoo +-JAVABINARY=$(awk -F'=' '/^ *wrapper\.java\.command/{print $2}' "$WRAPPER_CONF") +- -if [ -e /etc/gentoo-release ]; then - if [ $JAVABINARY = java ]; then - if [ -x /etc/java-config-2/current-system-vm/bin/java ]; then @@ -103,44 +106,54 @@ Debian wrapper.config to try to prevent confusion. - echo "**`gettext 'Failed to load the wrapper'`**" - case `uname -s` in - FreeBSD) -- echo -- echo "The wrapper requires libiconv to be on your system." -- echo "It can be installed with pkg_add -r libiconv" -- echo -- exit 1 +- # We should never get here on recent versions of FreeBSD +- if ! $(pkg_info -E 'libiconv*' > /dev/null 2>&1); then +- echo +- echo "The wrapper requires libiconv." +- echo +- echo "It can be installed with pkg_add -r libiconv" +- echo +- fi - ;; - *) - echo - unsupported -- exit 1 - ;; - esac +- exit 1 -} +- +-if $(which ldd > /dev/null 2>&1); then +- # This should cover every *NIX other than OSX since OSX doesn't have ldd. +- # OSX has otool. Is otool on every OSX installation? Is otool's output the same as ldd's? +- # The wrapper we ship for OSX are for PPC and Intel, so maybe we don't need to worry about OSX? +- if (ldd "$WRAPPER_CMD" |grep -q 'not found') > /dev/null 2>&1 || \ +- ! (ldd "$WRAPPER_CMD" > /dev/null 2>&1); then +- failed +- fi +-fi - if [ -n "$FIXED_COMMAND" ] then COMMAND="$FIXED_COMMAND" -@@ -928,9 +877,6 @@ +@@ -940,7 +873,7 @@ + # The string passed to eval must handles spaces in paths correctly. COMMAND_LINE="$CMDNICE \"$WRAPPER_CMD\" \"$WRAPPER_CONF\" wrapper.syslog.ident=\"$APP_NAME\" wrapper.java.command=\"$JAVABINARY\" wrapper.pidfile=\"$PIDFILE\" wrapper.name=\"$APP_NAME\" wrapper.displayname=\"$APP_LONG_NAME\" $ANCHORPROP $STATUSPROP $COMMANDPROP $LOCKPROP $LOGPROP wrapper.script.version=3.5.20 $ADDITIONAL_PARA" - eval $COMMAND_LINE -- if [ "$?" -ne "0" ]; then -- failed -- fi +- eval $COMMAND_LINE || failed ++ eval $COMMAND_LINE else eval echo `gettext '$APP_LONG_NAME is already running.'` exit 1 -@@ -1054,9 +1000,6 @@ - # The string passed to eval must handles spaces in paths correctly. - COMMAND_LINE="$CMDNICE \"$WRAPPER_CMD\" \"$WRAPPER_CONF\" wrapper.syslog.ident=\"$APP_NAME\" wrapper.java.command=\"$JAVABINARY\" wrapper.pidfile=\"$PIDFILE\" wrapper.name=\"$APP_NAME\" wrapper.displayname=\"$APP_LONG_NAME\" wrapper.daemonize=TRUE $ANCHORPROP $IGNOREPROP $STATUSPROP $COMMANDPROP $LOCKPROP $LOGPROP wrapper.script.version=3.5.20 $ADDITIONAL_PARA" - eval $COMMAND_LINE -- if [ "$?" -ne "0" ]; then -- failed -- fi - else - eval echo `gettext '$APP_LONG_NAME is already running.'` - exit 1 -@@ -1793,7 +1736,7 @@ +@@ -997,7 +930,6 @@ + if [ "X$pid" = "X" ] + then + eval echo " `gettext 'WARNING: $APP_LONG_NAME may have failed to start.'`" +- failed + else + eval echo ' running: PID:$pid' + fi +@@ -1800,7 +1732,7 @@ } showsetusermesg() { @@ -149,7 +162,7 @@ Debian wrapper.config to try to prevent confusion. } checkifstartingasroot() { -@@ -1801,7 +1744,7 @@ +@@ -1808,7 +1740,7 @@ echo "`gettext 'Running I2P as the root user is *not* recommended.'`" showsetusermesg echo @@ -158,7 +171,7 @@ Debian wrapper.config to try to prevent confusion. exit 1 fi } -@@ -1866,24 +1809,10 @@ +@@ -1873,24 +1805,10 @@ status ;; diff --git a/installer/resources/i2prouter b/installer/resources/i2prouter index 30ed01a17..e614bd7e7 100644 --- a/installer/resources/i2prouter +++ b/installer/resources/i2prouter @@ -203,20 +203,33 @@ failed() { echo "**`gettext 'Failed to load the wrapper'`**" case `uname -s` in FreeBSD) - echo - echo "The wrapper requires libiconv to be on your system." - echo "It can be installed with pkg_add -r libiconv" - echo - exit 1 + # We should never get here on recent versions of FreeBSD + if ! $(pkg_info -E 'libiconv*' > /dev/null 2>&1); then + echo + echo "The wrapper requires libiconv." + echo + echo "It can be installed with pkg_add -r libiconv" + echo + fi ;; *) echo unsupported - exit 1 ;; esac + exit 1 } +if $(which ldd > /dev/null 2>&1); then + # This should cover every *NIX other than OSX since OSX doesn't have ldd. + # OSX has otool. Is otool on every OSX installation? Is otool's output the same as ldd's? + # The wrapper we ship for OSX are for PPC and Intel, so maybe we don't need to worry about OSX? + if (ldd "$WRAPPER_CMD" |grep -q 'not found') > /dev/null 2>&1 || \ + ! (ldd "$WRAPPER_CMD" > /dev/null 2>&1); then + failed + fi +fi + if [ -n "$FIXED_COMMAND" ] then COMMAND="$FIXED_COMMAND" @@ -927,10 +940,7 @@ console() { # The string passed to eval must handles spaces in paths correctly. COMMAND_LINE="$CMDNICE \"$WRAPPER_CMD\" \"$WRAPPER_CONF\" wrapper.syslog.ident=\"$APP_NAME\" wrapper.java.command=\"$JAVABINARY\" wrapper.pidfile=\"$PIDFILE\" wrapper.name=\"$APP_NAME\" wrapper.displayname=\"$APP_LONG_NAME\" $ANCHORPROP $STATUSPROP $COMMANDPROP $LOCKPROP $LOGPROP wrapper.script.version=3.5.20 $ADDITIONAL_PARA" - eval $COMMAND_LINE - if [ "$?" -ne "0" ]; then - failed - fi + eval $COMMAND_LINE || failed else eval echo `gettext '$APP_LONG_NAME is already running.'` exit 1 @@ -987,7 +997,7 @@ startwait() { if [ "X$pid" = "X" ] then eval echo " `gettext 'WARNING: $APP_LONG_NAME may have failed to start.'`" - exit 1 + failed else eval echo ' running: PID:$pid' fi @@ -1054,9 +1064,6 @@ start() { # The string passed to eval must handles spaces in paths correctly. COMMAND_LINE="$CMDNICE \"$WRAPPER_CMD\" \"$WRAPPER_CONF\" wrapper.syslog.ident=\"$APP_NAME\" wrapper.java.command=\"$JAVABINARY\" wrapper.pidfile=\"$PIDFILE\" wrapper.name=\"$APP_NAME\" wrapper.displayname=\"$APP_LONG_NAME\" wrapper.daemonize=TRUE $ANCHORPROP $IGNOREPROP $STATUSPROP $COMMANDPROP $LOCKPROP $LOGPROP wrapper.script.version=3.5.20 $ADDITIONAL_PARA" eval $COMMAND_LINE - if [ "$?" -ne "0" ]; then - failed - fi else eval echo `gettext '$APP_LONG_NAME is already running.'` exit 1