Been hours trying... Please help me start a sciprt on boot. rc.local, init.d, rcX.d. cant get any to work. Please

It’s just a simple script, just need to run at boot. i dont care about stop, status, reload, restart (and yes, ive made proper scripts with explicit functions, still nothing). init scripts run fine manually, but not at any runlevel, or even red.up. I’ve tried creating systemv services, ive tried chkconfig services, rc.local in every possible /etc folder, including /etc/sysconfig. Please just help me run a stupid command at boot. I know super noob question, but not a noob.

also tried making init.d services with SXX numeration and symlinks. i can manually start services. tried different headers like #!/bin/bash, #!/bin/bash -e. idk what else to do…

Hi Josh - Welcome to the IPFire Community!

Before you added your script to rc.local, init.d, etc, does the script run on its own without issue?

I suggest sharing the script for us to help.

If you are running a bash script then the shebang of:

#!/bin/bash

. . . is correct.

  • FYI - A perl script is different, a python script is also different.

You can try:

#!/bin/bash
set -e

# your code goes here...

The set -e causes the script to end on any error.

3 Likes

Good evening. Thank you for the reply.

Yes, the script runs fine on its own, and it also runs fine as a service when ran manually. It just will not run at any runlevel.

Not PERL or Python scripts. just outright shell commands.

Pretty sure I deleted all the service files I created. I will upload them shortly.

Here is what I am trying to run

#!/bin/sh
sh /etc/dns/start.sh

start.sh contents is :

#!/bin/sh
dotnet DnsServerApp.dll

these are not the service files i created. i created real init.d services with start, stop, reload, status functions. i then symlinked that service file into /etc/rc.d/rc3.d/S55start or something similar. rebuilding the service files now, will upload shortly.

i could start the service with /etc/rc.d/init.d/dnsserver start and it would be fine. but at boot, nothing.

/etc/rc.d/init.d/dnsserver (yes, chmod +x) :

#! /bin/sh
### BEGIN INIT INFO
# Provides:          dnsserver
# Required-Start:
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:
# Short-Description: Start DNS Server
# Description: Start DNS SERVER
### END INIT INFO


case "$1" in
  start)
        sh /etc/dns/startscript.sh
        ;;
  stop)
        pidof dotnet | xargs kill -9
        ;;
  restart|reload|force-reload)
        pidof dotnet | xargs kill -9
        sh /etc/dns/startscript.sh
        ;;
  *)
        # echo "Usage: $0 start|stop" >&2
        # exit 3
        ;;
esac
[root@ipfire ~]# /etc/rc.d/init.d/dnsserver start
Technitium DNS Server was started successfully.
Using config folder: /etc/dns/config

Note: Open http://ipfire:5380/ in web browser to access web console.

Press [CTRL + C] to stop...

after this, i do ln -s /etc/rc.d/init.d/dnsserver /etc/rc.d/rc3.d/S99dnsserver . reboot, nothing

hmmm… this is not making much sense so I have to ask questions.

Keep in mind a lot of these files might be overwritten during a core upgrade. I usually add scripts to the /root/ directory to keep them out of the way.


This seems to be a script within a script. And that runs what may be a Windows command.

Since this looks more like a windows and a windows DLL then anything else. What is this? What is dotnet and DnsServerApp.dll?

And what is the Technitium DNS Server?

2 Likes

It is not a windows command. it is dotnet. an SDK provided by Microsoft, for many platforms, including Linux, FreeBSD, Windows, etc.

The context within the scripts are not important. It does not matter what I put in there, they do not launch.

The reason I call a script to then open another script is because I specifically do not want to include globalization support. furthermore, i do not want that path exported or used as a function. Again, only telling you this as information, not asking for assistance in that regard. Though I do appreciate your concern.

Please ignore any consideration of binaries. As I stated, I am not a novice in the linux world.

Technitium DNS Server is a DNS Server branded by a developer. Each of his servers begin with his chosen name ‘Technitium’.

To verify, it is a DLL, but DOTNET handles it just fine and is intended for linux. This is not WINE, it is not emulation, it is not translated. It is native and supported natively with a core instalation of DOTNET 7.0 (as of this writing). But again, please ignore what my scripts launch or do.

This inquiry is specifically as to why my SystemV and/or init.d scripts are not loading. Everything seems correct.

Furthermore, yes, I know IPFIRE provides Unbound, and many other features. This is a niche request. I have disabled Unbound, and replacing it with this DNS server. Just informational, not asking for assistance in that regard.

I just need to be able to launch this (and potentially other) commands via init.d. that is the problem launching via init.d. As I have expressed, the script(s) and services launch just fine, but only manually. They should be running at boot, which is RUNLEVEL 3.

I just tested it out on my IPFire vm testbed and it worked fine. Here is what I set up using just simple bash script to test out.

Created a file /etc/init.d/technitium with ownership and permissions as follows

-rwxr-xr-- 1 root root 120 Feb 5 10:58 /etc/init.d/technitium

Contents of this file are

#!/bin/sh

case "${1}" in
        start)
                touch /root/$EPOCHSECONDS
                ;;

        *)
                echo "Usage: ${0} {start}"
                exit 1
                ;;
esac

Then created a symlink

ln -s /etc/init.d/technitium /etc/rc.d/rc3.d/S99technitium

which can then be seen in the rc3.d directory

lrwxrwxrwx 1 root root   24 Apr 26  2022 S98rc.local -> ../../sysconfig/rc.local
lrwxrwxrwx 1 root root   22 Feb  5 11:03 S99technitium -> /etc/init.d/technitium

Then ran this manually with

/etc/init.d/technitium start

and then rebooted my IPFire vm and this is what was in the root directory.

-rw-r--r-- 1 root root 0 Feb  5 11:01 /root/1675591294
-rw-r--r-- 1 root root 0 Feb  5 11:05 /root/1675591546

One file from my manual running and the other from the reboot.

Maybe try exactly with the examples I have used above to confirm that it also works for you and then you can edit them to include your content until you find where it doesn’t continue working.

3 Likes

Just an idea.
Has dotnet to be started on boot, also? If yes, is it started before the Microsoft oriented DNS server?

1 Like

I am not familiar at all with dotnet but a quick read of some microsoft pages indicated that the path variable needs to be configured correctly.

Does your IPFire PATH environment variable have the required path content.

The default PATH environment for IPFire is

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin

1 Like

Thank you I will try this if other solution doesn’t work. I have a feeling it is what someone below said though. They mention PATH … And immediately I realized that I very stupidly forgot I export PATH for dotnet in ~/.bashrc or some other user context… Which is only going to happen AFTER logging in. I bet my face it’s this lmao.

(Just realized you were the same commentor lol. Anyway, I will check my environment and report back. Thank you.

1 Like

Just wanted to thank you @bonnietwin , @jon and also @ bbitsch (but i can’t mention you since I am a new user, only allows for 2 people mentioned at once) . In the end, of course, it was a PEBCAC error. It was resolved by adding

export DOTNET_ROOT=/root/.dotnet

export PATH=$PATH:/root/.dotnet:/root/.dotnet/tools

into the init.d script. sigh stupid simple stuff. sorry guys. and thank you again

3 Likes