Help with actually getting a script to run after boot

I need to run some post-install configuration commands to change the default PPPoE username and password. I've tried putting them in rc.local but they are not being executed so I then put them in the include file for the build and placed them in /usr/sbin/scriptname. I then have rc.local make it executable before running the script. I've even tried running it from the shell but ash says it can not locate the file even though I'm in the current directory.

I thought it was something to do with building master and possibly gcc not linking correctly so I checked out the 22.03 branch and it still does the same thing.

rc.local

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

echo 437500 > /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq
echo performance > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor
chmod +x /usr/sbin/pppoe-setup
/usr/sbin/pppoe-setup
exit 0

script located at /usr/sbin/pppoe-setup

#!/bin/sh
echo 'Getting WAN Mac Address'
PPPoE_Username=$(cat /sys/class/net/wan/address)
echo $PPPoE_Username
echo 'Configuring WAN link for PPPoE'
uci set network.wan.proto=pppoe
uci set network.wan.username=$PPPoE_Username
uci set network.wan.password=$PPPoE_Username
echo 'Commiting Changes'
uci commit network
echo 'Restarting Network'
service network reload

root@OpenWrt:~# /usr/sbin/pppoe-setup
-ash: /usr/sbin/pppoe-setup: Permission denied

It looks like the executable is set now


root@OpenWrt:~# ls -la /usr/sbin/pppoe-setup
-rwxrwxr--    1 root     root           363 Jun  2 15:01 /usr/sbin/pppoe-setup

I can not run /usr/sbin/pppoe-setup from the shell and it does set it up as I want. However, it's not being run by rc.local on startup. 


I found another instance on the internet where this was happening and it was due to creating the files in notepad++ and then copying them into my build files. What I ended up doing was editing them in the shell on the router and then copying them off and placing them in the build root files. Now my scripts are running and configuring the interface as I've asked.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.