From 3b8ce6f62deaf835311cd63ad675bea7013c91ff Mon Sep 17 00:00:00 2001 Message-Id: <3b8ce6f62deaf835311cd63ad675bea7013c91ff.1714958951.git.mdw@distorted.org.uk> From: Mark Wooding Date: Tue, 22 Apr 2008 19:13:49 +0100 Subject: [PATCH] Command line parsing for scripts/setup. This is useful for repeated installs and teardowns with identical configuration. Organization: Straylight/Edgeware From: Richard Kettlewell --- CHANGES | 4 ++ scripts/setup.in | 180 +++++++++++++++++++++++++++++++---------------- 2 files changed, 125 insertions(+), 59 deletions(-) diff --git a/CHANGES b/CHANGES index 32822ef..fa3a144 100644 --- a/CHANGES +++ b/CHANGES @@ -24,6 +24,10 @@ remove users or modify their settings. Relatedly, the server will only allow remote user management if you set remote_userman to 'yes'. +** Miscellaneous + +scripts/setup now honors command line options. + * Changes up to version 3.0.2 Builds --without-server should work again. diff --git a/scripts/setup.in b/scripts/setup.in index 449da2d..e89ddb4 100755 --- a/scripts/setup.in +++ b/scripts/setup.in @@ -21,6 +21,57 @@ 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 +122,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 +148,61 @@ if [ -z "$encoding" ]; then read -r encoding fi -while :; do +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 + +if [ -z "$smtp_server" ]; then 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 + echo "What host should DisOrder use as an SMTP server?" + read -r smtp_server +fi -echo -echo "What host should DisOrder use as an SMTP server?" -read -r smtp_server +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 -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 +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 +214,7 @@ else fi echo " SMTP Server: $smtp_server" echo " Sender address: $mail_sender" +echo " Online registration: $register" echo "Is this OK? (Enter 'y' or 'n')" read -r ok @@ -393,17 +466,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 +475,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 -- [mdw]