X-Git-Url: https://git.distorted.org.uk/~mdw/disorder/blobdiff_plain/4f70fa294199020b2d84023be1b07b27ad1cbd31..7c82ecb820073aa894f9b41442fdf910c19accdb:/scripts/setup.in diff --git a/scripts/setup.in b/scripts/setup.in index 449da2d..3bc0b45 100755 --- a/scripts/setup.in +++ b/scripts/setup.in @@ -21,6 +21,79 @@ set -e +while [ $# -gt 0 ]; do + opt="$1" + shift + case "$opt" in + -h | --help ) + cat <&2 "ERROR: unknown option '$opt'" + exit 1 + ;; + esac +done + echo echo ------------------------------------------------------------------------ echo "DisOrder setup script" @@ -71,22 +144,24 @@ echo echo "If this is not what you want, press ^C." echo ------------------------------------------------------------------------ -while :; do - echo - echo "What directory or directories contain your music files:" - echo "(enter one or more directories separated by spaces)" - read -r roots - ok=true - for root in $roots; do - if [ ! -d $root ]; then - echo "'$root' does not exist" - ok=false +if [ -z "$roots" ]; then + while :; do + echo + echo "What directory or directories contain your music files:" + echo "(enter one or more directories separated by spaces)" + read -r roots + ok=true + for root in $roots; do + if [ ! -d $root ]; then + echo "'$root' does not exist" + ok=false + fi + done + if $ok; then + break fi done - if $ok; then - break - fi -done +fi if [ -z "$encoding" ]; then echo @@ -95,42 +170,107 @@ if [ -z "$encoding" ]; then read -r encoding fi -while :; do - echo - echo "What TCP port should DisOrder listen on?" - echo "(enter 'none' for none)" - read -r port - case $port in - none ) - break - ;; - [^0-9] ) - echo "'$port' is not a valid port number" - continue - ;; - * ) - break - ;; - esac -done +if [ -z "$port" ]; then + while :; do + echo + echo "What TCP port should DisOrder listen on?" + echo "(enter 'none' for none)" + read -r port + case $port in + none ) + break + ;; + [^0-9] ) + echo "'$port' is not a valid port number" + continue + ;; + * ) + break + ;; + esac + done +fi -echo -echo "What host should DisOrder use as an SMTP server?" -read -r smtp_server +if [ -z "$play" ]; then + while :; do + echo + echo "How do you want to play sound? Enter 'local' to use a local sound" + echo "device or 'network' to multicast sound across your network." + read -r play + case $play in + 'local' | network ) + break + ;; + * ) + echo "Enter 'local' or 'network'" + continue + ;; + esac + done +fi + +if [ "x$play" = xnetwork ]; then + if [ -z "$mcast_address" ]; then + echo + echo "Enter destination address for network transmission" + echo "(e.g. a multicast address)" + read -r mcast_address + fi + if [ -z "$mcast_port" ]; then + while :; do + echo + echo "Enter destination port for network transmission" + read -r mcast_port + case $mcast_port in + none ) + break + ;; + [^0-9] ) + echo "'$mcast_port' is not a valid port number" + continue + ;; + * ) + break + ;; + esac + done + fi +fi -while :; do +if [ -z "$smtp_server" ]; then echo - echo "What address should mail from DisOrder come from?" - read -r mail_sender - case "$mail_sender" in - *@* ) - break - ;; - * ) - echo "Email address must contain an '@' sign" - ;; - esac -done + echo "What host should DisOrder use as an SMTP server?" + read -r smtp_server +fi + +if [ -z "$mail_sender" ]; then + while :; do + echo + echo "What address should mail from DisOrder come from?" + read -r mail_sender + case "$mail_sender" in + *@* ) + break + ;; + * ) + echo "Email address must contain an '@' sign" + ;; + esac + done +fi + +if [ -z "$register" ]; then + while :; do + echo + echo "Do you want to enable online registration? (Enter 'y' or 'n')" + read -r register + case $reguser in + y | n ) + break + ;; + esac + done +fi echo echo "Proposed DisOrder setup:" @@ -142,6 +282,10 @@ else fi echo " SMTP Server: $smtp_server" echo " Sender address: $mail_sender" +echo " Online registration: $register" +if [ $play = network ]; then + echo " Send sound to: $mcast_address port $mcast_port" +fi echo "Is this OK? (Enter 'y' or 'n')" read -r ok @@ -168,6 +312,9 @@ echo "user $user" >> pkgconfdir/config.new if [ $port != none ]; then echo "listen 0.0.0.0 $port" >> pkgconfdir/config.new fi +if [ $play = network ]; then + echo "broadcast $mcast_address $mcast_port" >> pkgconfdir/config.new +fi echo "smtp_server $smtp_server" >> pkgconfdir/config.new echo "mail_sender $mail_sender" >> pkgconfdir/config.new @@ -393,17 +540,6 @@ else fi if $server_running; then - while :; do - echo - echo "Do you want to enable online registration? (Enter 'y' or 'n')" - read -r reg - case $reg in - y | n ) - break - ;; - esac - done - echo first=true sleep 5 while ! disorder version >/dev/null 2>&1; do @@ -413,7 +549,7 @@ if $server_running; then fi sleep 1 done - if [ $reg = y ]; then + if [ $register = y ]; then echo "Creating guest user with 'register' right" disorder setup-guest else