Merge branch 'cameraport'

This commit is contained in:
paukstelis
2023-04-06 20:08:26 -04:00

View File

@@ -278,11 +278,11 @@ new_instance () {
#find frontend line, do insert #find frontend line, do insert
#Don't know how to do the formatting correctly here. This works, however. #Don't know how to do the formatting correctly here. This works, however.
SEDREPLACE="#$INSTANCE start\n\ SEDREPLACE="#$INSTANCE start\n\
acl is_$INSTANCE url_beg /$INSTANCE\n\ acl is_$INSTANCE url_beg /$INSTANCE\n\
http-request redirect scheme http drop-query append-slash if is_$INSTANCE ! { path_beg /$INSTANCE/ }\n\ http-request redirect scheme http drop-query append-slash if is_$INSTANCE ! { path_beg /$INSTANCE/ }\n\
use_backend $INSTANCE if { path_beg /$INSTANCE/ }\n\ use_backend $INSTANCE if { path_beg /$INSTANCE/ }\n\
#$INSTANCE stop" #$INSTANCE stop"
sed -i "/option forwardfor except 127.0.0.1/a $SEDREPLACE" /etc/haproxy/haproxy.cfg sed -i "/option forwardfor except 127.0.0.1/a $SEDREPLACE" /etc/haproxy/haproxy.cfg
echo "#$INSTANCE start" >> /etc/haproxy/haproxy.cfg echo "#$INSTANCE start" >> /etc/haproxy/haproxy.cfg
@@ -392,7 +392,7 @@ write_camera() {
#find frontend line, do insert #find frontend line, do insert
sed -i "/use_backend $INSTANCE if/a\ use_backend cam${INUM}_$INSTANCE if { path_beg /cam${INUM}_$INSTANCE/ }" /etc/haproxy/haproxy.cfg sed -i "/use_backend $INSTANCE if/a\ use_backend cam${INUM}_$INSTANCE if { path_beg /cam${INUM}_$INSTANCE/ }" /etc/haproxy/haproxy.cfg
if [ $HAversion -gt 1 ]; then if [ $HAversion -gt 1 ]; then
EXTRACAM="backend cam${INUM}_$INSTANCE\n\ EXTRACAM="backend cam${INUM}_$INSTANCE\n\
http-request replace-path /cam${INUM}_$INSTANCE/(.*) /|\1\n\ http-request replace-path /cam${INUM}_$INSTANCE/(.*) /|\1\n\
server webcam1 127.0.0.1:$CAMPORT" server webcam1 127.0.0.1:$CAMPORT"
else else
@@ -492,18 +492,28 @@ add_camera() {
echo echo
fi fi
while true; do
echo "Camera Port (ENTER will increment last value in /etc/camera_ports):" echo "Camera Port (ENTER will increment last value in /etc/camera_ports):"
read CAMPORT read CAMPORT
if [ -z "$CAMPORT" ]; then if [ -z "$CAMPORT" ]; then
CAMPORT=$(tail -1 /etc/camera_ports) CAMPORT=$(tail -1 /etc/camera_ports)
fi
if [ -z "$CAMPORT" ]; then if [ -z "$CAMPORT" ]; then
CAMPORT=8000 CAMPORT=8000
fi fi
CAMPORT=$((CAMPORT+1)) CAMPORT=$((CAMPORT+1))
echo Selected port is: $CAMPORT | log
if [ $CAMPORT -gt 7000 ]; then
break
else
echo "Camera Port must be greater than 7000"
fi fi
done
echo "Settings can be modified after initial setup in /etc/systemd/system/cam${INUM}_$INSTANCE.service" echo "Settings can be modified after initial setup in /etc/systemd/system/cam${INUM}_$INSTANCE.service"
echo echo
while true; do while true; do