3

I am running Raspbian on my raspberry pi.

I downloaded and installed the custom drivers from Realtek for my wifi dongle

After compiling and moving the binary created to /usr/sbin/ I saw that I could not call service hostapd start as it returned **hostapd: unrecognized service **

I was told that I must create a init.d script for this and place it in the /etc/init.d/ folder

I decided to look at another init.d script for a program called dhcpd, the file contents are

#!/bin/sh
#
### BEGIN INIT INFO
# Provides:          dhcpcd
# Required-Start:    $local_fs
# Required-Stop:     $local_fs
# Should-Start:
# Should-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: IPv4 DHCP client with IPv4LL support
# Description:
### END INIT INFO

PATH=/sbin:/bin
DHCPCD=/sbin/dhcpcd
NAME=dhcpcd
PIDFILE=/var/run/dhcpcd.pid

test -x $DHCPCD || exit 0

INTERFACES=/etc/network/interfaces

. /lib/lsb/init-functions

sanity()
{
        local x=

        case "$($DHCPCD --version)" in
        [1234].*)
                log_failure_msg "Not running $NAME because an older version" \
                        "is currently preferred"
                exit 6
        esac

        for x in /var/run/dhcpcd-*.pid; do
                [ -f "$x" ] || continue
                log_failure_msg "Not running $NAME because there is aleady an" \
                        "interface specific instance"
                log_failure_msg "$x"
                exit 6
        done

        if grep -q "^[[:space:]]*iface[[:space:]]*.*[[:space:]]*inet[[:space:]]*dhcp" \
        $INTERFACES; then
                log_failure_msg "Not running $NAME because $INTERFACES"
                log_failure_msg "defines some interfaces that will use a" \
                        "DHCP client"
                exit 6
        fi
}

case "$1" in
start)
        sanity
        if pidofproc -p $PIDFILE $DHCPCD >/dev/null; then
                log_warning_msg "$NAME is already running"
                exit 0
        fi
        $DHCPCD
        ;;
stop)
        sanity
        $DHCPCD -x
        ;;
restart|force-reload)
        sanity
        $DHCPCD -x
        $DHCPCD
        ;;
try-restart)
        if ! pidofproc -p $PIDFILE $DHCPCD >/dev/null; then
                log_warning_msg "$NAME is not running"
        else
                sanity
                $DHCPCD -x
                $DHCPCD
        fi
        ;;
reload)
        if ! pidofproc -p $PIDFILE $DHCPCD >/dev/null; then
                log_failure_msg "$NAME is not running"
                exit 7
        fi
        sanity
        $DHCPCD -n
        ;;
status)
        status_of_proc -p $PIDFILE $DHCPCD "$NAME" || exit $?
        ;;
*)
        log_failure_msg "Usage: /etc/init.d/dhcpcd {start|stop|restart|try-restart|force-reload|status}"
        exit 1
        ;;
esac

It SURELY cannot be the case that the user is expected to create a init.d file for a binary just compiled? And even if they do what are the chances of the integrity of all the if statments and msg outputs being accurate?

Have I missed something here? is there a common filename/location for init.d scripts within the package.zip file prior to calling make?

A file that specific should be written by somebody who has a good understanding of the binary...

1

Not all linux distros use the same kind of init scripts. Even for distros that ostensibly used SysV init system had shell functions that were distro-specific.

Also, there's a 'hostapd' package in raspbian that includes a hostapd init script, perhaps that might be what you should be using anyway.

  • the hostapd package doesnt work with alot of chipsets on the market today, which is why realtek released there own, perhaps if distros dont use the same kind of init scripts a abstract should be created..., starting and stopping a service is essential, so leaving it out completly is just idiotic..., I am planning to use the init.d script from the debian hostapd, however it wudnt surprise me if its missing certain things... – buntybudia Sep 12 '15 at 13:47
  • Sorry, I should have indicated that you should start with the init script from the 'hostapd' package, not use the package instead of the realtek driver. Unsurprisingly, a lot of distros got fed up with the lack of portability with init scripts, and so that's why we have Upstart and systemd. – jsbillings Sep 12 '15 at 14:06
  • Yes that was what I thought you mean, however I did move my realtek hostapd file into the position of the raspbian hostapd, now when running service hostapd status I do not get the unrecognized response but none at all. What could this point to? – buntybudia Sep 12 '15 at 14:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.