Ignore:
Timestamp:
12/04/2006 01:32:20 (5 years ago)
Author:
ccowart
Message:

Modularized some parts of confman for reuse. Used these elements in the
new roll-and-pull features available.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/confman/confmanlib.sh

    r117 r120  
    5555# Commits module $1 with message $2 
    5656function conf_commit { 
    57         local module=$1 
     57        local modules=$(echo $modules | tr ' ' ',') 
    5858        local msg="$2" 
    59         svn commit -F "$msg" ${WORK_PATH}/$module 
     59 
     60    # $modules is in the form foo,bar,baz. This eval trick forces 
     61    # curly brace expansion. 
     62        svn commit -F "$msg" $(eval echo foo/{$modules}) 
     63} 
     64 
     65function conf_fetch { 
     66    local tmpfile=`mktemp -t confman` 
     67    local proto="${CONF_EXPORT_URI%:/*}" 
     68    local remote 
     69 
     70    case $proto in 
     71        sftp|scp)    
     72            remote="${CONF_EXPORT_URI#*://}" 
     73            remote="${remote/\//:/}" 
     74            scp $remote $tmpfile  
     75            ;; 
     76        http|https|ftp) 
     77            fetch -o $tmpfile $remote 
     78            ;; 
     79        file) 
     80            remote="${CONF_EXPORT_URI#*://}" 
     81            cp $remote $tmpfile 
     82            ;; 
     83        *) 
     84            echo "Unsupported Protocol in conf_fetch" >&2 
     85            return 1 
     86            ;; 
     87    esac 
     88    echo $tmpfile 
     89    return 0 
    6090} 
    6191 
     
    6393function conf_status { 
    6494        svn status $* 
     95} 
     96 
     97# This exports a working copy of the repository to a tarball 
     98function conf_export { 
     99    local tmpdir=`mktemp -d -t confman` 
     100    local tarball="$1" 
     101    svn checkout "${REPO_URI}" "${tmpdir}/conf" 
     102    tar -czf "$tarball" -C "$tmpdir" conf 
     103    rm -rf "$tmpdir" 
    65104} 
    66105 
     
    400439} 
    401440 
     441# Accepts log messages on stdin until EOF 
     442function conf_logger { 
     443   cat | logger -t "$MYNAME[$$]: $USER" -s 
     444} 
     445 
    402446# WARNING: If you refer to fd 2 in this code, this function will silently 
    403447# fail when called by trap. DO NOT ATTEMPT TO LOG TO fd 2 IN THIS FUNCTION! 
     
    405449# process, which is receiving its input from our fd 2. 
    406450function conf_cleanexit { 
     451    echo "Confman received a signal. Exiting cleanly." | conf_logger 
    407452        echo "Abort, Abort! Patience is a virtue." >&4 
    408453        echo "Please wait until I finish cleaning up after you." >&4 
    409  
    410         echo "Removing leftover temp files..." >&4 
    411         find /tmp -maxdepth 1 -user `whoami` -name 'confman*' -exec rm -f {} \; 
    412454 
    413455        # And in case we got an interrupt during a rollout, we still want the 
     
    415457        chmod 700 ${WORK_PATH} 
    416458 
     459        echo "Removing leftover temp files..." >&4 
     460        find /tmp -maxdepth 1 -user `whoami` -name 'confman*' -exec rm -rf {} \; 
     461 
    417462        # And this clears any locks we may have created on our working copy: 
    418463        echo "Undoing damage to your working copy..." >&4 
    419         svn cleanup ${WORK_PATH} 
     464        [ -d "${WORK_PATH}" ] && svn cleanup ${WORK_PATH} 
    420465        echo "All clean. Terminating." >&4 
    421466 
Note: See TracChangeset for help on using the changeset viewer.