You are not logged in.

#1 2014-09-16 10:29:34

almandin
Member
Registered: 2014-02-23
Posts: 31

Script executing one time only at boot

Hello there ,

I'd like to write a script that allow me to connect my wifi with wpa_supplicant automatically when the computer boot.
I even have that script, but I usually launch it myself when I log in.

I have some issues doing this, that's why I ask for some help here !

I can use my .bash_profile to do it isn't it ?

Can't I do something like that ?


.bash_profile :


if [[ $wifi != 1 ]]
then
        mywifiscript
        wifi = 1
        export wifi #I don't want this script to be executed each time i log me on other TTY
fi



thanks a lot for your answers !

(I hope I'm on the right section, and I'm not native english, sorry for your eyes !)

Offline

#2 2014-09-16 11:10:20

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: Script executing one time only at boot

The best way to launch it would be to make a systemd service file.

The excerpt from your bash_profile will not work as intended.  That will run every time the bash_profile is read on a new login.  Exporting your 'wifi' variable only makes that variable available to child processes, not other logins.

However, I'm curious what's actually in your script.  There is a wpa_supplicant service file already (I think), or if you just enable dhcpcd service, it will automatically start wpa_supplicant as needed.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2014-09-16 11:10:45

stqn
Member
Registered: 2010-03-19
Posts: 1,191
Website

Re: Script executing one time only at boot

Well have you tried it?

(Please use [ code ] … [ /code ] around your code.)

Personally I have a /etc/rc.local file to do that kind of stuff, but since systemd happened this functionnality has been removed (it was too easy and useful so "they" decided to remove it, I guess).

Also, why don’t you use netctl? Works mostly fine here.

Offline

Board footer

Powered by FluxBB