Changeset 3 for trunk/dsys


Ignore:
Timestamp:
Dec 21, 2005, 10:07:54 PM (19 years ago)
Author:
rainer
Message:

More fixes for update function, released 2.1.1 version.

Location:
trunk/dsys
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/dsys/comINSTALL

    r1 r3  
    340340    #---------------------------------------------------------------------
    341341
     342    instlock="${yule_conf}.lockdir";
     343    trap "rm -rf ${instlock}" 1 2 13 15
     344
     345    if test x"$simulate" = x0
     346    then
     347        #
     348        # A lockfile will not work, because 'root' can write anyway.
     349        # However, 'mkdir' an existing directory will fail even for root
     350        #
     351        until (umask 222; mkdir "${instlock}") 2>/dev/null   # test & set
     352        do
     353           printINFO "Waiting for lock"
     354           sleep 1
     355        done
     356    fi
     357
    342358    Replace=`"${yule_exec}" -P "${is_passwd}" | sed s%HOSTNAME%${host}%g`
    343359    if test "x$Replace" = x
    344360    then
     361        rm -rf "${instlock}"
    345362        printFATAL "Could not execute ${yule_exec} -P ${is_passwd}."
    346363    fi
     
    356373            then
    357374                Seen=y
    358                 echo "$Replace" >>"$tmpF" || printFATAL "Cannot write new server configuration."
     375                echo "$Replace" >>"$tmpF"
     376                if [ $? -ne 0 ]; then
     377                        rm -rf "${instlock}"
     378                        printFATAL "Cannot write new server configuration."
     379                fi
    359380            fi
    360381        else
     
    363384                :
    364385            else
    365                 echo "$line" >>"$tmpF" || printFATAL "Cannot write new server configuration."
     386                echo "$line" >>"$tmpF"
     387                if [ $? -ne 0 ]; then
     388                        rm -rf "${instlock}"
     389                        printFATAL "Cannot write new server configuration."
     390                fi
    366391            fi
    367392        fi
     
    380405    if test x"$simulate" = x0
    381406    then
    382         ageFILE "${yule_conf}" || printFATAL "Could not backup ${yule_conf}."
    383         rm -f "${yule_conf}" && { cp "$tmpF"  "${yule_conf}" || printFATAL "Could not write new server config. Backup is ${yule_conf}.1"; }
    384         chown ${rcfile_owner}:${rcfile_group} "${yule_conf}" || printFATAL "Could not chown ${rcfile_owner}:${rcfile_group} ${yule_conf}"
    385         chmod ${rcfile_perm} "${yule_conf}" || printFATAL "Could not chmod ${rcfile_perm} ${yule_conf}"
     407        ageFILE "${yule_conf}"
     408        if [ $? -ne 0 ]; then
     409                rm -rf "${instlock}"
     410                printFATAL "Could not backup ${yule_conf}"
     411        fi
     412
     413        rm -f "${yule_conf}" && cp "$tmpF"  "${yule_conf}"
     414        if [ $? -ne 0 ]; then
     415                rm -rf "${instlock}"
     416                printFATAL "Could not write new server config. Backup is ${yule_conf}.1"
     417        fi
     418
     419        chown ${rcfile_owner}:${rcfile_group} "${yule_conf}"
     420        if [ $? -ne 0 ]; then
     421                rm -rf "${instlock}"
     422                printFATAL "Could not chown ${rcfile_owner}:${rcfile_group} ${yule_conf}"
     423        fi
     424
     425        chmod ${rcfile_perm} "${yule_conf}"
     426        if [ $? -ne 0 ]; then
     427                rm -rf "${instlock}"
     428                printFATAL "Could not chmod ${rcfile_perm} ${yule_conf}"
     429        fi
    386430    else
    387431        printINFO "Backup and update ${yule_conf}"
     
    423467        sleep 5
    424468        #
     469        rm -rf "${instlock}"
    425470    else
    426471        printINFO "Reloading server configuration."
     
    428473
    429474    printLOG "Server configuration updated and reloaded."
     475
    430476
    431477    #---------------------------------------------------------------------
  • trunk/dsys/funcINSTALL

    r1 r3  
    9191        DATABASE="${basedir}/${defdatabase}"
    9292    fi
     93
     94    updlock="${DATABASE}.lockdir"
     95    trap "rm -rf ${updlock}" 1 2 13 15
     96
     97    #
     98    # A lockfile will not work, because 'root' can write anyway.
     99    # However, 'mkdir' an existing directory will fail even for root
     100    #
     101    until (umask 222; mkdir "${updlock}") 2>/dev/null   # test & set
     102    do
     103       printINFO "Waiting for lock"
     104       sleep 1
     105    done
     106
    93107
    94108    IDATE=`date +"%Y-%m-%d %H:%M:%S"`
     
    223237    fi
    224238
    225     chown ${rcfile_owner}:${rcfile_group} "${DATABASE}" || printFATAL "Could not chown ${rcfile_owner}:${rcfile_group} ${DATABASE}"
    226     chmod ${rcfile_perm} "${DATABASE}" || printFATAL "Could not chmod ${rcfile_perm} ${DATABASE}"
    227 
     239    chown ${rcfile_owner}:${rcfile_group} "${DATABASE}"
     240    if [ $? -ne 0 ]; then
     241        rm -rf "${instlock}"
     242        printFATAL "Could not chown ${rcfile_owner}:${rcfile_group} ${DATABASE}"
     243    fi
     244    chmod ${rcfile_perm} "${DATABASE}"
     245    if [ $? -ne 0 ]; then
     246        rm -rf "${instlock}"
     247        printFATAL "Could not chmod ${rcfile_perm} ${DATABASE}"
     248    fi
     249
     250    rm -rf "${updlock}"
    228251}
    229252
Note: See TracChangeset for help on using the changeset viewer.