Hello,
I'm trying to create a startup script for following tcpdump command:
tcpdump -i eth1.1 -l arp and ether[0x26:1]= and ether[0x27:1]= and ether[0x28:1]= and ether[0x29:1]=|while read -r line; do etherwake -i eth1.1 ; done&
(The <> tags are placeholders)
This script sends a wake on lan magic packet to the destination host, when a client is accessing it (over web or smb for example). The script works fine, but not at boot.
I tried creating a script, which looks like following:
#!/bin/sh /etc/rc.common
START=99
USE_PROCD=1
COMMAND="/usr/sbin/tcpdump -i eth1.1 -l arp and ether[0x26:1]=192 and ether[0x27:1]=168
start_service() {
procd_open_instance
procd_set_param command $COMMAND
}
Can someone help to get this working?
cat <<'__EOF__' > /root/script.sh
#!/bin/sh
/usr/sbin/tcpdump -i eth1.1 -l arp and ether[0x26:1]=192 and ether[0x27:1]=168
/usr/sbin/tcpdump -i eth1.1 -l arp and ether[0x26:1]=192 and ether[0x27:1]=168 and ether[0x28:1]=1 and ether[0x29:1]=2 | while read -r line; do etherwake -i eth1.1; done &
__EOF__
chmod +x /root/script.sh
/root/script.sh # test
logread # see logs
cat <<'__EOF__' > /etc/init.d/mydaemon
#!/bin/sh /etc/rc.common
START=99
USE_PRCD=1
start_service() {
logger "Daemon Started"
procd_open_instance
procd_set_param command /root/script.sh
procd_close_instance
}
stop_service() {
logger "Daemon Stopped"
}
__EOF__
chmod +x /etc/init.d/mydaemon
/etc/init.d/mydaemon enable
/etc/init.d/mydaemon start
logread # see logs
I think that command parameter are not read with those double quotes, you should be minimal your command call, but if you call a script and not a command then is better if you put your script in a script file.