diff options
author | luis <luis> | 2007-12-06 13:04:03 +0000 |
---|---|---|
committer | luis <luis> | 2007-12-06 13:04:03 +0000 |
commit | 62e6c82a85dff975b11f21f07f76f92ffc18e2aa (patch) | |
tree | 8155cc1981e5ec113e0d1c82502e7c02f8fdfbb6 | |
parent | ea67cf748060ac542497d8ca41e8ebf3c88a67da (diff) | |
download | firma-62e6c82a85dff975b11f21f07f76f92ffc18e2aa.tar.gz firma-62e6c82a85dff975b11f21f07f76f92ffc18e2aa.tar.bz2 |
VERSION=0.3-CVS (instead of just 0.3) and cleaned up part of the command line parsing code.origin
-rwxr-xr-x | firma | 137 |
1 files changed, 66 insertions, 71 deletions
@@ -2472,7 +2472,7 @@ function ReplayProtectionCheck { # hardcode path to firma.conf, firma version and program name declare -r \ FIRMA_CONFIG_FILE="/usr/local/etc/firma.conf" \ - VERSION="0.3" \ + VERSION="0.3-CVS" \ BASENAME="$(basename $0)" # set environmental variables and options @@ -2616,99 +2616,94 @@ if [[ "$EXIT_CODE" == "0" ]]; then esac ;; 2) - # if firma.conf exists - if [[ -f "$FIRMA_CONFIG_FILE" ]]; then + # if firma.conf exists and can be read + if [[ ! -r "$FIRMA_CONFIG_FILE" ]]; then - # evaluate its parameters - SourceFirmaConfig - - # and finally check firma.conf parameters and permissions - if CheckFirmaConfigFile && CheckPermission $FIRMA_CONFIG_FILE; then + LogMessage "FATAL: Cannot source \`$FIRMA_CONFIG_FILE': No such file or directory" + EXIT_CODE=1 - LIST_NAME="$ARG" - LIST_PATH="$LISTS_DIR/$LIST_NAME" - LIST_CONFIG_FILE="$LIST_PATH/$LIST_NAME.conf" + # then source and evaluate its parameters + elif ! { SourceFirmaConfig && \ + CheckFirmaConfigFile && \ + CheckPermission "$FIRMA_CONFIG_FILE" + }; then - case "$OPTION" in + EXIT_CODE=1 - -c|--create-newlist) - NewList - EXIT_CODE=$? - ;; + else - # options that depend on the list configuration file - -a|--admin-task|-e|--email-admin-task|-p|--process-message) + LIST_NAME="$ARG" + LIST_PATH="$LISTS_DIR/$LIST_NAME" + LIST_CONFIG_FILE="$LIST_PATH/$LIST_NAME.conf" - # if config file exists - if [[ -f "$LIST_CONFIG_FILE" ]]; then + case "$OPTION" in - # eval list parameters - SourceListConfig + -c|--create-newlist) + NewList + EXIT_CODE=$? + ;; - # check its permissions - CheckListPermissions $LIST_CONFIG_FILE + # options that depend on the list configuration file + -a|--admin-task|-e|--email-admin-task|-p|--process-message) - # get gpg parameters - DeclareGpgVars + # if list config file exists and can be read + if [[ ! -r "$LIST_CONFIG_FILE" ]]; then - # check the list configuration file - if CheckListConfigFile; then + LogMessage "FATAL: Cannot source \`$LIST_CONFIG_FILE': No such file or directory" + EXIT_CODE=1 - case "$OPTION" in + # then source and evaluate its parameters + elif ! { SourceListConfig && \ + DeclareGpgVars && \ + CheckListPermissions "$LIST_CONFIG_FILE" && \ + CheckListConfigFile + }; then - -a|--admin-task) + EXIT_CODE=1 - MODE="admin-interactive" - # while a "quit" command isn't entered (returns 3), read STDIN - while (( $EXIT_CODE != 3 )) && read -rep "Command> " STDIN; do - # if line is not empty or commented, process command - if [[ -n "$STDIN" && "$STDIN" != "#"* ]]; then - ListAdministration $STDIN - EXIT_CODE=$? - fi - done + else - # since quit was entered, exit without error - EXIT_CODE=0 + case "$OPTION" in - ;; + -a|--admin-task) - -p|--process-message) - MODE="list-message" - ProcessMessage - EXIT_CODE=$? - ;; - -e|--email-admin-task) - MODE="admin-non-interactive" - ProcessMessage + MODE="admin-interactive" + # while a "quit" command isn't entered (returns 3), read STDIN + while (( $EXIT_CODE != 3 )) && read -rep "Command> " STDIN; do + # if line is not empty or commented, process command + if [[ -n "$STDIN" && "$STDIN" != "#"* ]]; then + ListAdministration $STDIN EXIT_CODE=$? - ;; + fi + done - esac - # else, list configuration file checking returned an error - else + # since quit was entered, exit without error + EXIT_CODE=0 + + ;; + + -p|--process-message) + MODE="list-message" + ProcessMessage EXIT_CODE=$? - fi - # else, list configuration file could not be found - else - LogMessage "FATAL: Cannot source \`$LIST_CONFIG_FILE': No such file or directory" - EXIT_CODE=1 - fi - ;; + ;; + -e|--email-admin-task) + MODE="admin-non-interactive" + ProcessMessage + EXIT_CODE=$? + ;; + + esac + + fi + ;; + + esac - esac - # else, firma.conf checking returned an error - else - EXIT_CODE=$? - fi - # else, firma.conf could not be found - else - LogMessage "FATAL: Cannot source \`$FIRMA_CONFIG_FILE': No such file or directory" - EXIT_CODE=1 fi ;; - esac + esac fi # exit |