소스 검색

Set maximum number of icecast clients

Bob Mottram 7 년 전
부모
커밋
18c2603789
1개의 변경된 파일31개의 추가작업 그리고 3개의 파일을 삭제
  1. 31
    3
      src/freedombone-app-icecast

+ 31
- 3
src/freedombone-app-icecast 파일 보기

372
     start_icecast
372
     start_icecast
373
 }
373
 }
374
 
374
 
375
+function icecast_set_maximum_streams {
376
+    data=$(tempfile 2>/dev/null)
377
+    trap "rm -f $data" 0 1 2 5 15
378
+    dialog --title $"Set the maximum clients" \
379
+           --backtitle $"Freedombone Control Panel" \
380
+           --inputbox $"Maximum number of clients" 8 40 "10" 2>$data
381
+    sel=$?
382
+    case $sel in
383
+        0)
384
+            max_clients=$(<$data)
385
+            if [ ${#max_clients} -gt 0 ]; then
386
+                if [[ "$max_clients" != *' '* ]]; then
387
+                    if [[ $max_clients =~ '^[0-9]+$' ]] ; then
388
+                        sed -i "s|<clients>.*|<clients>${max_clients}</clients>|g" /etc/icecast2/icecast.xml
389
+                        stop_icecast
390
+                        start_icecast
391
+                        dialog --title $"Set the maximum clients" \
392
+                               --msgbox $"\nMaximum Icecast clients was set to ${max_clients}" 8 50
393
+                    fi
394
+                fi
395
+            fi
396
+            ;;
397
+    esac
398
+    rm $data
399
+}
400
+
375
 function configure_interactive_icecast {
401
 function configure_interactive_icecast {
376
     while true
402
     while true
377
     do
403
     do
379
         trap "rm -f $data" 0 1 2 5 15
405
         trap "rm -f $data" 0 1 2 5 15
380
         dialog --backtitle $"Freedombone Control Panel" \
406
         dialog --backtitle $"Freedombone Control Panel" \
381
                --title $"Icecast" \
407
                --title $"Icecast" \
382
-               --radiolist $"Choose an operation:" 18 70 11 \
408
+               --radiolist $"Choose an operation:" 19 70 12 \
383
                1 $"Import stream files from directory" off \
409
                1 $"Import stream files from directory" off \
384
                2 $"Import stream files from USB drive" off \
410
                2 $"Import stream files from USB drive" off \
385
                3 $"Manually edit playlist" off \
411
                3 $"Manually edit playlist" off \
390
                8 $"Re-scan playlist" off \
416
                8 $"Re-scan playlist" off \
391
                9 $"Restart stream" off \
417
                9 $"Restart stream" off \
392
                10 $"Set Stream Name/Description/Genre" off \
418
                10 $"Set Stream Name/Description/Genre" off \
393
-               11 $"Exit" on 2> $data
419
+               11 $"Set maximum number of clients/streams" off \
420
+               12 $"Exit" on 2> $data
394
         sel=$?
421
         sel=$?
395
         case $sel in
422
         case $sel in
396
             1) break;;
423
             1) break;;
412
                stop_icecast
439
                stop_icecast
413
                start_icecast;;
440
                start_icecast;;
414
             10) icecast_set_stream_name;;
441
             10) icecast_set_stream_name;;
415
-            11) break;;
442
+            11) icecast_set_maximum_streams;;
443
+            12) break;;
416
         esac
444
         esac
417
     done
445
     done
418
 }
446
 }