diff options
author | luis <luis> | 2007-08-19 15:40:54 +0000 |
---|---|---|
committer | luis <luis> | 2007-08-19 15:40:54 +0000 |
commit | a7e6b926b39c26b76b585fde53f4be6fc03a6998 (patch) | |
tree | eb36a19a58958e53569b3f5b80cf4673a9789fcd | |
parent | bec16fd176f4d16d322d61edaf70a61b18513a0b (diff) | |
download | firma-a7e6b926b39c26b76b585fde53f4be6fc03a6998.tar.gz firma-a7e6b926b39c26b76b585fde53f4be6fc03a6998.tar.bz2 |
- Set FIRMA_CONFIG_FILE, VERSION and BASENAME as readonly variables.
- Removed REPLAY_DEFAULT_FILE global variable.
-rwxr-xr-x | firma | 52 |
1 files changed, 29 insertions, 23 deletions
@@ -240,6 +240,7 @@ function CheckListConfigFile { local -i return_code=0 local administrator local valid_admins + local replay_default_file="/var/log/firma/replay.db" # check LIST_HOMEDIR value if [[ ! -d "$LIST_HOMEDIR" || \ @@ -372,7 +373,7 @@ WARNING: $LIST_NAME: Setting REPLAY_COUNT to '150' for this run." # check REPLAY_FILE value if [[ -z "$(echo "$REPLAY_FILE" | tr -d '[:space:]')" ]]; then - REPLAY_FILE="$REPLAY_DEFAULT_FILE" + REPLAY_FILE="$replay_default_file" fi touch "$REPLAY_FILE" 2> /dev/null @@ -2227,13 +2228,13 @@ function SourceFirmaConfig { [[ "$1" == "help" ]] && echo -e "\nOptional global firma config parameters\n" [[ "$1" == "help" ]] && echo -e "\tFIRMA_USER= user that runs firma (usually the same as your MTA user); -\t defaults to "nobody"; you can also specify this parameter +\t defaults to \"nobody\"; you can also specify this parameter \t in each mailing list config file if you plan to have one \t user per mailing list." || \ FIRMA_USER="$(EvalConfigParameter $FIRMA_CONFIG_FILE FIRMA_USER)" [[ "$1" == "help" ]] && echo -e "\tFIRMA_GROUP= group that runs firma (usually the same as your MTA group); -\t defaults to "nobody"; you can also specify this parameter +\t defaults to \"nobody\"; you can also specify this parameter \t in each mailing list config file if you plan to have one \t group per mailing list." || \ FIRMA_GROUP="$(EvalConfigParameter $FIRMA_CONFIG_FILE FIRMA_GROUP)" @@ -2293,14 +2294,14 @@ function SourceListConfig { LIST_HOMEDIR="$(EvalConfigParameter $LIST_CONFIG_FILE LIST_HOMEDIR)" [[ "$1" == "help" ]] && echo -e "\tFIRMA_USER= user that runs firma (usually the same as your MTA user); -\t defaults to "nobody"; you can also specify this parameter +\t defaults to \"nobody\"; you can also specify this parameter \t in each mailing list config file if you plan to have one \t user per mailing list." || \ firma_user="$(EvalConfigParameter $LIST_CONFIG_FILE FIRMA_USER)" [[ -n "$firma_user" ]] && FIRMA_USER="$firma_user" [[ "$1" == "help" ]] && echo -e "\tFIRMA_GROUP= group that runs firma (usually the same as your MTA group); -\t defaults to "nobody"; you can also specify this parameter +\t defaults to \"nobody\"; you can also specify this parameter \t in each mailing list config file if you plan to have one \t group per mailing list." || \ firma_group="$(EvalConfigParameter $LIST_CONFIG_FILE FIRMA_GROUP)" @@ -2368,7 +2369,7 @@ function SourceListConfig { [[ "$1" == "help" ]] && echo -e "\tREPLAY_FILE= file to store sha1sums of messages; \t only used when REPLAY_PROTECTION is set to '1'; -\t defaults to $REPLAY_DEFAULT_FILE." || \ +\t defaults to \"/var/log/firma/replay.db\"." || \ REPLAY_FILE="$(EvalConfigParameter $LIST_CONFIG_FILE REPLAY_FILE)" } @@ -2468,10 +2469,11 @@ function ReplayProtectionCheck { # main() #------------------------------------------------------------- -# path to firma.conf and firma version -FIRMA_CONFIG_FILE="/usr/local/etc/firma.conf" -REPLAY_DEFAULT_FILE="/var/log/firma/replay.db" -VERSION="0.3" +# hardcode path to firma.conf, firma version and program name +declare -r \ + FIRMA_CONFIG_FILE="/usr/local/etc/firma.conf" \ + VERSION="0.3" \ + BASENAME="$(basename $0)" # set environmental variables and options export LANG=en_US @@ -2480,13 +2482,17 @@ umask 0077 # set initial exit code EXIT_CODE=0 -# set program name -BASENAME="$(basename $0)" +# define the number of command line arguments, the option +#+being run and its argument, if any +declare -r \ + NUM_OF_ARGS="$#" \ + OPTION="$1" \ + ARG="$2" # command line parsing: # first check number of arguments, then check what was entered # start main case -case $# in +case $NUM_OF_ARGS in 0) echo >&2 "$BASENAME: missing arguments" Usage @@ -2494,7 +2500,7 @@ case $# in ;; 1) # start case #1 - case $1 in + case $OPTION in -h|--help) Usage EXIT_CODE=0 @@ -2510,7 +2516,7 @@ case $# in EXIT_CODE=1 ;; *) - echo >&2 "$BASENAME: invalid option -- $1" + echo >&2 "$BASENAME: invalid option -- $OPTION" Usage EXIT_CODE=1 ;; @@ -2527,12 +2533,12 @@ case $# in # and finally check firma.conf parameters and permissions if CheckFirmaConfigFile && CheckPermission $FIRMA_CONFIG_FILE; then - LIST_NAME="$2" + LIST_NAME="$ARG" LIST_PATH="$LISTS_DIR/$LIST_NAME" LIST_CONFIG_FILE="$LIST_PATH/$LIST_NAME.conf" # start case #2 - case $1 in + case $OPTION in -c|--create-newlist) NewList EXIT_CODE=$? @@ -2555,7 +2561,7 @@ case $# in if CheckListConfigFile; then # start case #3 - case $1 in + case $OPTION in -a|--admin-task) MODE="admin-interactive" @@ -2596,8 +2602,8 @@ case $# in ;; # valid option called with too many arguments -h|--help|-v|--version) - if [[ "$1" == "-h" || "$1" == "--help" ]]; then - ListAdministration $2 help + if [[ "$OPTION" == "-h" || "$OPTION" == "--help" ]]; then + ListAdministration $ARG help EXIT_CODE=$? else echo >&2 "$BASENAME: too many arguments -- $@" @@ -2606,7 +2612,7 @@ case $# in fi ;; *) - echo >&2 "$BASENAME: invalid option -- $1" + echo >&2 "$BASENAME: invalid option -- $OPTION" Usage EXIT_CODE=1 ;; @@ -2624,7 +2630,7 @@ case $# in ;; *) # start case #4 - case $1 in + case $OPTION in # again, valid option called with too many arguments -a|--admin-task|-e|--email-admin-task|-c|--create-newlist|-h|--help|-p|--process-message|-v|--version) echo >&2 "$BASENAME: too many arguments -- $@" @@ -2632,7 +2638,7 @@ case $# in EXIT_CODE=1 ;; *) - echo >&2 "$BASENAME: invalid option -- $1" + echo >&2 "$BASENAME: invalid option -- $OPTION" Usage EXIT_CODE=1 ;; |