Ignore:
Timestamp:
10/08/2007 17:12:27 (5 years ago)
Author:
arjun
Message:

Commiting 1.5.5a

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tags/confman-1.5.5a/confmanlib.sh

    r172 r177  
    1515# Checks out the conf tree if we don't already have it. Updates it if we do. 
    1616function conf_checkout_tree { 
    17         if [ ! -d ${WORK_PATH} ] ; then 
     17        if [ ! -d ${WORK_PATH}/.svn ] ; then 
    1818                        local path=`echo ${WORK_PATH} | sed -E 's:/[^/]+$::'` 
    1919                        mkdir -p ${WORK_PATH} 
     
    3939function conf_update_tree { 
    4040        svn update ${WORK_PATH} 
     41} 
     42 
     43function conf_setup_lock { 
     44    if [ -f ${WORK_PATH}/confman.lock ] 
     45    then 
     46        return 1 
     47    else 
     48        touch ${WORK_PATH}/confman.lock 
     49        echo $$ > "${WORK_PATH}/confman.lock" #Send PID to the lock to allow for recursive calls 
     50        return 0 
     51    fi 
     52} 
     53 
     54function conf_lock_wcopy { 
     55    if [ ! -d ${WORK_PATH}/.svn ] 
     56    then 
     57        echo "${WORK_PATH} is not a valid svn working copy or does not exist." >&4 
     58        exit 1 
     59    fi 
     60    if [ -f ${WORK_PATH}/confman.lock ] 
     61    then 
     62        return 1 
     63    else 
     64        touch ${WORK_PATH}/confman.lock 
     65        echo $$ > "${WORK_PATH}/confman.lock" #Send PID to the lock to allow for recursive calls 
     66        return 0 
     67    fi 
     68} 
     69 
     70function conf_unlock_wcopy { 
     71    if [ -f ${WORK_PATH}/confman.lock ] 
     72    then 
     73        rm ${WORK_PATH}/confman.lock 
     74    fi 
     75} 
     76 
     77function conf_lock_system { 
     78    if [ -f /var/run/confman.lock ] 
     79    then 
     80        return 1 
     81    else 
     82        sudo touch /var/run/confman.lock 
     83        sudo chmod 666 /var/run/confman.lock 
     84        sudo echo $$ > "/var/run/confman.lock"  
     85        return 1 
     86    fi 
     87} 
     88 
     89function conf_unlock_system { 
     90    if [ -f /var/run/confman.lock ] 
     91    then 
     92        sudo rm /var/run/confman.lock 
     93    fi 
     94} 
     95 
     96function conf_wcopy_locked? { 
     97    if [ -f ${WORK_PATH}/confman.lock ] 
     98    then 
     99        return 0 
     100    else 
     101        return 1 
     102    fi 
     103} 
     104 
     105function conf_system_locked? { 
     106    if [ -f /var/run/confman.lock ] 
     107    then 
     108        return 0 
     109    else 
     110        return 1 
     111    fi 
    41112} 
    42113 
     
    377448        svn mv ${WORK_PATH}/${oldmod} ${WORK_PATH}/${newmod} || \ 
    378449                {       echo "There was a problem renaming the modules." >&4 ; \ 
    379                         conf_clean_exit 1  
     450                        conf_cleanExit 1  
    380451                } 
    381452        svn mv ${WORK_PATH}/${REPO_CHECKPTS}/${oldmod} \ 
    382453                        ${WORK_PATH}/${REPO_CHECKPTS}/${newmod} || \ 
    383454                {       echo "There was a problem renaming the checkpts." >&4 ; \ 
    384                         conf_clean_exit 1  
     455                        conf_cleanExit 1  
    385456                } 
    386457 
    387458        svn update ${WORK_PATH} || \ 
    388459                {       echo "Your working copy didn't update correctly." >&4 ; \ 
    389                         conf_clean_exit 1  
     460                        conf_cleanExit 1  
    390461                } 
    391462        svn commit -m "Renaming ${oldmod} to ${newmod}, phase 1." \ 
    392463                ${WORK_PATH}/{,${REPO_CHECKPTS}}/{${oldmod},${newmod}} || \ 
    393                 {       echo "Committing the changes failed." >&4 ; conf_clean_exit 1  
     464                {       echo "Committing the changes failed." >&4 ; conf_cleanExit 1  
    394465                } 
    395466 
     
    404475        svn update ${WORK_PATH} || \ 
    405476                {       echo "Your working copy didn't update correctly." >&4 ; \ 
    406                         conf_clean_exit 1  
     477                        conf_cleanExit 1  
    407478                } 
    408479        svn commit -m "Renaming ${oldmod} to ${newmod}, phase 2." \ 
    409480                ${WORK_PATH}/${newmod} || \ 
    410                 {       echo "Committing the changes failed." >&4 ; conf_clean_exit 1  
     481                {       echo "Committing the changes failed." >&4 ; conf_cleanExit 1  
    411482                } 
    412483 
     
    418489        svn update ${WORK_PATH} || \ 
    419490                {       echo "Your working copy didn't update correctly." >&4 ; \ 
    420                         conf_clean_exit 1  
     491                        conf_cleanExit 1  
    421492                } 
    422493        svn commit -m "Renaming ${oldmod} to ${newmod}, complete." \ 
    423494                ${WORK_PATH}/${newmod} || \ 
    424                 {       echo "Committing the changes failed." >&4 ; conf_clean_exit 1  
     495                {       echo "Committing the changes failed." >&4 ; conf_cleanExit 1  
    425496                } 
    426497} 
     
    536607# The SIGNAL seems to kill the logger process spawned by the parent  
    537608# process, which is receiving its input from our fd 2. 
    538 function conf_cleanexit { 
     609function conf_cleanExit { 
    539610    echo "Received a signal. Exiting cleanly." | conf_logger 
    540611        echo "Abort, Abort! Patience is a virtue." >&4 
     
    544615        # permissions here to be in a consistent state. 
    545616        chmod 700 ${WORK_PATH} 
    546  
    547617        echo "Removing leftover temp files..." >&4 
    548618        find /tmp/confman* -maxdepth 0 -user `whoami` -exec rm -rf {} \; 
     
    551621        echo "Undoing damage to your working copy..." >&4 
    552622        [ -d "${WORK_PATH}" ] && svn cleanup ${WORK_PATH} 
    553         echo "All clean. Terminating." >&4 
     623 
     624    echo "Removing any system or working copy locks..." >&4 
     625    conf_unlock_wcopy 
     626    conf_unlock_system 
     627         
     628    echo "All clean. Terminating." >&4 
    554629 
    555630        exit ${1:-1} 
    556631}        
    557632 
     633function conf_checkgroup { 
     634        GROUP_FILE=$(mktemp -t confman) 
     635    GROUP_STAT=$(chgrp staff $GROUP_FILE 2>&1) 
     636        rm $GROUP_FILE 
     637        if [ -n "$GROUP_STAT" ] ; then 
     638       return 2 
     639    else 
     640       return 0 
     641    fi 
     642} 
     643 
    558644# vim:ts=4 
    559645 
Note: See TracChangeset for help on using the changeset viewer.