Tiny Core Linux
Tiny Core Base => TCB Talk => Topic started by: kh335m on November 10, 2023, 06:13:13 AM
-
Hi,
My bootlocal.sh is not executing myfw.sh file during boot time. here is my bootlocal.sh
#!/bin/sh
# put other system startup commands here
/opt/myfw.sh
and here is myfw.sh
#!/bin/sh
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -s x.x.x.x -j ACCEPT
iptables -A INPUT -s x.x.x.x -j ACCEPT
iptables -A INPUT -s x.x.x.x -j ACCEPT
iptables -A INPUT -j DROP
iptables -A FORWARD --j DROP
I can manually execute the bootlocal.sh file, there is no problem but did not execute during boot. Where is the issue?
Thanks
[Edit]: Added code tags. Rich
-
Hi kh335m
Is iptables.tcz listed in your onboot.lst file?
Does iptables need the network to be up in order to work?
-
Hi,
The iptables installed and it is in the onboot.ist list. when I run "iptables -L" , I can see bellow
#iptables -L
Chain INPUT (policy ACCEPT)
target prot opt SOURCE destination
Chain FORWARD (policy ACCEPT)
target prot opt SOURCE destination
Chain OUTPUT (policy ACCEPT)
target prot opt SOURCE destination
[Edit]: Added code tags. Rich
-
Still no luck
-
Hi kh335m
Try changing bootlocal.sh to this:
#!/bin/sh
# put other system startup commands here
# Wait for network to come up
SEC="60"
while [ $SEC -gt 0 ]
do
SEC=$(($SEC - 1))
ifconfig | grep -q "Bcast:" && break
sleep 1
done
if [ $SEC -gt 0 ]
then
echo "$(date +"%m-%d-%y %H:%M:%S") : Starting /opt/myfw.sh" >> /opt/myfw.err
/opt/myfw.sh
echo "$(date +"%m-%d-%y %H:%M:%S") : Finished /opt/myfw.sh" >> /opt/myfw.err
else
echo "$(date +"%m-%d-%y %H:%M:%S") : Network interface is down" >> /opt/myfw.err
fi
Then see what got logged to /opt/myfw.err.
-
Then see what got logged to /opt/myfw.err.
I came to recommend the same. I tried to replicate and it didn't work, after adding
/opt/test.sh > /tmp/log.txt 2>&1
I got a permissions error message, which was fixed with chmod u+x in test.sh
I didn't know that the files needed proper permissions, since they run as root
-
I think you missed just to set the execution bit with the script.
If you typed in that command with the root user you should see with the ls -l command that the x is there for the root user.
The kernel need to know if this file is executable. And what she bang interpreter it should execute.
Like something like this
#/bin/bash
#/bin/sh
You can also use some other interpreters like python.
#/bin/env python3
-
is there any other way to run the script from boot?
-
Hi kh335m
Sure. If you are running a GUI, create a file in
~/.X.d/ (any name you want) containing:
/opt/myfw.sh &
Add sudo if that's needed. The contents of the
file will be automatically executed after the
GUI is started.
If you are strictly in text mode, add the above
command to the end of ~/.ashrc instead.
-
Here is my question -- I have bootlocal.sh and myfw.sh, but when I reboot the tinycore, I am not seeing any output the error log, and also all entries are gone from bootlocal.sh (empty) .
That is wired or am I doing wrong.
-
Hi kh335m
Restore your myfw.sh and bootlocal.sh files.
Then:
echo "opt/bootlocal.sh" >> /opt/.filetool.lst
echo "opt/myfw.sh" >> /opt/.filetool.lst
filetool.sh -b
Reboot and see if things are any better.
-
Thanks. it works.