NetPractice / net_practice / run.sh 16 commits
20-08-2026
31 lines 803 B
 1#!/usr/bin/env bash
 2
 3myport='49242'
 4
 5if command -v ss >/dev/null 2>&1; then
 6	for port in $(seq 49152 65535); do
 7		if ! ss -lnt | grep -q ":$port "; then
 8			myport=$port
 9			break
10		fi
11	done
12else
13    echo "ss not available, using port 49242."
14fi
15
16
17if command -v xdg-open >/dev/null 2>&1; then
18	echo "Netpractice server is starting, web browser will open."
19	( sleep 2 ; xdg-open "http://localhost:$myport" >/dev/null 2>&1 || true ) &
20else
21	if command -v open >/dev/null 2>&1; then
22		echo "Netpractice server is starting, web browser will open."
23		( sleep 2 ; open "http://localhost:$myport" >/dev/null 2>&1 || true ) &
24	else
25		echo "Netpractice server is starting. Open your web browser with URL: http://localhost:$myport"
26	fi
27fi
28
29echo "Type Ctrl-C to shutdown the server."
30
31python3 -m http.server $myport