server.sh

23 lines | 470 B Blame History Raw Download
#!/bin/bash

if [ "$(whoami)" != 'root' ]; then
    echo "You have no permission to run $0 as non-root user."
    exit 1;
fi

echo "Start listening on port 5000 ..."
while read line
do
	if [ "$line" == 'caching-approaches-comparison exit' ]; then
		echo "Received 'exit'"
		break
	else
		echo "$line"
		if [[ "$line" = "caching-approaches-comparison "* ]]; then
			cmd=${line/caching-approaches-comparison/}
			eval $cmd
		fi
	fi
done < <(nc -k -l 5000)
echo "Good bye"