You are not logged in.

#1 2012-12-27 21:08:04

oysteijo
Member
Registered: 2012-12-27
Posts: 9

[SOLVED] systemd and wifi on my laptop

Hi,

I've just converted from initscripts to systemd, and I've managed to get most of the DAEMONS array over to systemd, but I still have a problem with the wireless connection.
I used to have a /etc/rc.local file with the following content:

#!/bin/bash
#
# /etc/rc.local: Local multi-user startup script.
#
ip link set wlan0 up
wpa_supplicant -B -Dwext -i wlan0 -c /etc/wpa_supplicant.conf 
dhcpcd wlan0 > /dev/null

So, after scratching my head for a while, and trying to figure out how systemd really works (which I still haven't fully worked out), I hope someone could tell me where to put these three lines of code in a systemd init. So far I've only manually executed the rc.local.pacsave file as root at every startup.

Thanks,
Øystein

Last edited by oysteijo (2012-12-31 20:23:29)

Offline

#2 2012-12-27 21:43:46

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 13,826

Re: [SOLVED] systemd and wifi on my laptop

I cheat.  This is not the published way of doing things, but I like it.

I created a service to run a script at startup.  Here are the script and service.  Remember to make the script executable:

ewaller@odin:~ 1012 %cat /usr/lib/systemd/system/local.service
[Unit]
Description= local startup and shutdown

[Service]
Type=simple
ExecStart=/usr/local/bin/startup

[Install]
WantedBy=multi-user.target
ewaller@odin:~ 1013 %cat /usr/local/bin/startup          
#!/bin/bash
#
# /etc/rc.local: Local multi-user startup script.
#


hdparm -B 254 /dev/sda
setkeycodes e042 234
cpufreq-set -c0 -g ondemand
cpufreq-set -c1 -g ondemand
ewaller@odin:~ 1014 %

On my system, I set some keycodes, configure cpu-freq, and tell my drive not to park the heads all the time.  You would replace my commands with yours.

Last edited by ewaller (2012-12-27 21:44:39)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
You assume people are rational and influenced by evidence.  You must not work with the public much. -- Trilby
----
How to Ask Questions the Smart Way

Online

#3 2012-12-27 21:44:03

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 14,803
Website

Re: [SOLVED] systemd and wifi on my laptop

If you don't want to use one of the ready made services like netcfg you can make your own service file to run a script with those three commands.

EDIT: I was about to edit and add an example ... but one snuck in just above my post.

Last edited by Trilby (2012-12-27 21:45:08)


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#4 2012-12-27 22:11:32

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: [SOLVED] systemd and wifi on my laptop

I can never understand why people don't just use netcfg....

Offline

#5 2012-12-27 23:29:23

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,412

Re: [SOLVED] systemd and wifi on my laptop

@tomk, that is what I was thinking... its all the work already done for you. 

@ewaller, you still use cpufreq?  I don't know about cpufreq, but since it has been replaced by cpupower, there is actually a service file you can use to set the governor (and a config).  But ondemand is actually used by default, so there is no need to specify it anymore.  As for the hdparm command, I had previously set up a udev rule for that, so that it would set "-B 254" to any disks that were rotational, since it is obviously rather pointless to set this on a SSD.

Offline

#6 2012-12-27 23:56:58

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 13,826

Re: [SOLVED] systemd and wifi on my laptop

WonderWoofy wrote:

@ewaller, you still use cpufreq?  I don't know about cpufreq, but since it has been replaced by cpupower, there is actually a service file you can use to set the governor (and a config).  But ondemand is actually used by default, so there is no need to specify it anymore.

Yeah, I do.  Heck, I set that up when we were just starting the change over to systemd.  It has not broken yet, so I've had no reason to revisit it.  At the time, it was not the default.  Anyway, the system behaves exactly as I want; I usually use excursions from that norm as impetuous to go fix things smile

As for the hdparm command, I had previously set up a udev rule for that, so that it would set "-B 254" to any disks that were rotational, since it is obviously rather pointless to set this on a SSD.

That would be a bit silly.  I never even considered using a udev rule.  I guess I've been around *nix for so long, I never bothered to learn the intricacies of udev; I learned just enough to get my system to behave.

I've some learning to do.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
You assume people are rational and influenced by evidence.  You must not work with the public much. -- Trilby
----
How to Ask Questions the Smart Way

Online

#7 2012-12-30 23:31:12

oysteijo
Member
Registered: 2012-12-27
Posts: 9

Re: [SOLVED] systemd and wifi on my laptop

Thanks for all your answers so far, but I now got into deeper problems. I'm trying to implement ewallers suggested solution.

# cat /usr/lib/systemd/system/local.service
[Unit]
Description= local startup and shutdown

[Service]
Type=simple
ExecStart=/usr/local/bin/wireless-startup

[Install]
WantedBy=multi-user.target

and:

# cat /usr/local/bin/wireless-startup
#!/bin/bash
#
# /etc/rc.local: Local multi-user startup script.
# /usr/local/bin/wireless-startup: Local multi-user startup script.
#
ip link set wlan0 up
wpa_supplicant -B -Dwext -i wlan0 -c /etc/wpa_supplicant.conf 
dhcpcd wlan0 > /dev/null

To my big surprise this did not work. It looks to me that dhcpcd is terminated just after it's started. Why? Howcome?

# systemctl status local
local.service - local startup and shutdown
	  Loaded: loaded (/usr/lib/systemd/system/local.service; enabled)
	  Active: inactive (dead) since Sun, 2012-12-30 15:01:04 CET; 1h 0min ago
	 Process: 285 ExecStart=/usr/local/bin/wireless-startup (code=exited, status=0/SUCCESS)
	  CGroup: name=systemd:/system/local.service

Dec 30 15:00:59 oysteins-laptop dhcpcd[324]: wlan0: acknowledged 10.0.0.4 from 10.0.0.138 `P2602HWT'
Dec 30 15:00:59 oysteins-laptop wireless-startup[285]: dhcpcd[324]: wlan0: checking for 10.0.0.4
Dec 30 15:00:59 oysteins-laptop dhcpcd[324]: wlan0: checking for 10.0.0.4
Dec 30 15:01:03 oysteins-laptop wireless-startup[285]: dhcpcd[324]: wlan0: sending IPv6 Router Solicitation
Dec 30 15:01:03 oysteins-laptop dhcpcd[324]: wlan0: sending IPv6 Router Solicitation
Dec 30 15:01:04 oysteins-laptop wireless-startup[285]: dhcpcd[324]: wlan0: leased 10.0.0.4 for 259200 seconds
Dec 30 15:01:04 oysteins-laptop dhcpcd[324]: wlan0: leased 10.0.0.4 for 259200 seconds
Dec 30 15:01:04 oysteins-laptop wireless-startup[285]: dhcpcd[324]: forked to background, child pid 368
Dec 30 15:01:04 oysteins-laptop dhcpcd[368]: received SIGTERM, stopping
Dec 30 15:01:04 oysteins-laptop dhcpcd[368]: wlan0: removing interface

Thanks for any input?
-Øystein

.... maybe I should consider netcfg....?

Offline

#8 2012-12-30 23:55:00

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 14,803
Website

Re: [SOLVED] systemd and wifi on my laptop

I recently faced the vary same problem here but in a compiled connection tool rather than a script.

For me the solution was to change to "Type=forking" in the service file and to use fork() and execvp() in the code when dhcpcd was launched.

You may be able to replicate the latter half in your bash script with nohup, but I'm not sure - I also had trouble with systemd killing nohup child processes.


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#9 2012-12-31 00:22:57

oysteijo
Member
Registered: 2012-12-27
Posts: 9

Re: [SOLVED] systemd and wifi on my laptop

Thanks!

I just changed Type=simple to Type=forking, and everything now seems to work. (dhcpcd is forking natively) Thanks everyone!

-Øystein
[SOLVED] How do I add [SOLVED] to the topic? I'll read the Newbee forum again....

Offline

#10 2012-12-31 00:38:33

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 5,675

Re: [SOLVED] systemd and wifi on my laptop

Edit the subject of your first post...


How To Ask Questions The Smart Way | Help Vampires

Arch Linux | x86_64 | GPT | EFI boot | grub2 | systemd | LVM2 on LUKS
Lenovo x121e | Intel(R) Core(TM) i3-2367M CPU @ 1.40GHz GenuineIntel | Intel Centrino Wireless-N 1000 | US keyboard with Euro | 320G 7200 RPM Seagate HDD

Offline

Board footer

Powered by FluxBB