Skip to content

init file for RPM package is broken (it's Debian-specific) #315

@FlorinAndrei

Description

@FlorinAndrei

Looks like "make rpm" uses the same init.d file as "make deb". The init file works fine on Ubuntu 14.04, but on RPM-based distribution it's completely inadequate. It's missing many files and functions that are Debian-specific, so it quits immediately without doing anything.

I've tested it only on Amazon Linux AMI release 2013.09, which is pretty close to Fedora (v17 I guess), but just looking at the file I can tell it would quit with error on any recent Red Hat compatible distro.

I don't have time to put together a good init file; this is what I use, it's pretty terrible, but it works:

#! /bin/sh
### BEGIN INIT INFO
# Provides:          skeleton
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Example initscript
# Description:       This file should be used to construct scripts to be
#                    placed in /etc/init.d.
### END INIT INFO

# Author: Jordan Sissel <jordan.sissel@dreamhost.com>

# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="log shipper"
NAME=logstash-forwarder
DAEMON=/opt/logstash-forwarder/bin/logstash-forwarder
DAEMON_ARGS="-config /etc/logstash-forwarder -spool-size 100 -log-to-syslog"
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

. /etc/init.d/functions

do_start() {
  echo -n $"Starting $NAME: "
  $DAEMON $DAEMON_ARGS &
  RETVAL=$?
  echo
  [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$NAME
  return $RETVAL
}

do_stop()
{
  echo -n $"Shutting down $NAME: "
  killproc $NAME
  RETVAL=$?
  echo
  [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$NAME
  return $RETVAL
}

case "$1" in
  start)
    do_start
    ;;
  stop)
    do_stop
    ;;
  status)
    status $NAME
    RETVAL=$?
    ;;
  restart)
    do_stop
    do_start
    ;;
  *)
    echo "Usage: $SCRIPTNAME {start|stop|status|restart}" >&2
    exit 3
    ;;
esac

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions