2
I have my script.sh
and want to run it with ./script.sh
or ./script.sh --daemon
, having it remain in the foreground unless the --daemon flag is given, in which case it should detach and go into the background appropriately. I want the script to look like
[function definitions]
process_args
if [ "$BECOME_DAEMON" == "1" ]; then
become_daemon
fi
while true; do
read line <controller_fifo
do_command $line
done
Is it possible to get the behavior I want? If so, what do I need to fill in for become_daemon? If not, what would be the best alternative?