#!/bin/sh set -e # Copyright 2009-2013 Holger Levsen (holger@layer-acht.org) # Copyright © 2013 Andreas Beckmann (anbe@debian.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 # # Run (several) piuparts-slave instance(s) in screen to allow interactive # control later on. # . @sharedir@/piuparts/lib/read_config.sh get_config_value PYTHONPATH global PYTHONPATH '' get_config_value SLAVEROOT global slave-directory get_config_value PIUPARTS_TMPDIR global tmpdir get_config_value SLAVECOUNT global slave-count 1 export PYTHONPATH SESSIONNAME=piuparts_slave_screen SCREENLOG=$SLAVEROOT/screenlog if ! screen -ls $SESSIONNAME | grep -q "No Sockets found" ; then echo "piuparts-slave is already running!" echo screen -ls exit 1 fi # cleanup cruft from previous runs @sharedir@/piuparts/slave/slave_cleanup rm -f $SCREENLOG.* # ensure the temporary directory exists mkdir -p $PIUPARTS_TMPDIR mkdir -p $SLAVEROOT cd $SLAVEROOT # Ensure the screen session exists, run normal shell in screen 0 SHELL=/bin/bash screen -S $SESSIONNAME -d -m echo "Started screen session '$SESSIONNAME'." # run this on a single slave or a sequence of slaves # (use value given, if given and an integer and <= $SLAVECOUNT) if [ "$1" != "" ] && [ "$1" -eq "$1" ] && [ "$1" -le "$SLAVECOUNT" ] ; then SLAVES="$(seq $1)" else SLAVES="$(seq $SLAVECOUNT)" fi for SLAVENUM in $SLAVES do mkdir -p $SLAVENUM SLAVEDIR=$(readlink -f $SLAVENUM) # Ensure there is a window for this slave. screen -S $SESSIONNAME -X screen -t slave$SLAVENUM -L $SLAVENUM # Launch the slave. screen -S $SESSIONNAME -p $SLAVENUM -X stuff " cd $SLAVEDIR && @sharedir@/piuparts/piuparts-slave " echo "piuparts-slave $SLAVENUM has been started." done