Diff for /badi/public_scripts/parallelstarter/db_backup/generate_arglist between versions 1.1 and 1.2

version 1.1, 2011/07/18 11:49:04 version 1.2, 2012/09/06 20:23:54
Line 4 Line 4
 # step through DBLIST and convert each line   # step through DBLIST and convert each line 
 # into a set of command line args for db_backup  # into a set of command line args for db_backup
   
   
   # the default ports
   function getdefault_dbport { 
           if [ "$DBTYPE" = "mysql" ]; then
                   echo -n "3306"
           elif [ "$DBTYPE" = "postgresql" ]; then
                   echo -n "5432"
           fi
   }
   
   
 if [ -e "$ARGLIST_FILE" ]; then  if [ -e "$ARGLIST_FILE" ]; then
         rm "$ARGLIST_FILE"          rm "$ARGLIST_FILE"
 fi  fi
Line 20  while read dbinfo; do Line 31  while read dbinfo; do
                 continue                  continue
         fi          fi
   
         curhost="`echo $(echo "$dbinfo" | awk -F ':' '{print $1}')`"          curhost="`echo $(echo "$dbinfo" | awk -F ' : ' '{print $1}')`"
         curdb="`echo $(echo "$dbinfo" | awk -F ':' '{print $3}')`"      curdb="`echo $(echo "$dbinfo" | awk -F ' : ' '{print $3}')`"
         curuser="`echo $(echo "$dbinfo" | awk -F ':' '{print $4}')`"      curuser="`echo $(echo "$dbinfo" | awk -F ' : ' '{print $4}')`"
         curtype="`echo $(echo "$dbinfo" | awk -F ':' '{print $2}')`"      curtype="`echo $(echo "$dbinfo" | awk -F ' : ' '{print $2}')`"
         curpw="`echo $(echo "$dbinfo" | awk -F ':' '{print $5}')`"          curpw="`echo $(echo "$dbinfo" | awk -F ' : ' '{print $5}')`"
   
         echo "-h $curhost -D $curdb -u $curuser -c $DBLIST -t $curtype" >> "$ARGLIST_FILE"          curport="$(echo "$curhost" | sed -e "s/.*:\([0-9]\{1,\}\) *$/\1/")"
           if [ "$curhost" = "$curport" ]; then
                   curport="$(getdefault_dbport)"
           else
                   # remove port information from host string
                   curhost="$(echo "$curhost" | sed -e "s/\(.*\):[0-9]\{1,\} *$/\1/")"             
           fi
           echo "-h $curhost -p $curport -D $curdb -u $curuser -c $DBLIST -t $curtype" >> "$ARGLIST_FILE"
                   
         # write .pgpass in case there is a PostgreSQL DB involved          # write .pgpass in case there is a PostgreSQL DB involved
         if [ "$curtype" = "postgresql" ]; then          if [ "$curtype" = "postgresql" ]; then
Line 35  while read dbinfo; do Line 53  while read dbinfo; do
                         touch "$HOME/.pgpass"                          touch "$HOME/.pgpass"
                         chmod 600 "$HOME/.pgpass"                          chmod 600 "$HOME/.pgpass"
                 fi                  fi
                 if [ $(grep -c "$curhost:$PGPORT:$curdb:$curuser" "$HOME/.pgpass") -eq 0 ]; then                  if [ $(grep -c "$curhost:$curport:$curdb:$curuser" "$HOME/.pgpass") -eq 0 ]; then
                         # add the line to .pgpass                          # add the line to .pgpass
                         echo "$curhost:$PGPORT:$curdb:$curuser:$curpw" >> "$HOME/.pgpass"                          echo "$curhost:$curport:$curdb:$curuser:$curpw" >> "$HOME/.pgpass"
                 elif [ $(grep -c "$curhost:$PGPORT:$curdb:$curuser:$curpw" "$HOME/.pgpass") -eq 0 ]; then                  elif [ $(grep -c "$curhost:$curport:$curdb:$curuser:$curpw" "$HOME/.pgpass") -eq 0 ]; then
                         # the pw has changed; replace the password with new value                          # the pw has changed; replace the password with new value
                         mv "$HOME/.pgpass" "$HOME/.pgpass.old"                          mv "$HOME/.pgpass" "$HOME/.pgpass.old"
                         touch "$HOME/.pgpass"                          touch "$HOME/.pgpass"
                         chmod 600 "$HOME/.pgpass"                          chmod 600 "$HOME/.pgpass"
                         grep -v "$curhost:$PGPORT:$curdb:$curuser" "$HOME/.pgpass.old" >> "$HOME/.pgpass"                          grep -v "$curhost:$curport:$curdb:$curuser" "$HOME/.pgpass.old" >> "$HOME/.pgpass"
                         echo "$curhost:$PGPORT:$curdb:$curuser:$curpw" >> "$HOME/.pgpass"                          echo "$curhost:$curport:$curdb:$curuser:$curpw" >> "$HOME/.pgpass"
                 fi                  fi
         fi          fi
   

Removed from v.1.1  
changed lines
  Added in v.1.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>