#!/bin/bash set -e # shortcut to query condors configuration without interpreting its # macros ccv() { condor_config_val -dump |grep "^${1}\s=" | sed -e "s/^${1}\s=\s//" } . /usr/share/debconf/confmodule db_version 2.0 db_capb backup db_settitle condor/title # if we have a working condor config query it to charge debconf # hmmm '&> /dev/null' would ruin the logic ... strange if condor_config_val -config 1> /dev/null 2> /dev/null; then if [ "$(ccv CONDOR_DEVELOPERS)" = "NONE" ]; then db_set condor/phonehome false else db_set condor/phonehome true fi if [ "$(ccv START)" = "TRUE" ]; then db_set condor/startpolicy true else db_set condor/startpolicy false fi db_set condor/reservedmemory "$(ccv RESERVED_MEMORY)" db_set condor/admin "$(ccv CONDOR_ADMIN)" db_set condor/filesystemdomain "$(ccv FILESYSTEM_DOMAIN)" db_set condor/uiddomain "$(ccv UID_DOMAIN)" db_set condor/centralmanager "$(ccv CONDOR_HOST)" db_set condor/allowwrite "$(ccv ALLOW_WRITE)" # figure out roles condor_daemons=$(ccv DAEMON_LIST) [[ "$condor_daemons" =~ "COLLECTOR" ]] \ && condor_roles+="${condor_roles:+, }COLLECTOR:NEGOTIATOR" [[ "$condor_daemons" =~ "SCHEDD" ]] \ && condor_roles+="${condor_roles:+, }SCHEDD" [[ "$condor_daemons" =~ "STARTD" ]] \ && condor_roles+="${condor_roles:+, }STARTD" db_set condor/daemons "$condor_roles" fi # initial check whether our service is wanted # stop here if not db_input high condor/wantdebconf || true db_go # need to run once to get db_get to work db_get condor/wantdebconf if [ "$RET" = "false" ]; then exit 0 fi # This implements a simple state machine so the back button can be handled. # taken from debconf demo example MAX_STATE=6 STATE=1 while [ "$STATE" != 0 -a "$STATE" != "$MAX_STATE" ]; do case $STATE in 1) db_input high condor/personal || true ;; 2) db_beginblock db_input low condor/startpolicy || true db_input low condor/reservedmemory || true db_input low condor/admin || true db_input low condor/phonehome || true db_endblock ;; 3) db_get condor/personal if [ "$RET" = "true" ]; then # for the initial configuration of a personal condor, we want # all jobs to start right away, regardless of machine activity # (but only force this setting if the user never had the chance # to indicate something else) db_fget condor/startpolicy seen if [ "$RET" = "false" ]; then db_set condor/startpolicy true fi # skip over all other questions STATE=$MAX_STATE continue fi db_input high condor/daemons || true ;; 4) db_beginblock db_input high condor/filesystemdomain || true db_input high condor/uiddomain || true db_input high condor/centralmanager || true db_endblock ;; 5) db_input critical condor/allowwrite || true ;; esac if db_go; then STATE=$(($STATE + 1)) else STATE=$(($STATE - 1)) fi done db_stop