Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: da9fce707c
Fetching contributors…

Cannot retrieve contributors at this time

executable file 127 lines (118 sloc) 3.253 kB
#!/bin/sh
set -e
cd /etc
# settings
APT="apt-get --assume-yes"
ACCOUNT=jcdubacq
HOSTINSTALL=fiona
ACCOUNTHOME=$(getent passwd $ACCOUNT|cut -f6 -d:)
INSTALL=${ACCOUNTHOME}/INSTALL
printf '[user]\n\tname = Jean-Christophe Dubacq (as root)\n\temail = jean-christophe.dubacq@ens-lyon.org\n' > /root/.gitconfig
if [ -f $INSTALL/modified ]; then
REVERT=1
rm -f $INSTALL/modified
else
REVERT=0
touch $INSTALL/modified
fi
export ACCOUNT ACCOUNTHOME INSTALL REVERT HOSTINSTALL APT
# run
chapter() {
bold=$(tput smso)
offbold=$(tput rmso)
if [ "$REVERT" = 1 ]; then
echo "${bold}[Revert $@]${offbold}"
else
echo "${bold}[$@]${offbold}"
fi
}
runit() {
BASEDIR=$1
TOPDIR="$INSTALL/lib/$BASEDIR"
if [ -f "$TOPDIR"/README ]; then COMMENT=$(cat "$TOPDIR"/README); else COMMENT="Adding modification $1"; fi
chapter "$1: $COMMENT"
find $TOPDIR -print | while read i; do
ii="${i#$TOPDIR/}"
if [ "${ii#_}" != "$ii" ]; then
j="/root/${ii#_}"
else
j="/etc/${ii}"
fi
jj=$(dirname "$ii")
POSTRUN=0
POSTREVERT=0
case "$ii" in
VERSION|README)
true
;;
POSTRUN)
if [ "$REVERT" = 0 ]; then FILE="$j"; export FILE; POSTRUN=1; fi
;;
POSTREVERT)
if [ "$REVERT" = 1 ]; then FILE="$j"; export FILE; POSTREVERT=1; fi
;;
*.debconf)
if [ "$REVERT" = 0 ]; then debconf-set-selections < "$i"; fi
;;
*.patch)
if [ "$REVERT" = 1 ]; then OPTION=-R;else OPTION=-N;fi
patch -p1 "$OPTION" < $i
;;
*)
if [ "$REVERT" = 1 ]; then
echo "Removing $j"
rm "$j"
rmdir --ignore-fail-on-non-empty "$jj"
else
echo "Copying $i to $j"
mkdir -p "$jj"
cp "$i" "$j"
fi
;;
esac
done
if [ "$POSTRUN" = 1 ]; then
sh "${TOPDIR}/POSTRUN"
fi
if [ "$POSTREVERT" = 1 ]; then
sh "${TOPDIR}/POSTREVERT"
fi
shift
etckeeper commit "$COMMENT"||true
}
# doing
if [ "$REVERT" = 0 ]; then
chapter "Checking basic packages"
${APT} install debconf-utils
${APT} install autossh
${APT} install gnome
${APT} install texlive-full
${APT} install vim
${APT} --purge remove nano
chapter "Initializing /etc monitoring"
${APT} install etckeeper
rm -rf /etc/.git
etckeeper init
etckeeper commit "Initial commit"
runit record-manual
runit network
runit repository-dubacq
runit repository-sidexp
runit superusers
runit fix-groups
runit postfix
fi
if [ "$REVERT" = 1 ]; then
runit network
runit superusers
runit fix-groups
runit postfix
runit repository-dubacq
runit repository-sidexp
runit record-manual
chapter "Destroying /etc monitoring"
git checkout $(git log |grep commit|tail -n 1|cut -f2 -d' ')
git status
echo rm -rf /etc/.git
echo rm -rf /root/.gitconfig
fi
Jump to Line
Something went wrong with that request. Please try again.