aboutsummaryrefslogtreecommitdiff
path: root/audio/bristol/files/patch-bin_startBristol.in
blob: 2ef201ac86076410ecfa6cd5724f3071f1ff3a27 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
--- bin/startBristol.in.orig	2012-04-27 13:07:18.000000000 +0200
+++ bin/startBristol.in	2012-09-24 13:30:26.589848964 +0200
@@ -39,14 +39,19 @@
 #PORT=5028
 # Randomise the port numbers, can be overridden by -port which would be a
 # requirement for multitimbral
-PORT=`date +%N`
-PORT=`expr $PORT % 65536` >/dev/null 2>&1
-if [ -z $PORT ]; then
-	PORT=`date +%s`
+UNAME=`uname`
+if [ "${UNAME}x" = "FreeBSDx" ]; then
+	PORT=`jot -r 1 1025 65536`
+else
+	PORT=`date +%N`
 	PORT=`expr $PORT % 65536` >/dev/null 2>&1
-fi
-if [ $PORT -lt 1024 ]; then
-	PORT=`expr $PORT + 5028`
+	if [ -z $PORT ]; then
+		PORT=`date +%s`
+		PORT=`expr $PORT % 65536` >/dev/null 2>&1
+	fi
+	if [ $PORT -lt 1024 ]; then
+		PORT=`expr $PORT + 5028`
+	fi
 fi
 
 valgrind=0
@@ -497,12 +502,12 @@
 		fi
 	else
 		echo checking availability of TCP port $PORT
-		netstat -taln | awk '{print $4}' | grep $PORT > /dev/null
+		netstat -a -f inet -p tcp -ln | grep $PORT > /dev/null
 		while [ $? -eq 0 ]; do
 			echo -n "port looked busy, trying "
 			PORT=`expr $PORT + 1`
 			echo $PORT
-			netstat -taln | grep $PORT > /dev/null
+			netstat -a -f inet -p tcp -ln | grep $PORT > /dev/null
 		done
 		if [ ${PORT} -lt 1024 -a ${USER} != "root" ]; then
 				echo you may not have permissions for ports less than 1024