Starting .sh script at boot breaks LED & reboot

Hi, Ive Been Trying To Get A Script I've Put Together To Run At Boot, The Script Runs Placed In /sbin/ When Launched Manually With

"root@LEDE:~# btwifi.sh"

Cant Figure Out How To Run This At Boot (the script loops forever so only needs launched once)

Tried Sevaral Things But Just Cant Figure It Out,

Script:

#!/bin/sh

######## INFO ########

# OpenWrt: 
# wget: SSL support not available, please install the following 
# libustream-mbedtls

# At The TOP Edit Your Account Type & Add Email & Password

# Account Type:
# 1 = BT Home Broadband
# 2 = BT Wi-Fi Account
# 3 = BT Buisness Broadband

######## settings ########

ACCOUNTTYPE=1
USERNAME=example@btinternet.com
PASSWORD=example2022

######## OPTIONAL ########

PINGDNS=8.8.8.8
PING2URL=www.google.com

######## DO NOT EDIT BELOW HERE ########

while :
do
pingtime=$(ping -w 1 $PINGDNS | grep ttl)
if [ "$pingtime" = "" ] 
then 
   pingtimetwo=$(ping -w 1 $PING2URL | grep ttl) 
   if [ "$pingtimetwo" = "" ] 
   echo "Offline, Attempting Login"
	then
		if [ "$ACCOUNTTYPE" = "1" ]
		then
		wget --no-check-certificate -T 2 -O /dev/null --post-data "username=$USERNAME&password=$PASSWORD" 'https://192.168.23.21:8443/tbbLogon'
		fi
			if [ "$ACCOUNTTYPE" = "2" ]
			then
			wget --no-check-certificate -T 2 -O /dev/null --post-data "username=$USERNAME&password=$PASSWORD" 'https://192.168.23.21:8443/ante'
			fi
				if [ "$ACCOUNTTYPE" = "3" ]
				then
				wget --no-check-certificate -T 2 -O /dev/null --post-data "username=$USERNAME&password=$PASSWORD" 'https://192.168.23.21:8443/ante?partnerNetwork=btb'
				fi
				else
					clear ; echo 'Online'
   fi 
else
    clear ; echo 'Online'
fi
sleep 1
done

cat /etc/rc.local

ive tried but it woudnt trigger (Tried adding via LUCI /system/startup)

My Last Attempt

# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.

/root/sbin/btwifi.sh

exit 0

  1. Use logger -t debug_my_code my_message instead of echo
  2. Use absolute paths instead of relative.

That looks wrong. Shouldn't that be just /sbin/btwifi.sh ?

This Any Help? (Rather New To All This)

root@LEDE:/sbin# find "$(cd ..; pwd)" -name "btwifi.sh"
/overlay/upper/sbin/btwifi.sh
/sbin/btwifi.sh

This Seemed To Work but tried many similar configs and wouldn't trigger

# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.

/overlay/upper/sbin/btwifi.sh

exit 0

The /sbin/btwifi.sh is enough.

That Works, No Idea What I Did Wrong Originally,

Odd Note, With The Script Running My Power LED doesn't Stop Flashing & reboot from LUCI no longer works either,

Any Ideas?

Since it is not backgrounding it does not allow the boot process to fully complete. Try adding an & after the command:

/sbin/btwifi.sh &

1 Like

Im Afraid The $ Made No Difference

It's a &, not a $

1 Like

sorry been looking at symbols all day haha

This Causes The Script To No Longer Run At All

# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.

/sbin/btwifi.sh &

exit 0

Keep in mind that anything that runs as a startup script will be run headless, so the echo commands won't work properly -- you may want to replace those with logger commands.

Also...

Is this running on 17.01? And if so, is this running the official LEDE release or is it a vendor customized version? If the latter, that may change how some of this stuff works.

Please run the following commands (copy-paste the whole block) and paste the output here, using the "Preformatted text </> " button:
grafik

ubus call system board

All Should Be Official, i also have x2 bt home hub 5a and TP-Link WR2543ND Both Running 19.07.9, just using This D-Link To Test With, Its On 17.x as 19.x wouldn't save config after reboot (low storage device)

Output

root@LEDE:~# ubus call system board
{
        "kernel": "4.4.182",
        "hostname": "LEDE",
        "system": "Ralink RT3052 id:1 rev:3",
        "model": "D-Link DIR-615 D",
        "board_name": "dir-615-d",
        "release": {
                "distribution": "LEDE",
                "version": "17.01.7",
                "revision": "r4030-6028f00df0",
                "codename": "reboot",
                "target": "ramips\/rt305x",
                "description": "LEDE Reboot 17.01.7 r4030-6028f00df0"
        }
}

It would be wise to use a newer device with the ability to run a modern version of OpenWrt. LEDE has been EOL for many years now, and is unsupported and has many actively exploited/exploitable vulnerabilities, and really shouldn't be used on the internet anymore.

While we're talking about that... 19.07.10 was just released and that is the final release of the 19.07 series releases and it is officially EOL. It is no longer supported in terms of updates/bug-fixes/security patches (although obviously forum support continues). Consider upgrading your other devices to 21.02 if possible.

I'm sure people here will still give you a best-effort attempt to help resolve your issue, but given the age of LEDE as an OS, it is possible there are nuances that people will not remember.

2 Likes

Will Update One Hub 5a (128/218) to 19.10 & The Other To 20.03, i did try both (i think) 20.01 & 20.02 And they resulted in lower wifi performance, i think the tp link will be stuck on 19.x, not sure if i tried 20.x, think maybe decided to roll back too on there (8/64 device) , Yhe the dlink i bought in 2014, came with DDWRT with a 2013 build on it, used that for a few years, Will see on newer openwrt & see :slight_smile:

Infinite loop in the script.
Thee boot script should do something then end.
For example start another script in the background

so results with testing, 20.x on TP Link, 10 Mbps Slower Download Throughput vs 19.x, simmilar with BT Hubs But Not As Bad, Will Have To Try 19 again on d-link but not hopeful here, ill probably stick with 19.10 for now :slight_smile:

Something Like This?

#!/bin/sh

echo "This script is about to run another script."
sh /sbin/btwifi.sh
echo "This script has just run another script."

Add an & to this line

Like this

sh /sbin/btwifi.sh &

1 Like