lib/update.args
changeset 627 a81206440be2
parent 626 5cd99761fe4d
child 628 b10ad946d01d
equal deleted inserted replaced
626:5cd99761fe4d 627:a81206440be2
     1 #!/bin/bash
       
     2 # vim: set ft=sh :
       
     3 #
       
     4 # Command-line options
       
     5 
       
     6 ## Options
       
     7 
       
     8 SERIAL_NOOP=
       
     9 SERIAL_FORCE=
       
    10 
       
    11 COMMIT_SKIP=
       
    12 COMMIT_FORCE=
       
    13 COMMIT_MSG=' '
       
    14 
       
    15 RELOAD_NOOP=
       
    16 RELOAD_FORCE=
       
    17 
       
    18 ## Output command-line argument help.
       
    19 function help_args {
       
    20     local prog=$1
       
    21 
       
    22     cat <<END
       
    23 Usage: $prog [options]
       
    24 
       
    25 General:
       
    26     -h      display this help text
       
    27     -d DIR  datadir
       
    28 
       
    29 Logging:    
       
    30     -q      quiet
       
    31     -v      verbose
       
    32     -D      debug
       
    33     -V      debug commands
       
    34     
       
    35 Updates:
       
    36     -p      show changes
       
    37     -F      force-updates without checking src mtime
       
    38     -S      do not update serial
       
    39     -s      update serials
       
    40     -n      no-op/mock-update; don't actually change/deploy anything; implies -SpC
       
    41 
       
    42 Commit:
       
    43     -C      do not commit changes
       
    44     -c      commit changes
       
    45     -m MSG  commit message
       
    46 
       
    47 Deploy:
       
    48     -R      do not reload zones/dhcp
       
    49     -r      force reload zones/dhcp
       
    50 END
       
    51 }
       
    52 
       
    53 ## Parse any command-line arguments, setting the global options vars.
       
    54 function parse_args {
       
    55     OPTIND=1
       
    56 
       
    57     while getopts 'hd:qvDVpFSsnCcm:Rr' opt "$@"; do
       
    58         case $opt in
       
    59             h)  
       
    60                 help_args $0
       
    61                 exit 0
       
    62             ;;
       
    63 
       
    64             d)  SRV="$OPTARG" ;;
       
    65 
       
    66             q)  
       
    67                 LOG= 
       
    68                 LOG_WARN=
       
    69                 LOG_UPDATE=
       
    70                 LOG_FORCE=
       
    71                 LOG_NOOP=
       
    72                 LOG_DIFF=
       
    73                 ;;
       
    74 
       
    75             v)  LOG_SKIP=y ;;
       
    76             D)  
       
    77                 LOG_DEBUG=y
       
    78                 LOG_INFO=y
       
    79                 ;;
       
    80             V)  LOG_CMD=y ;;
       
    81 
       
    82             p)  UPDATE_DIFF=y   ;;
       
    83             F)  UPDATE_FORCE=y  ;;
       
    84             S)  SERIAL_NOOP=y   ;;
       
    85             s)  SERIAL_FORCE=y  ;;
       
    86  
       
    87             n)  
       
    88                 UPDATE_NOOP=y 
       
    89                 # implies -Sp
       
    90                 UPDATE_DIFF=y
       
    91                 SERIAL_NOOP=y
       
    92                 COMMIT_SKIP=y
       
    93                 RELOAD_NOOP=y
       
    94                 ;;
       
    95 
       
    96             C)  COMMIT_SKIP=y ;;
       
    97             c)  COMMIT_FORCE=y ;;
       
    98             m)  COMMIT_MSG="$OPTARG" ;;
       
    99 
       
   100             R)  RELOAD_NOOP=y   ;;
       
   101             r)  RELOAD_FORCE=y  ;;
       
   102            
       
   103             ?)  
       
   104                 die 
       
   105             ;;
       
   106         esac
       
   107 
       
   108     done
       
   109 }
       
   110 
       
   111