#!/bin/bash echo "checking for user autoadmin and his nightly autocommit" if ! id autoadmin &>/dev/null ; then useradd autoadmin fi echo "checking for /home/autoadmin" [ -d /home/autoadmin ] || mkdir /home/autoadmin chown autoadmin /home/autoadmin echo "checking for group wheel" grep '^wheel:' /etc/group &>/dev/null || groupadd wheel echo "checking for group membership: autoadmin in wheel" groups autoadmin|grep -w wheel &>/dev/null || gpasswd -a autoadmin wheel echo "checking for /sysrepo" [ -d /sysrepo ] || mkdir /sysrepo echo "checking for svn repository in /sysrepo" if ! [ -d /sysrepo/db ] ; then svnadmin create --fs-type fsfs /sysrepo chgrp -R wheel /sysrepo chmod -R g+w /sysrepo fi echo checking for initialisation of vadm su - autoadmin -c "vadm init file:///sysrepo/$HOSTNAME" # if su does not work for debian but sudo does: #if [ ! -d /home/autoadmin/.vadm/$HOSTNAME ] ; then #rm -rf /home/autoadmin/.vadm #if [ -e /etc/gentoo-release ] ; then #su - autoadmin -c "vadm init file:///sysrepo/$HOSTNAME" #elif [ -e /etc/debian_version ] ; then #sudo -u autoadmin vadm init file:///sysrepo/$HOSTNAME #else #echo "WARNING: could not determin distribution" #su - autoadmin -c "vadm init file:///sysrepo/$HOSTNAME" #fi #fi echo checking cronjob if crontab -u autoadmin -l 2>/dev/null |grep autocommit >/dev/null ; then echo -n #do nothing else echo '59 23 * * * /usr/bin/vadm ci -m "autocommit `date \"+\%Y.\%m.\%d \%H:\%M:\%S\"`" / >/dev/null' |crontab -u autoadmin - fi echo checking post-commit mails if [ -e /sysrepo/hooks/post-commit ] ; then if ! grep -E '^/admin/bin/svn-mailer.py.*mailer.conf' /sysrepo/hooks/post-commit &>/dev/null ; then cp /sysrepo/hooks/post-commit /sysrepo/hooks/post-commit.bac echo overwriting /sysrepo/hooks/post-commit, backup is in /sysrepo/hooks/post-commit.bac cp post-commit /sysrepo/hooks/ fi else echo installing /sysrepo/hooks/post-commit cp post-commit /sysrepo/hooks/ fi if [ -e /sysrepo/hooks/mailer.conf ] ; then WRONG_LINES=`grep -E '^[^#].*_subject_prefix' /sysrepo/hooks/mailer.conf |grep -v $HOSTNAME|wc -l` if [ ! "$WRONG_LINES" = "0" ] ; then cp /sysrepo/hooks/mailer.conf /sysrepo/hooks/mailer.conf.bac echo overwriting /sysrepo/hooks/mailer.conf, backup is in /sysrepo/hooks/mailer.conf.bac cat mailer.conf |sed 's/HOSTNAME/'$HOSTNAME'/' > /sysrepo/hooks/mailer.conf fi else echo installing /sysrepo/hooks/mailer.conf cat mailer.conf |sed 's/HOSTNAME/'$HOSTNAME'/' > /sysrepo/hooks/mailer.conf fi echo trying to add all possible files into vadm su - autoadmin -c "vadm add --fromfile /admin/package/cell_layout/vadm-list" su - autoadmin -c "vadm ci -m \"comitting state\" /"