I would like to use a script that modifies iptables and that starts rtmpsuck as a deamon.
My current script is:
#!/bin/bash
function help_txt {
package="enable-rtmpsuck"
echo "$package - setup rtmpsuck to intercept rtmp streams and start rtmpsuck as a deamon"
echo " "
echo "sudo $package [options]"
echo " "
echo "options:"
echo "-p, --path specify download path (default is the current directory)"
echo " "
echo "Please note that this script needs root privileges to work."
}
if [ $# -eq 0 ]
then
path="$PWD"
elif [ $# -eq 2 -a \( "$1" == "-p" -o "$1" == "--path" \) -a -d "$2" ]
then
path="$2"
else
help_txt
exit 1
fi
if [[ "$(id -u)" == "0" ]]
then
cd "$path"
echo "changed directory to: $path"
iptables -t nat -A OUTPUT -p tcp --dport 1935 -m owner ! --uid-owner root -j REDIRECT
echo "redirect all rtmp traffic to rtmpsuck"
setsid sudo rtmpsuck >/dev/null 2>&1 &
PID="$!"
echo "$PID" > /tmp/.rtmpsuck_pid
echo "started rtmpsuck deamon"
else
help_txt
exit 1
fi
Everything works fine, but rtmpsuck is using 96% of the CPU if I start it like that. Is there any way to get its normal behavior that is near 0% usage of the CPU?
I'm using Linux Mint 17.1.