Running bash script at boot?

I am testing 12.2, and have to run “modprobe -r brcmsmac” and “modprobe brcmsmac” at each boot for my broadcom card to work. I created simple bash script (owned by root/777), but can’t seem to get it to work. 12.1/12.2 and systemd handle things differently. /etc/rc.d/before.local didn’t work, and just adding it to the KDE startup items doesn’t work. Does it matter that I put it in /usr/bin? Just running it as root after boot works great. How do I make this thing run?

#! /bin/bash
# script to load and unload brcmsmac
modprobe -r brcmsmac
modprobe brcmsmac

On 2012-06-03 23:06, 67GTA wrote:

> boot works great. How do I make this thing run?

Use root’s cron. @reboot clause (man 5 crontab).


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

Check out how I got the after.local bash script to work with systemd where you could put your command or create another in the same manner.

systemd and using the after.local script in openSUSE 12.1 - Blogs - openSUSE Forums

Thank You,

Thanks for the suggestions. Both approaches work, but I think it seems to be more of a timing issue. I found systemd-gtk in the package manager. It shows the after.local service has executed and exited, but the wireless still doesn’t work. If I click the “restart” button in systemadm, it reruns the commands, and the wireless starts working. I guess this needs to happen after the card is brought up. I need to read up on systemd to see if there is an equivalent to the sysvinit run levels. Hopefully this bug will get fixed soon!

But actually, the after.local bash script does not work at all by default in openSUSE 12.1. If you follow my blog, you will see how you can get it to work properly.

Thank You,

I actually did use your how to to get it going. Nice write up! It still didn’t work, even though the commands are being ran, I think they are being ran too early before the card is initialised.

So you could create your own systemd service, for a bash script, to be loaded after the graphics system has been loaded for instance.

Thank You,

On 2012-06-04 00:56, jdmcdaniel3 wrote:
> ‘systemd and using the after.local script in openSUSE 12.1 - Blogs -
> openSUSE Forums’ (http://tinyurl.com/6r8hxpd)

When exactly does this run? At the start of services or the end?
I ask because I do not see the “After=” clause in your file, so I don’t
clearly see where it does execute. But I know very little about systemD, so
I could easily miss something else.

In systemV there are two similar scripts: boot.local runs at the start,
before any level script runs; and after.local, which runs after all service
scripts have finished.


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

Neither. That’s why it doesn’t always work as expected. See my post here:
http://forums.opensuse.org/english/other-forums/development/programming-scripting/469832-running-commands-depend-process-being-started-after-local.html

I mean, the script will work but whether some services will be started as the script is executed is not guaranteed. If the commands in your after.local need these services, they will fail. So I have to use this trick to mount fileservers. I have similar issues under Fedora btw.

When nothing works the way it is supposed to, I end up adding a sleep command in after.local. :open_mouth:

On 2012-06-04 16:06, please try again wrote:
>
> robin_listas;2467254 Wrote:

>> When exactly does this run? At the start of services or the end?
>>
>
> Neither. That’s why it doesn’t always work as expected. See my post
> here:
> http://tinyurl.com/7lhwutx

With a comment from me…

> I mean, the script will work but whether some services will be started
> as the script is executed is not guaranteed. If the commands in your
> after.local need these services, they will fail. So I have to use this
> trick to mount fileservers. I have similar issues under Fedora btw.
>
> When nothing works the way it is supposed to, I end up adding a sleep
> command in after.local. :open_mouth:

Wow. :frowning:


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

That is about the same results I have come up with while studying systemd. The script is running and exiting, but I can’t tell when. SystemV was easier in this regard. I’m sure systemd will catch up. I will look more into trying to set up a cron job.

On 2012-06-04 20:46, 67GTA wrote:
>
> That is about the same results I have come up with while studying
> systemd. The script is running and exiting, but I can’t tell when.

You can deduce it from the logs.

> SystemV was easier in this regard. I’m sure systemd will catch up. I
> will look more into trying to set up a cron job.

The cronjob will probably run the moment the cron daemon is started at
boot, perhaps not after all services have been started as would be the
optimum place.


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

On Mon, 04 Jun 2012 23:08:06 GMT, “Carlos E. R.”
<robin_listas@no-mx.forums.opensuse.org> wrote:

>On 2012-06-04 20:46, 67GTA wrote:
>>
>> That is about the same results I have come up with while studying
>> systemd. The script is running and exiting, but I can’t tell when.
>
>You can deduce it from the logs.
>
>> SystemV was easier in this regard. I’m sure systemd will catch up. I
>> will look more into trying to set up a cron job.
>
>The cronjob will probably run the moment the cron daemon is started at
>boot, perhaps not after all services have been started as would be the
>optimum place.

Ya know, IBM sussed all this out a long time ago developing MVS. Ignoring
history is done at risk.

?-)