Bosse_B
Posts: 836
Joined: Thu Jan 30, 2014 9:53 am

How to enable, start and stop a service in Jessie?

Mon Nov 16, 2015 11:05 pm

I am setting up a WiFi AP on an RPi2B running Raspbian Jessie.
The tutorials are OK so far but now I have come to the end and one item remains:
Getting the two services running on boot.
In the tutorials for Wheezy they say that I should do this:

Code: Select all

sudo service hostapd start
sudo service isc-dhcp-server start

sudo service hostapd status
sudo service isc-dhcp-server status

sudo update-rc.d hostapd enable
sudo update-rc.d isc-dhcp-server enable 
But I am pretty sure that since Jessie uses systemctl these commands have another format.
Can someone please help me out here?
It is the last step on the ladder, I can run the hostapd manually and it works as intended, but I do not want to reboot the Pi until I have fixed this issue first.
Thanks.
Bo Berglund
Sweden

stderr
Posts: 2178
Joined: Sat Dec 01, 2012 11:29 pm

Re: How to enable, start and stop a service in Jessie?

Tue Nov 17, 2015 1:22 am

Bosse_B wrote:But I am pretty sure that since Jessie uses systemctl these commands have another format.
I think that systemd is still half baked. I've got an x86 machine that I'm booting off a flash drive and it will blow up if I go straight to X but it will work fine if I go to a command line and then type startx. This problem also occurs on another machine I used the same flash drive on. I was, however, able to make the needed changes to get it to stay booting to the command line, so stuff is possible!

User avatar
AndyD
Posts: 2333
Joined: Sat Jan 21, 2012 8:13 am
Location: Melbourne, Australia
Contact: Website

Re: How to enable, start and stop a service in Jessie?

Tue Nov 17, 2015 1:30 am

I believe the init.d services still work on Jessie. The one I use works for me.

There is a thread called VNC server in Jessie (using a systemd service) that may be of interest.
Last edited by AndyD on Tue Nov 17, 2015 8:33 pm, edited 1 time in total.

Bosse_B
Posts: 836
Joined: Thu Jan 30, 2014 9:53 am

Re: How to enable, start and stop a service in Jessie?

Tue Nov 17, 2015 4:25 pm

I went ahead and used the commands from the AdaFruit tutorial (towards the end) to make the hostapd run as a service.
But it did not work at once, I had to try it again a few times and then it came on line.
This is what I did:

Code: Select all

sudo service hostapd start
sudo service isc-dhcp-server start
sudo update-rc.d hostapd enable
sudo update-rc.d isc-dhcp-server enable
There was no error or other message when I used these commands, but the AP did not come on-line at first.
When it was running I used the status command to check the service and I got this:

Code: Select all

[email protected] ~/hostapd $ sudo service hostapd status
● hostapd.service - LSB: Advanced IEEE 802.11 management daemon
   Loaded: loaded (/etc/init.d/hostapd)
   Active: active (running) since Tue 2015-11-17 17:12:36 CET; 8min ago
  Process: 21316 ExecStop=/etc/init.d/hostapd stop (code=exited, status=0/SUCCESS)
  Process: 21489 ExecStart=/etc/init.d/hostapd start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/hostapd.service
           └─21493 /usr/sbin/hostapd -B -P /run/hostapd.pid /etc/hostapd/hostapd.conf

Nov 17 17:12:36 rpi2-jessie hostapd[21489]: Starting advanced IEEE 802.11 management: hostapdioctl[RTL_IOCTL_HOSTAPD]: Invalid argument
Nov 17 17:12:36 rpi2-jessie hostapd[21489]: .
Nov 17 17:12:36 rpi2-jessie systemd[1]: Started LSB: Advanced IEEE 802.11 management daemon.
Nov 17 17:14:54 rpi2-jessie hostapd[21493]: wlan0: STA 38:0b:40:db:5b:0d IEEE 802.11: associated
Nov 17 17:14:54 rpi2-jessie hostapd[21493]: wlan0: STA 38:0b:40:db:5b:0d WPA: pairwise key handshake completed (RSN)
Nov 17 17:19:09 rpi2-jessie hostapd[21493]: wlan0: STA 38:0b:40:db:5b:0d IEEE 802.11: disassociated
What does the "Invalid argument" at 17:12:36 top line mean?

I have as yet not rebooted the Pi2 to see if the AP comes up automatically or not, this is the next task...

EDIT: After reboot
It all works! I can connect to the WiFi AP just fine after a "sudo shutdown -r now" command! :)
Bo Berglund
Sweden

Return to “Raspbian”