etckeeper and friends

by dupuy
0 deployments · 0 still active · last rev. 3 years ago

Most common utilities. It's a party.

[adapted from SS4506 - this one has UDF example removed and maybe typo fixed]

## NOTES ##

1. First run:

system_start_etc_dir_versioning (pick a vcs, probably git)

2. After every major change, run:

system_record_etc_dir_changes describe in bare infinitive verb tense, <50 chars.

## API ##

system_start_etc_dir_versioning baazar | darcs | git | mercurial (subversion not supported by etckeeper)

system_record_etc_dir_changes describe what was changed

system_install pkg1 pkg2 ...
system_install_build
system_install_vcs baazar | darcs | git | mercurial | subversion
system_install_baazar
system_install_darcs
system_install_git
system_install_mercurial
system_install_subversion


Do not mix with SS124. It would be bad.

Compatible with: No distros currently supported
						#!/bin/bash
#
# Install better common utilities
#
# Copyright (c) 2012 Barry Allard <barry.allard@gmail.com>
#
# Also available at: https://gist.github.com/3452111

# UDF template for including in other scripts



DEFAULT_SYSTEM_UTILITIES="

    apt-file
    bsd-mailx
    bwm-ng
    curl
    htop
    iotop
    iozone3
    iperf
    python-software-properties
    strace
    sysstat
    tmux
    tofrodos
    wget
    zsh

"

SYSTEM_UTILITIES="${SYSTEM_UTILITIES:-$DEFAULT_SYSTEM_UTILITIES}"

function system_install {
    DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends $@
}

function system_install_utils {
    system_install ${SYSTEM_UTILITIES}

    echo $SYSTEM_UTILITIES | grep -qs sysstat && \
      echo 'sysstat sysstat/enable boolean true' | debconf-set-selections
}

function system_install_build {
    system_install build-essential bison flex
}

function system_install_subversion {
    system_install subversion
}

function system_install_git {
    system_install git-core
}

function system_install_mercurial {
    system_install mercurial
}

function system_install_bazaar {
    system_install bzr
}

function system_install_darcs {
    system_install darcs
}

function system_install_subversion {
    system_install subversion
}

function system_install_vcs {
    local vcs="${1}"

    case "$vcs" in
         darcs) system_install_darcs     ;;
    baazar|bzr) system_install_bazaar    ;;
  mercurial|hg) system_install_mercurial ;;
           git) system_install_git       ;;
subversion|svn) system_install_subversion
    esac
}

function system_start_etc_dir_versioning {
    local vcs="${1:-git}"

    system_install_vcs $vcs
    system_install etckeeper
    sed -i "s/^VCS=.*/VCS=$vcs/" /etc/etckeeper/etckeeper.conf
    etckeeper init
}

# call this after major changes
function system_record_etc_dir_changes {
    # make a change in /etc/ in case apt run has committed everything already
    (TZ=UTC date +%Y-%m-%dT%H:%M:%SZ; echo "$@") >> /etc/etckeeper/etckeeper.log
    etckeeper commit "$@"
}