Changeset 181

Show
Ignore:
Timestamp:
09/16/06 15:01:57 (2 years ago)
Author:
lunar
Message:

Load /tmp/tmp.ciOCm13901/metche-1.1 into
debian/branches/upstream/current.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • debian/branches/upstream/current/Changelog

    r115 r181  
    1 02-17-2006 - metche 1.0 
     11.1 (2006 09 16) 
     2 
     3        * ververs: added Linux VServers support. 
     4        * EXCLUDES: added a few everchanging Postfix files, and AlternC's 
     5          local.sh 
     6        * documentation: clear up the way backups are made (Closes: #365694) 
     7 
     81.0 (2006 02 17) 
    29 
    310        * Initial release. 
    4  
  • debian/branches/upstream/current/INSTALL

    r115 r181  
    33`------------------------------------------------------------------------------- 
    44 
    5 1. Have a look to the REQUIREMENTS section in the README file. 
     51. Have a look at the REQUIREMENTS section in the README file. 
    662. Copy the metche executable to /usr/local/sbin/ 
    7 3. As root, mkdir /var/lib/metche 
    8 4. Copy the manpage (metche.8) to /usr/local/man/man8/ 
    9 5. Read the README file and the manpage 
     73. Copy the manpage (metche.8) to /usr/local/man/man8/ 
     84. Read the README file, the FAQ and the manpage 
    109 
  • debian/branches/upstream/current/README

    r115 r181  
    11metche - reducing root bus factor 
    2 homepage : https://poivron.org/dev/metche/ 
     2homepage: https://poivron.org/dev/metche/ 
     3dev team: metche AT lists DOT riseup DOT net 
    34 
    45,------------------------------------------------------------------------------- 
     
    2324`------------------------------------------------------------------------------- 
    2425 
    25 metche is a tool meant to facilitate collective sysadmin ; basically, it 
     26metche is a tool meant to ease collective system administration. It does 
    2627periodically : 
    27    - saves the "system state" to $BACKUP_DIR (default /var/lib/metche), i.e. : 
     28   - save the "system state" of  
    2829      . $WATCHED_DIR (default: /etc) 
    2930      . $CHANGELOG_FILE (default /root/Changelog) 
    3031        or $CHANGELOG_DIR/*/Changelog (default: /root/changelogs/*/Changelog) 
    3132      . Debian packages states and versions (using apt-show-versions) 
    32    - sends you, in a nicely formated email, the last changes to the "system 
    33      state"; see https://poivron.org/dev/metche/ for an example. 
     33     to $BACKUP_DIR (default: /var/lib/metche). 
     34   - send a nicely formatted email to a defined email address, listing the last 
     35     changes that have been made to the system. 
     36     See https://poivron.org/dev/metche/ for an example.  
    3437 
    3538,------------------------------------------------------------------------------- 
     
    3740`------------------------------------------------------------------------------- 
    3841 
    39 When installed and configured, metche is run by a cronjob, and you just have to 
    40 read the report emails. Of course, it's not useful at all if you don't
    41    - set $EMAIL_ADDRESS config variable to your sysadmin collective mailing-list 
    42      address
     42When installed and configured, metche is run by a cron job. You just have to 
     43read the report emails. Of course it's not useful at all if you don't
     44   - set the $EMAIL_ADDRESS config variable to your sysadmins' collective  
     45     mailing-list or email address
    4346   - use the Changelog files in a rigorous way. 
    4447 
    45 Note: it is dangerous to use metche without before reading the SECURITY section 
    46 of the manpage
     48Note: It is dangerous to use metche without reading the SECURITY section 
     49of the manpage before
    4750 
    48 For a deeper explanation of the way metche works, read the metche(8) manpage. 
     51For further explanation of the way metche works, read the metche(8) manpage and 
     52the FAQ file. 
    4953 
    5054,------------------------------------------------------------------------------- 
     
    5256`------------------------------------------------------------------------------- 
    5357 
    54    * Debian GNU/Linux and apt-show-versions (if Debian packages monitoring is 
    55     enabled) 
     58   * Debian GNU/Linux and apt-show-versions (if Debian package monitoring is 
     59    enabled) 
    5660   * mutt 
    5761   * bzip2 
    58    * If you want metche to encrypt the email it sends you : gnupg 
    59    * If you want metche to monitor your vservers as well : util-vserver tools 
     62   * If you want metche to encrypt the email it sends: gnupg 
     63   * If you want metche to monitor your vservers as well: util-vserver tools 
    6064   * If you want metche to monitor one manually written Changelog file, 
    6165     it must be located at $CHANGELOG_FILE. 
    6266_or_ If you want metche to monitor multiple manually written Changelog 
    63      files, they must be located in $CHANGELOG_DIR/*/Changelog
    64      for example, you can have
     67     files, they must be located in $CHANGELOG_DIR/*/Changelog
     68     for example this way
    6569        /root/ 
    6670            changelogs/ 
     
    7377`------------------------------------------------------------------------------- 
    7478 
    75 See the included INSTALL file. 
     79Please see the included INSTALL file. 
    7680 
    7781,------------------------------------------------------------------------------- 
     
    8286   your needs. 
    83872. Read the next sections of this document and the metche(8) manpage. 
    84 3. Add to /etc/cron.d/metche something like
     883. Add to /etc/cron.d/metche something like
    8589     0-59/5 * * * * root test -x /usr/local/sbin/metche && \ 
    8690                         /usr/local/sbin/metche cron 
     91   See the cron (8) manpage for further explanations on how to create a cron  
     92   job. 
    8793 
    8894,------------------------------------------------------------------------------- 
    89 | SECURITY : BIG FAT WARNING 
     95| VSERVERS SUPPORT 
     96`------------------------------------------------------------------------------- 
     97 
     98Just add one (or more) VServer name to the VSNAMES configuration variable, and 
     99metche will monitor it in addition to the host system: 
     100   - the WATCHED_DIR, CHANGELOG_DIR and CHANGELOG_FILE paths are also used, 
     101     relatively to your VServer's root directory; 
     102   - the "system state" backups will be saved in sub-directory in BACKUP_DIR's, 
     103     called the same as the VServer; 
     104   - EMAIL_ADDRESS is not used for the VServers: the report messages will be 
     105     sent to the your VServer's root email address; if you're using 
     106     ENCRYPT_EMAIL to encrypt the report messages, make sure their public key is 
     107     in the host system root's keyring, trusted enough to be used blindly by 
     108     metche; 
     109   - all other configuration variables are used as it. 
     110 
     111Most of metche commands (namely: list, report and stabilize) support a 
     112'-h <VSERVER>' option: 
     113   - if -h is specified, metche only operates on the VServer provided as an 
     114     argument; 
     115   - else, metche only operates on the host system. 
     116 
     117Troubleshooting: in case you have a not-purely-Debianish VServer setup, you may 
     118have to customize some of the VServers-related configuration variables. See the 
     119comments in metche.conf for more details. 
     120 
     121,------------------------------------------------------------------------------- 
     122| SECURITY WARNING 
    90123`------------------------------------------------------------------------------- 
    91124 
    92125Read the SECURITY section of metche(8). Really. 
    93126 
    94 ,------------------------------------------------------------------------------- 
    95 | FAQ 
    96 `------------------------------------------------------------------------------- 
    97  
    98 1. How are the monitored Changelog files ($CHANGELOG_FILE or 
    99    $CHANGELOG_DIR/*/Changelog) generated ? 
    100  
    101    With Emacs or Vim. Ah ah. They are written by *you* ! They are an important 
    102    part of the collective sysadmin process metche is supposed to facilitate. 
    103  
    104 2. Hey, how is metche working, and what are the underlying concepts I have to 
    105    know ? 
    106  
    107    When called with the "cron" command line switch, metche looks if the "system 
    108    state" has changed in the last $TESTING_TIME minutes. If it is the case, a 
    109    "unstable" state is saved. Otherwise, a "testing state" is saved, and a 
    110    report is emailed to you. 
    111  
    112    A similar mechanism to automatically turn a "testing" state into a "stable" 
    113    one ; see metche(8) for explainations. 
    114  
    115 3. How do I see the saved states list ? 
    116  
    117    Run "metche list". 
    118  
    119 4. I've broken my system, how can I see a report against a previous, known 
    120    working, system state ? 
    121  
    122    Run "metche report [{stable,testing,unstable}-YYYYMMDDHHMM]". 
    123    If no saved state is specified, the latest "testing state" is used as 
    124    reference. 
    125  
    126 5. How do I create a "stable state" by hand ? 
    127  
    128    Run "metche stabilize [testing-YYYYMMDDHHMM]". 
    129    This turns the given testing state, if specified, or the latest one, 
    130    otherwise, into a "stable state". 
  • debian/branches/upstream/current/metche

    • Property svn:executable set to *
    r115 r181  
    11#! /bin/bash 
    22# -*- mode: sh; sh-basic-offset: 4; indent-tabs-mode: nil; -*- 
     3# 
     4# SVN version: $Id: metche 176 2006-09-15 15:31:11Z intrigeri $ 
     5# $URL: http://poivron.org/dev/svn/metche/upstream/tags/metche-1.1/metche $ 
    36# 
    47#  metche: reducing root bus factor 
     
    2831 
    2932display_usage() { 
    30     ( echo "Usage: `basename $0` list"  
    31       echo "       `basename $0` report" \ 
     33    ( echo "Usage:" 
     34      echo "       `basename $0` [-h VSERVER] list"  
     35      echo "       `basename $0` [-h VSERVER] report" \ 
    3236           "[{stable|testing|unstable}-YYYYMMDDHHMM]" 
     37      echo "       `basename $0` [-h VSERVER] stabilize [testing-YYYYMMDDHHMM]" 
     38      echo "" 
     39      echo "       With -h, the VServer VSERVER is operated on instead of the host system." 
     40      echo "" 
     41      echo "Non-interactive usage:" 
    3342      echo "       `basename $0` cron" 
    34       echo "       `basename $0` stabilize [testing-YYYYMMDDHHMM]" 
    3543      echo "" 
    3644    ) >&2 
     
    3846 
    3947fatal() { 
    40     echo -e "$@" >&2 
     48    echo -e "Fatal:   $@" >&2 
    4149    exit 2 
     50} 
     51 
     52warning() { 
     53    echo -e "Warning: $@" >&2 
     54} 
     55 
     56debug() { 
     57    [ "$DEBUG" != yes ] || echo -e "Debug:   $@" >&2 
    4258} 
    4359 
     
    4561    local executable="$1" 
    4662    local software="$2" 
    47     local option="$3" 
    48  
    49     fatal "$executable not found. Please install $software or turn $option off." 
    50 
    51  
    52 debug() { 
    53     [ "$DEBUG" != yes ] || echo -e "debug: $@" >&2 
     63    local dependant_option="$3" 
     64    local solution_option="$4" 
     65 
     66    if [ -z "$solution_option" ]; then 
     67        fatal "$executable not found on `current_system`." \ 
     68              "Please install $software or turn $dependant_option off." 
     69    else 
     70        fatal "$executable not found on `current_system`." \ 
     71              "Please install $software, customize $solution_option" \ 
     72              "or turn $dependant_option off." 
     73    fi 
    5474} 
    5575 
    5676email() { 
    57     debug "email $@
    58     local subject="$_MAIL_SUBJECT : $1" 
     77    debug "* email $@ to $EMAIL_ADDRESS
     78    local subject="`current_system` - $_MAIL_SUBJECT : $1" 
    5979    if [ $ENCRYPT_EMAIL = "yes" ]; then 
    6080        LC_ALL="$LOCALE" gpg --batch --armor --encrypt \ 
     
    6484        LC_ALL="$LOCALE" mutt -s "$subject" "$EMAIL_ADDRESS" 
    6585    fi 
     86} 
     87 
     88current_system() { 
     89    $VSERVER_EXEC_PREFIX hostname -f 
    6690} 
    6791 
     
    83107EMAIL_ADDRESS="root@`hostname -f`" 
    84108ENCRYPT_EMAIL="no" 
    85 EXCLUDES="*.swp #* *~ *.key ifstate adjtime ld.so.cache shadow* \ 
    86           blkid.tab* aumixrc net.enable mtab \ 
    87           vdirbase run.rev vdir run.rev" 
     109EXCLUDES="*.swp #* *~ *.gpg *.key ifstate adjtime ld.so.cache shadow* \ 
     110          .gnupg blkid.tab* aumixrc net.enable mtab backup.d \ 
     111          vdirbase run.rev vdir run.rev \ 
     112          prng_exch smtp_scache.pag smtpd_scache.pag \ 
     113          smtp_scache.dir smtpd_scache.dir local.sh" 
    88114LOCALE="C" 
    89115 
    90 _MAIL_SUBJECT="`hostname -f` - changes report" 
     116VSNAMES="" 
     117VSERVERINFO=/usr/sbin/vserver-info 
     118VSERVER=/usr/sbin/vserver 
     119 
     120_MAIL_SUBJECT="changes report" 
    91121_NO_DEBIAN_PACKAGES_CHANGE="No change in Debian packages state." 
    92122_NO_CHANGE="No change." 
     
    127157 
    128158if [ "$1" = "-h" ]; then 
    129     if [ -f /etc/metche/$2.conf ]; then 
    130         . /etc/metche/$2.conf 
    131         CMD="$3" 
    132         MILESTONE="$4" 
    133     else 
    134         display_usage 
    135         fatal "Config file /etc/metche/$2.conf does not exist." 
    136     fi 
    137 elif [ -f /etc/metche.conf ]; then 
    138     . /etc/metche.conf 
     159    VSNAME="$2" 
     160    CMD="$3" 
     161    MILESTONE="$4" 
     162else 
    139163    CMD="$1" 
    140164    MILESTONE="$2" 
     165fi 
     166 
     167if [ -f /etc/metche.conf ]; then 
     168    . /etc/metche.conf 
    141169else 
    142170    display_usage 
     
    151179umask 077 
    152180 
    153 test -d "$WATCHED_DIR" || fatal "WATCHED_DIR ($WATCHED_DIR) does not exist." 
    154 test -d "$BACKUP_DIR"  || fatal "BACKUP_DIR ($BACKUP_DIR) does not exist." 
    155 test -z "$TAR_OPTS"    || fatal "TAR_OPTS is deprecated, use EXCLUDES instead." 
    156  
    157 if [ "$DO_PACKAGES" = "yes" ]; then 
    158     which apt-show-versions > /dev/null || 
    159         executable_not_found "apt-show-versions" "it" "DO_PACKAGES" 
     181# Manage deprecated configuration files and options 
     182test ! -d /etc/metche || fatal "An old configuration directory (/etc/metche/)" \ 
     183                               "was found, please upgrade your configuration." 
     184test -z "$TAR_OPTS"   || fatal "TAR_OPTS is deprecated, use EXCLUDES instead." 
     185 
     186# Backup various configuration values: these non-underscored variable 
     187# names will be re-initialized in context_config() and re-used everywhere. 
     188_WATCHED_DIR="$WATCHED_DIR" 
     189_BACKUP_DIR="$BACKUP_DIR" 
     190_CHANGELOG_DIR="$CHANGELOG_DIR" 
     191_CHANGELOG_FILE="$CHANGELOG_FILE" 
     192_DO_PACKAGES="$DO_PACKAGES" 
     193_EMAIL_ADDRESS="$EMAIL_ADDRESS" 
     194 
     195if [ -n "$VSNAMES" ]; then 
     196    # check VSERVERINFO and VSERVER availability 
     197    test -x "$VSERVERINFO" || \ 
     198        executable_not_found "vserver-info" "util-vserver" "VSNAMES" "VSERVERINFO" 
     199    test -x "$VSERVER"     || \ 
     200        executable_not_found "vserver" "util-vserver" "VSNAMES" "VSERVER" 
     201    # check VROOTDIR availability 
     202    test -n "$VROOTDIR"    || \ 
     203        VROOTDIR="`$VSERVERINFO info SYSINFO \ 
     204                   | grep '^ *vserver-Rootdir' | awk '{print $2}'`" 
     205    test -n "$VROOTDIR"    || \ 
     206        fatal "VSNAMES is not empty, but VROOTDIR could not be guessed." \ 
     207              "Please set VROOTDIR in /etc/metche.conf." 
     208    test -d "$VROOTDIR"    || \ 
     209        fatal "VSNAMES is not empty, but VROOTDIR ($VROOTDIR) does not exist." \ 
     210              "Please set VROOTDIR in /etc/metche.conf." 
     211    # expand VSNAMES if it is set to "all" 
     212    if [ "$VSNAMES" = all ]; then 
     213        VSNAMES=`ls $VROOTDIR | grep -E -v "lost\+found|ARCHIVES" | tr "\n" " "` 
     214        if [ -z "$VSNAMES" ]; then 
     215            warning "VSNAMES is set to \"all\", but no VServer could be found" \ 
     216                    "in VROOTDIR ($VROOTDIR)." 
     217        fi 
     218    fi 
    160219fi 
    161220 
    162221if [ "$ENCRYPT_EMAIL" = "yes" ]; then 
    163222    which gpg > /dev/null || 
    164         executable_not_found "gpg" "GnuPG" "ENCRPYT_EMAIL" 
    165     gpg --batch --list-public-keys $EMAIL_ADDRESS >/dev/null 2>&1 || 
    166         fatal "GnuPG public key for $EMAIL_ADDRESS not found." 
     223        executable_not_found "gpg" "GnuPG" "ENCRYPT_EMAIL" 
    167224fi 
    168225 
    169226DATE=`date "+%Y%m%d%H%M"` 
    170 WATCHED_PARENT=`dirname $WATCHED_DIR` 
    171 if [ "$WATCHED_PARENT" != '/' ]; then 
    172     WATCHED_PARENT="$WATCHED_PARENT/" 
    173 fi 
    174227 
    175228# How to use $TAR_OPTS: 
     
    198251set +o noglob 
    199252 
    200 ### 
    201 ### Modules enabling/disabling 
    202 ### 
    203  
    204 DO_CHANGELOGS="no" 
    205 if [ "$CHANGELOG_DIR" ]; then 
    206     if [ -d "$CHANGELOG_DIR" ]; then 
    207         DO_CHANGELOGS="dir" 
    208     fi 
    209 elif [ -f "$CHANGELOG_FILE" ]; then 
    210     DO_CHANGELOGS="file" 
    211 fi 
    212  
    213 # Debian packages 
    214 # Enabled/disabled by $DO_PACKAGES, initialized to "yes", can be 
    215 # overriden by the sourced conf file. 
    216  
    217253 
    218254### 
    219255### A few functions to do the real work 
    220256### 
     257 
     258# Check and mangle the context-dependant configuration variables, 
     259# i.e. the parameters specific to the host system or to a given VServer. 
     260# If $1 is empty, operate on the host system. 
     261# Else, operate on a VServer and return with exit-code: 
     262#   - 2 if $1 is not an existing VServer 
     263#   - 3 if $1 is not a VServer listed in VSNAMES 
     264#   - 4 if $1 is not a running VServer 
     265# Anyway, return with exit-code: 
     266#   - 5 if the GnuPG public key can not be found 
     267context_config() { 
     268    local vsname="$1" 
     269    local res 
     270    debug "-------- Operating on" \ 
     271          "`if [ -z $vsname ]; then echo 'the host system'; else echo VServer $vsname; fi`" 
     272    debug "* context_config" 
     273 
     274    # 
     275    # Variables & VServer 
     276    # 
     277 
     278    if [ -z "$vsname" ]; then 
     279        WATCHED_DIR="$_WATCHED_DIR" 
     280        BACKUP_DIR="$_BACKUP_DIR" 
     281        VSERVER_EXEC_PREFIX="" 
     282        EMAIL_ADDRESS="$_EMAIL_ADDRESS" 
     283    else 
     284        WATCHED_DIR="$VROOTDIR/$vsname/$_WATCHED_DIR" 
     285        BACKUP_DIR="$_BACKUP_DIR/$vsname" 
     286        VSERVER_EXEC_PREFIX="$VSERVER $vsname exec" 
     287        EMAIL_ADDRESS="root@`current_system`" 
     288        # does the current VServer exist ? 
     289        if [ ! -d "$VROOTDIR/$vsname" ]; then 
     290            warning "  VServer $vsname does not exist (error 2)." 
     291            return 2 
     292        fi 
     293        # is the current VServer listed in VSNAMES ? 
     294        local found="no"; 
     295        for i in $VSNAMES; do 
     296            if [ "$vsname" = "$i" ]; then 
     297                found=yes 
     298                break 
     299            fi 
     300        done 
     301        if [ $found = no ]; then 
     302            warning "  VServer $vsname is not listed in VSNAMES (error 3)." 
     303            return 3 
     304        fi 
     305        # is the current VServer running ? 
     306        res="" 
     307        $VSERVERINFO -q "$vsname" RUNNING || res=failed 
     308        if [ "$res" = failed ]; then 
     309            warning "  VServer $vsname is not running (error 4)." 
     310            return 4 
     311        fi 
     312    fi 
     313 
     314    # E-mail encryption 
     315    if [ $ENCRYPT_EMAIL = "yes" ]; then 
     316        gpg --batch --list-public-keys $EMAIL_ADDRESS >/dev/null 2>&1 
     317        res=$? 
     318        if [ $res -ne 0 ]; then 
     319            warning "  GnuPG public key for $EMAIL_ADDRESS not found." 
     320            return 5 
     321        fi 
     322    fi 
     323 
     324    # 
     325    # Files and directories 
     326    # 
     327 
     328    # Check the existence of WATCHED_DIR 
     329    test -d "$WATCHED_DIR" || \ 
     330        fatal "$WATCHED_DIR directory (built from WATCHED_DIR) does not exist." 
     331 
     332    # Initialize WATCHED_PARENT 
     333    WATCHED_PARENT=`dirname $WATCHED_DIR` 
     334    if [ "$WATCHED_PARENT" != '/' ]; then 
     335        WATCHED_PARENT="$WATCHED_PARENT/" 
     336    fi 
     337 
     338    # Check the existence of the resulting BACKUP_DIR, creating it if needed. 
     339    if [ ! -d "$BACKUP_DIR" ]; then 
     340        debug "  Creating $BACKUP_DIR directory for `current_system`." 
     341        if mkdir -p "$BACKUP_DIR"; then 
     342            debug "  Successfully created $BACKUP_DIR directory." 
     343        else 
     344            fatal "  Failed to create $BACKUP_DIR directory." 
     345        fi 
     346    fi 
     347 
     348    # 
     349    # Modules enabling/disabling 
     350    # 
     351 
     352    # DO_CHANGELOGS 
     353    DO_CHANGELOGS="no" 
     354    if [ -n "$_CHANGELOG_DIR" ]; then 
     355        if [ -z "$vsname" ]; then 
     356            CHANGELOG_DIR="$_CHANGELOG_DIR" 
     357        else 
     358            CHANGELOG_DIR="$VROOTDIR/$vsname$_CHANGELOG_DIR" 
     359        fi 
     360        if [ -d "$CHANGELOG_DIR" ]; then 
     361            DO_CHANGELOGS="dir" 
     362        else 
     363            warning "  The directory $CHANGELOG_DIR (built from CHANGELOG_DIR)" \ 
     364                    "  does not exist. Changelogs file monitoring thereferore" \ 
     365                    "  cannot be performed this time for `current_system`." 
     366        fi 
     367    elif [ -n "$CHANGELOG_FILE" ]; then 
     368        if [ -z "$vsname" ]; then 
     369            CHANGELOG_FILE="$_CHANGELOG_FILE" 
     370        else 
     371            CHANGELOG_FILE="$VROOTDIR/$vsname$_CHANGELOG_FILE" 
     372        fi 
     373        if [ -f "$CHANGELOG_FILE" ]; then 
     374            DO_CHANGELOGS="file" 
     375        else 
     376            warning "  The file $CHANGELOG_FILE (built from CHANGELOG_FILE)" 
     377            warning "  does not exist. Changelog file monitoring thereferore" 
     378            warning "  cannot be performed this time for `current_system`." 
     379        fi 
     380    fi 
     381 
     382    # DO_PACKAGES 
     383    DO_PACKAGES="$_DO_PACKAGES" 
     384    if [ "$DO_PACKAGES" = "yes" ]; then 
     385        $VSERVER_EXEC_PREFIX which apt-show-versions > /dev/null 
     386        res=$? 
     387        if [ $res -ne 0 ]; then 
     388            warning "  apt-show-versions not found on `current_system`." 
     389            warning "  Please install it or turn DO_PACKAGES off." 
     390            warning "  DO_PACKAGES therefore cannot be performed this time" 
     391            warning "  for `current_system`." 
     392            DO_PACKAGES=no 
     393        fi 
     394    fi 
     395 
     396    # 
     397    # Final steps to get a coherent initial status 
     398    # 
     399 
     400    # Make sure we've got at least one testing and one stable 
     401    milestone_exists testing-latest || save_state "testing" 
     402    milestone_exists stable-latest || stabilize_state "testing-latest" 
     403} 
    221404 
    222405# Returns 0 if, and only if, specified milestone exists. 
     
    277460# This will save an archive of the watched directory with the given prefix 
    278461save_files() { 
    279     debug "  - save_files $@" 
     462    debug "    - save_files $@" 
    280463    set -o noglob 
    281464    tar jcf "$BACKUP_DIR/$1-$DATE".tar.bz2 \ 
     
    287470# This will save packages list with the given prefix 
    288471save_packages() { 
    289     debug "  - save_packages $@" 
    290     apt-show-versions -i 
    291     apt-show-versions | 
     472    debug "    - save_packages $@" 
     473    $VSERVER_EXEC_PREFIX apt-show-versions -i 
     474    $VSERVER_EXEC_PREFIX apt-show-versions | 
    292475        sort > "$BACKUP_DIR/$1-$DATE".packages 
    293476    ln -sf "$1-$DATE".packages "$BACKUP_DIR/$1"-latest.packages 
     
    296479# This will save Changelogs with the given prefix 
    297480save_changelogs() { 
    298     debug "  - save_changelogs $@" 
     481    debug "    - save_changelogs $@" 
    299482    local changelog domain file 
    300483 
     
    315498# Save whatever reflect the current state with the given prefix 
    316499save_state() { 
    317     debug "save_state $@" 
     500    debug "* save_state $@" 
    318501    save_files "$1" 
    319502    [ $DO_PACKAGES = "no" ] || save_packages "$1" 
     
    323506# Report changes against given version to standard output 
    324507report_changes() { 
    325     debug "report_changes $@"     
     508    debug "* report_changes $@"     
    326509    local tmp tmpdir changelog domain diff tar_diff diff_diff 
    327510    local files old new tmp_packages file 
     
    398581 
    399582        tmp_packages=`mktemp -q` 
    400         apt-show-versions -i 
    401         apt-show-versions | sort > "$tmp_packages" 
    402         if diff -wEbB "$BACKUP_DIR/$1".packages "$tmp_packages"; then 
     583        $VSERVER_EXEC_PREFIX apt-show-versions -i 
     584        $VSERVER_EXEC_PREFIX apt-show-versions | sort > "$tmp_packages" 
     585        if diff -wEbBN "$BACKUP_DIR/$1".packages "$tmp_packages"; then 
    403586            echo "$_NO_DEBIAN_PACKAGES_CHANGE" 
    404587        fi | grep -v '^[0-9-]' >> "$tmp" 
     
    430613# NB: argument validity is supposed to have been already checked. 
    431614stabilize_state() { 
    432     debug "stabilize_state $@" 
     615    debug "* stabilize_state $@" 
    433616    local testing stable file dst 
    434617 
     
    507690### 
    508691 
    509 # make sure we've got at least one testing and one stable 
    510 milestone_exists testing-latest || save_state "testing" 
    511 milestone_exists stable-latest || stabilize_state "testing-latest" 
    512  
    513692case "$CMD" in 
    514693 
    515694    report) 
     695        context_config "$VSNAME" || fatal "Aborting (error $?)." 
    516696        DO_DETAILS="yes" 
    517697        if [ -z "$MILESTONE" ]; then 
     
    526706 
    527707    list) 
     708        context_config "$VSNAME" || fatal "Aborting (error $?)." 
    528709        for file in "$BACKUP_DIR"/*.tar.bz2; do 
    529710            echo `basename ${file%%.tar.bz2}` 
     
    533714    cron) 
    534715        STABLE_TIME_MIN=`expr 24 '*' 60 '*' "$STABLE_TIME"` 
    535  
    536         ### Algorithm 
    537         # 
    538         # if (no change happened for TESTING_TIME) then 
    539         #     if (something has changed since the last testing) then 
    540         #       send a report against last testing 
    541         #       save a new testing state 
    542         #       delete all saved unstable states 
    543         #     elif (no change happened for STABLE_TIME) then 
    544         #       if (something has changed since the last stable) then 
    545         #           save a new stable state and notify EMAIL_ADDRESS 
    546         #           delete all saved testing states older than STABLE_TIME 
    547         #       fi 
    548         #     fi 
    549         # elif (last unstable exists) then 
    550         #     if (something has changed since the last unstable) then 
    551         #         save a new unstable state 
    552         #     fi 
    553         # else 
    554         #     save a new unstable state 
    555         # fi 
    556         if no_change_since "$TESTING_TIME"; then 
    557             debug "no change since TESTING_TIME" 
    558             if changed_from "$BACKUP_DIR"/testing-latest.tar.bz2; then 
    559                 debug "changed from testing-latest" 
    560                 report_changes "testing-latest" | email "testing-$DATE" 
    561                 save_state "testing" 
    562                 debug "removing all saved unstable states." 
    563                 find "$BACKUP_DIR" -name 'unstable-*' -exec rm "{}" \; 
    564             elif no_change_since "$STABLE_TIME_MIN"; then 
    565                 if changed_from "$BACKUP_DIR"/stable-latest.tar.bz2; then 
    566                     save_state "stable" 
    567                     echo "metche saved a new stable state : stable-${DATE}." | 
     716        if [ -n "$VSNAME" ]; then 
     717            display_usage 
     718            fatal "-h option not available for 'metche cron'" 
     719        fi 
     720 
     721        for i in "" $VSNAMES; do 
     722            res=0 
     723            context_config "$i" || res=$? 
     724            if [ $res -ne 0 ]; then 
     725                warning "-------- Ignoring" \ 
     726                        "`if [ -z $i ]; then \ 
     727                              echo 'the host system'; \ 
     728                          else \ 
     729                              echo VServer $i; fi` (error $res)" 
     730                continue 
     731            fi 
     732 
     733            ### Algorithm 
     734            # 
     735            # if (no change happened for TESTING_TIME) then 
     736            #     if (something has changed since the last testing) then 
     737            #       send a report against last testing 
     738            #       save a new testing state 
     739            #       delete all saved unstable states 
     740            #     elif (no change happened for STABLE_TIME) then 
     741            #       if (something has changed since the last stable) then 
     742            #           save a new stable state and notify EMAIL_ADDRESS 
     743            #           delete all saved testing states older than STABLE_TIME 
     744            #       fi 
     745            #     fi 
     746            # elif (last unstable exists) then 
     747            #     if (something has changed since the last unstable) then 
     748            #         save a new unstable state 
     749            #     fi 
     750            # else 
     751            #     save a new unstable state 
     752            # fi 
     753 
     754            debug "* main algorithm" 
     755 
     756            if no_change_since "$TESTING_TIME"; then 
     757                debug "  no change since TESTING_TIME" 
     758                if changed_from "$BACKUP_DIR"/testing-latest.tar.bz2; then 
     759                    debug "  changed from testing-latest" 
     760                    report_changes "testing-latest" | email "testing-$DATE" 
     761                    save_state "testing" 
     762                    debug "  removing all saved unstable states." 
     763                    find "$BACKUP_DIR" -name 'unstable-*' -exec rm "{}" \; 
     764                elif no_change_since "$STABLE_TIME_MIN"; then 
     765                    if changed_from "$BACKUP_DIR"/stable-latest.tar.bz2; then 
     766                        save_state "stable" 
     767                        echo "metche saved a new stable state: stable-${DATE}." | 
    568768                        email "stable-$DATE" 
    569                     debug "removing all saved testing states older " \ 
    570                           "than STABLE_TIME ($STABLE_TIME)." 
    571                     find "$BACKUP_DIR" -name 'testing-*' \ 
    572                                        -ctime +"$STABLE_TIME" -exec rm "{}" \; 
     769                        debug "  removing all saved testing states older" \ 
     770                              "than STABLE_TIME ($STABLE_TIME)." 
     771                        find "$BACKUP_DIR" -name 'testing-*' \ 
     772                            -ctime +"$STABLE_TIME" -exec rm "{}" \; 
     773                    fi 
    573774                fi 
    574             fi 
    575         elif milestone_exists unstable-latest; then 
    576             if changed_from "$BACKUP_DIR"/unstable-latest.tar.bz2; then 
    577                 debug "changed from unstable-latest" 
     775            elif milestone_exists unstable-latest; then 
     776                if changed_from "$BACKUP_DIR"/unstable-latest.tar.bz2; then 
     777                    debug "  changed from unstable-latest" 
     778                    save_state "unstable" 
     779                else 
     780                    debug "  not changed from unstable-latest" 
     781                fi 
     782            else 
    578783                save_state "unstable" 
    579784            fi 
    580         else 
    581             save_state "unstable" 
    582         fi 
     785             
     786        done 
     787         
    583788        ;; 
    584789 
    585790    stabilize) 
     791        context_config "$VSNAME" || fatal "Aborting (error $?)." 
    586792        if [ -z "$MILESTONE" ]; then 
    587793            stabilize_state "testing-latest" 
     
    596802 
    597803    test) 
    598         milestone_version "stable-200507040202" 
    599         milestone_version "testing-latest" 
    600         milestone_version "testing-200507030047" 
    601         milestone_version "testing-200507030047qsfd" 
    602         milestone_date "stable-200507040202" 
    603         milestone_date "testing-latest" 
    604         milestone_date "testing-200507030047" 
    605         milestone_date "testing-200507030047qsfd" 
    606         (is_latest testing-latest && echo oui) || echo non 
    607         (is_latest testing-200507031821 && echo oui) || echo non 
    608         (is_latest stable-200507031831 && echo oui) || echo non 
    609         (is_latest stable-200507040202 && echo oui) || echo non  
     804        for i in "" $VSNAMES; do 
     805            res=0 
     806            context_config "$i" || res=$? 
     807            if [ $res -ne 0 ]; then 
     808                warning "-------- Ignoring" \ 
     809                        "`if [ -z $i ]; then \ 
     810                              echo 'the host system'; \ 
     811                          else \ 
     812                              echo VServer $i; fi` (error $res)" 
     813                continue 
     814            fi 
     815            milestone_version "stable-200507040202" 
     816            milestone_version "testing-latest" 
     817            milestone_date "testing-latest" 
     818            #report_changes "testing-latest" | email "testing-$DATE" 
     819        done 
    610820        ;; 
    611821 
  • debian/branches/upstream/current/metche.8

    r115 r181  
    1 .\"Generated by db2man.xsl. Don't modify this, modify the source. 
    2 .de Sh \" Subsection 
    3 .br 
    4 .if t .Sp 
    5 .ne 5 
    6 .PP 
    7 \fB\\$1\fR 
    8 .PP 
    9 .. 
    10 .de Sp \" Vertical space (when we can't use .PP) 
    11 .if t .sp .5v 
    12 .if n .sp 
    13 .. 
    14 .de Ip \" List item 
    15 .br 
    16 .ie \\n(.$>=3 .ne \\$3 
    17 .el .ne 3 
    18 .IP "\\$1" \\$2 
    19 .. 
    20 .TH "METCHE" 8 "" "" "" 
    21 .SH NAME 
     1.\"     Title: metche 
     2.\"    Author:  
     3.\" Generator: DocBook XSL Stylesheets v1.70.1 <http://docbook.sf.net/> 
     4.\"      Date: 09/16/2006 
     5.\"    Manual:  
     6.\"    Source:  
     7.\" 
     8.TH "METCHE" "8" "09/16/2006" "" "" 
     9.\" disable hyphenation 
     10.nh 
     11.\" disable justification (adjust text to left margin only) 
     12.ad l 
     13.SH "NAME" 
    2214metche \- reducing root bus factor 
    2315.SH "SYNOPSIS" 
    24 .ad l 
    25 .hy 0 
    2616.HP 7 
    27 \fBmetche\fR {\fBcron\fR | \fBreport\ [{\fBstable\fR\ |\ \fBtesting\fR\ |\ \fBunstable\fR}\-\fIYYYYMMDDHHMM\fR]\fR | \fBlist\fR | \fBstabilize\ [testing\-\fIYYYYMMDDHHMM\fR]\fR} 
    28 .ad 
    29 .hy 
    30  
     17\fBmetche\fR [\-h\ \fIvserver\fR] {[report\ [\ {[stable]\ |\ [testing]\ |\ [unstable]}\-\fIYYYYMMDDHHMM\fR\ ]] | [list] | [stabilize\ [testing\-\fIYYYYMMDDHHMM\fR]]} 
    3118.SH "DESCRIPTION" 
    32  
    3319.PP 
    34 metche is a tool meant to facilitate collective sysadmin by monitoring changes in the system configuration\&. 
    35  
     20metche is a tool meant to ease collective system administration by monitoring changes in the system configuration. 
    3621.PP 
    37 metche basic usage is to monitor changes in a directory, usually \fI/etc\fR ; optionally, metche can also monitor: 
    38  
    39 .TP 3 
     22metche basic usage is to monitor changes in a directory, usually 
     23\fI/etc\fR 
     24; optionally, metche can also monitor: 
     25.TP 3n 
    4026\(bu 
    4127one or more user maintained changelog files, 
    42 .TP 
     28.TP 3n 
    4329\(bu 
    44 the state of Debian packages and versions\&
    45 .LP 
    46  
     30the state of Debian packages and versions
     31.sp 
     32.RE 
    4733.PP 
    48 metche should be installed with a cronjob that regularly runs to automatically save the system state as needed\&. These states are saved in a way similar to the Debian development model: 
    49  
    50 .TP 3 
     34metche should be installed with a cronjob that regularly runs to automatically save the system state as needed. These states are saved in a way similar to the Debian development model: 
     35.TP 3n 
    5136\(bu 
    52 \fIunstable\fR states are saved as soon as a change is detected\&. They are kept until a new \fItesting\fR state appears\&. 
    53 .TP 
     37\fIunstable\fR 
     38states are saved as soon as a change is detected. They are kept until a new 
     39\fItesting\fR 
     40state appears. 
     41.TP 3n 
    5442\(bu 
    55 \fItesting\fR states is created from the last \fIunstable\fR state that has not been changed after a short amount of time (by default, one hour)\&. Old \fIunstable\fR states are deleted afterwards\&. 
    56 .TP 
     43\fItesting\fR 
     44states is created from the last 
     45\fIunstable\fR 
     46state that has not been changed after a short amount of time (by default, one hour). Old 
     47\fIunstable\fR 
     48states are deleted afterwards. 
     49.TP 3n 
    5750\(bu 
    58 \fIstable\fR states are created from the last \fItesting\fR state, either manually, or after a long amount of time (by default, 3 days)\&. Old \fItesting\fR states are deleted afterwards\&. 
    59 .LP 
    60  
     51\fIstable\fR 
     52states are created from the last 
     53\fItesting\fR 
     54state, either manually, or after a long amount of time (by default, 3 days). Old 
     55\fItesting\fR 
     56states are deleted afterwards. 
     57.sp 
     58.RE 
    6159.PP 
    62 When a new \fItesting\fR state is saved, an email is sent to a configurable address, giving an overwiew of the differences with the previous \fItesting\fR\&. A notification is also sent when a new \fIstable\fR state is saved\&. 
    63  
     60When a new 
     61\fItesting\fR 
     62state is saved, an email is sent to a configurable address, giving an overwiew of the differences with the previous 
     63\fItesting\fR. A notification is also sent when a new 
     64\fIstable\fR 
     65state is saved. 
    6466.PP 
    65 metche's configuration is read from \fI/etc/metche\&.conf\fR\&. Various settings like changelog monitoring or time between system state switches are described there\&. 
    66  
     67metche's configuration is read from 
     68\fI/etc/metche.conf\fR. Various settings like changelog monitoring or time between system state switches are described there. 
    6769.SH "OPTIONS" 
    68  
     70.PP 
     71If 
     72\fB\-h\fR 
     73\fIVSERVER\fR 
     74is specified, the VServer 
     75\fIVSERVER\fR 
     76is operated on instead of the host system. This, along with the 
     77\fBVSNAMES\fR 
     78option, allows to monitor several VServers running on the system. 
    6979.PP 
    7080One of the following commands must be specified on the command line: 
    71  
    72 .TP 
     81.TP 3n 
    7382\fBreport\fR 
    74 When run with the \fBreport\fR command, metche displays a report against the specified saved state, or if unspecified, against the latest testing state\&. This is useful when you have broken your system and want to know which changes have been made since a given, known working, system state\&. 
    75  
    76 .TP 
     83When run with the 
     84\fBreport\fR 
     85command, metche displays a report against the specified saved state, or if unspecified, against the latest testing state. This is useful when you have broken your system and want to know which changes have been made since a given, known working, system state. 
     86.TP 3n 
    7787\fBlist\fR 
    78 When run with the \fBlist\fR command, metche displays a list of all the saved states\&. 
    79  
    80 .TP 
     88When run with the 
     89\fBlist\fR 
     90command, metche displays a list of all the saved states. 
     91.TP 3n 
    8192\fBstabilize\fR 
    82 When run with the \fBstabilize\fR command, metche turns a "testing state" into a "stable state"\&. By default, it will use the last "testing state", but this can be overriden by giving a specific state as argument\&. 
    83  
    84 .TP 
     93When run with the 
     94\fBstabilize\fR 
     95command, metche turns a "testing state" into a "stable state". By default, it will use the last "testing state", but this can be overriden by giving a specific state as argument. 
     96.TP 3n 
    8597\fBcron\fR 
    86 This command should not be called manually, but used from a cronjob\&. When called, it can perform various operations like: saving "unstable", "testing" or "stable" states as needed and sending reports and notification if configured to do so\&. 
    87  
     98This command should not be called manually, but used from a cronjob. When called, it can perform various operations like: saving "unstable", "testing" or "stable" states as needed and sending reports and notification if configured to do so. This command does not support the 
     99\fB\-h\fR 
     100option. 
    88101.SH "FILES" 
    89  
    90102.PP 
    91 \fI/etc/metche\&.conf\fR contains metche configuration\&. 
    92  
     103\fI/etc/metche.conf\fR 
     104contains metche configuration. 
    93105.PP 
    94 When configured to monitor one changelog, \fI\fBCHANGELOG_FILE\fR\fR (default \fI/root/Changelog\fR)\&. 
    95  
     106When configured to monitor one changelog, 
     107\fBCHANGELOG_FILE\fR 
     108(default: 
     109\fI/root/Changelog\fR). 
    96110.PP 
    97 When configured to monitor multiple changelogs, \fI\fBCHANGELOG_DIR\fR/*/Changelog\fR (default : \fI/root/changelogs\fR)\&. 
    98  
     111When configured to monitor multiple changelogs, 
     112\fICHANGELOG_DIR/*/Changelog\fR 
     113(default: 
     114\fI/root/changelogs\fR). 
    99115.PP 
    100 System states are saved in \fI\fBBACKUP_DIR\fR\fR (default \fI/var/lib/metche)\fR\&. 
    101  
     116System states are saved in 
     117\fBBACKUP_DIR\fR 
     118(default: 
     119\fI/var/lib/metche)\fR. 
    102120.SH "SECURITY" 
    103  
    104121.PP 
    105 metche is able to use GnuPG to encrypt the email it sends, but does not by default; just enable the \fBENCRYPT_EMAIL\fR configuration option, and make sure \fBEMAIL_ADDRESS\fR' public key is in root's keyring, trusted enough to be used blindly by metche\&. 
    106  
     122metche is able to use GnuPG to encrypt the email it sends, but does not by default; just enable the 
     123\fBENCRYPT_EMAIL\fR 
     124configuration option, and make sure 
     125\fBEMAIL_ADDRESS\fR' public key is in root's keyring, trusted enough to be used blindly by metche. 
    107126.PP