Skip to content

Commit 4db8fec

Browse files
committed
check for alt ports
1 parent 1e82763 commit 4db8fec

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

deb/debian/homebridge.service

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ ExecStart=/opt/homebridge/start.sh
1313
Restart=always
1414
RestartSec=3
1515
KillMode=process
16+
AmbientCapabilities=CAP_NET_BIND_SERVICE
1617

1718
[Install]
1819
Alias=homebridge

deb/debian/postinst

+11-2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@ fi
7373
# post-install only
7474
if [ "$1" = "configure" ] && [ -z $2 ]; then
7575
IP=$(hostname -I)
76+
PORT=8581
77+
78+
# check to see if an alternate port is defined in the config
79+
if [ -f /var/lib/homebridge/config.json ]; then
80+
PORT_FROM_CONFIG=$(cat /var/lib/homebridge/config.json | jq '.platforms[] | select(.platform | contains("config")) | .port' 2> /dev/null)
81+
if [ ${#PORT_FROM_CONFIG} -gt 0 ]; then
82+
PORT=$PORT_FROM_CONFIG
83+
fi
84+
fi
7685

7786
echo ""
7887
echo "Homebridge Installation Complete!"
@@ -81,9 +90,9 @@ if [ "$1" = "configure" ] && [ -z $2 ]; then
8190

8291
for ip in $IP; do
8392
if [[ $ip =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
84-
echo "* http://$ip:8581"
93+
echo "* http://$ip:$PORT"
8594
else
86-
echo "* http://[$ip]:8581"
95+
echo "* http://[$ip]:$PORT"
8796
fi
8897
done
8998

0 commit comments

Comments
 (0)