#!/bin/sh set -e # Copyright 2009-2018 Holger Levsen (holger@layer-acht.org) # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see # # update piuparts slave setup from git (eg. used on piu-slave-*.debian.org) # if [ "`id -n -u`" != "piupartss" ] ; then echo please run this script as piupartss user exit 1 fi PIUPARTS_PREFIX=/srv/piuparts.debian.org PIUPARTS_HTDOCS=$PIUPARTS_PREFIX/htdocs PIUPARTS_TMPDIR=$PIUPARTS_PREFIX/tmp # # create $PIUPARTS_PREFIX # if [ ! -d $PIUPARTS_PREFIX ] ; then sudo mkdir -p $PIUPARTS_PREFIX sudo chown piupartss:piuparts $PIUPARTS_PREFIX sudo chmod 0775 $PIUPARTS_PREFIX fi # # update source # if [ ! -d $PIUPARTS_PREFIX/src ] ; then mkdir -p $PIUPARTS_PREFIX/src chmod 0755 $PIUPARTS_PREFIX/src cd $PIUPARTS_PREFIX/src git clone https://salsa.debian.org/debian/piuparts.git cd piuparts git checkout develop fi cd $PIUPARTS_PREFIX/src/piuparts pwd # git checkout branch if $1 is given if [ ! -z "$1" ] ; then git checkout $1 fi # git fetch+pull if $2 is given if [ ! -z "$2" ] ; then git fetch $2 git pull $2 $1 fi # # install everything from GIT into PIUPARTS_PREFIX # make clean make prefix=$PIUPARTS_PREFIX \ build-slave build-doc make prefix=$PIUPARTS_PREFIX \ docdir=$PIUPARTS_HTDOCS/doc \ htdocsdir=$PIUPARTS_HTDOCS \ install-slave install-doc install-conf-4-running-from-git make clean # # update $PIUPARTS_PREFIX # cd $PIUPARTS_PREFIX pwd mkdir -p slave slave/basetgz # to support multiple hosts with this setup cd etc/piuparts HOSTNAME=$(hostname) for f in piuparts.conf do ln -sf $f.$HOSTNAME $f done # # create working dir # if [ ! -d $PIUPARTS_TMPDIR ] ; then if ! [ -L $PIUPARTS_TMPDIR ] && [ -d /srv/piuparts-workspace ] ; then ln -sf /srv/piuparts-workspace $PIUPARTS_TMPDIR fi fi if [ ! -d $PIUPARTS_TMPDIR ] && [ ! -L $PIUPARTS_TMPDIR ] ; then echo "$PIUPARTS_TMPDIR is neither a directory nor link, please fix." exit 1 fi # tell DSA not to back it up touch $PIUPARTS_TMPDIR/.nobackup # # update slave home # cd pwd ln -sf $PIUPARTS_PREFIX/share/piuparts/slave bin crontab $PIUPARTS_PREFIX/etc/piuparts/crontab-slave echo "Update finished."