description "SpeedTestServer instance"

instance $NUMBER

env SERVER_DIR="/opt/speedtest/SpeedTestServer"
env SERVER_BIN="/opt/speedtest/SpeedTestServer/SpeedTestServer"
env CONFIG_DIR="/opt/speedtest/SpeedTestServer/config"
env http_proxy=""

pre-start script
	export CONFIG_FILE="$CONFIG_DIR/server_$NUMBER.conf"
	[ -f "$CONFIG_FILE" ]
	[ -x "$SERVER_BIN" ]
end script

respawn
script
	export CONFIG_FILE="$CONFIG_DIR/server_$NUMBER.conf"
	export http_proxy=""
	exec su -s /bin/sh -c 'exec "$0" "$@"' speedtest -- $SERVER_BIN -c $CONFIG_FILE
end script
