--- /etc/init.d/rbot.bac 2009-12-27 00:24:22.000000000 -0500 +++ /etc/init.d/rbot 2009-12-27 00:40:41.000000000 -0500 @@ -3,6 +3,19 @@ # Distributed under the terms of the GNU General Public License v2 # $Header: /var/cvsroot/gentoo-x86/net-irc/rbot/files/rbot.init,v 1.1 2007/11/19 13:56:54 flameeyes Exp $ +ruby_getname() { + # for a series of reason, we can't rely on the process being started + # with 'ruby' name. As using ruby18 would break for ruby 1.9, get the + # linked name to use as rubyname. + RUBY="$(readlink /usr/bin/ruby)" + if [ -x "${RUBY}" ]; then + RUBYNAME="$(basename "${ruby}")" + else + RUBYNAME=${RUBY} + RUBY=/usr/bin/${RUBY} + fi +} + depend() { need net use dns @@ -23,17 +36,14 @@ return 1 fi - # for a series of reason, we can't rely on the process being started - # with 'ruby' name. As using ruby18 would break for ruby 1.9, get the - # linked name to use as rubyname. - ruby="$(readlink /usr/bin/ruby)" + ruby_getname export USER="${RBOTUSER%%:*}" export HOME="/dev/null" ebegin "Starting rbot" start-stop-daemon \ --start \ - --exec "/usr/bin/${ruby}" --name "${ruby}" \ + --exec "${RUBY}" --name "${RUBYNAME}" \ --pidfile "${RBOTDIR}/rbot.pid" \ --chuid "${RBOTUSER}" \ -- /usr/bin/rbot --background "${RBOTDIR}" @@ -41,14 +51,11 @@ } stop() { - # for a series of reason, we can't rely on the process being started - # with 'ruby' name. As using ruby18 would break for ruby 1.9, get the - # linked name to use as rubyname. - ruby="$(readlink /usr/bin/ruby)" + ruby_getname ebegin "Stopping rbot" start-stop-daemon --stop \ - --exec "/usr/bin/${ruby}" \ + --exec "${RUBY}" \ --pidfile "${RBOTDIR}/rbot.pid" \ --user "${RBOTUSER%%:*}" eend $?