From 1fc2cbb24c93d822216ee8aef94af51104dad1f5 Mon Sep 17 00:00:00 2001 From: Trevor Batley Date: Sun, 19 Nov 2023 12:21:54 +1100 Subject: [PATCH] allow web-deploy without parameters (uses hub) --- koji-setup/koji-add-builder.sh | 27 +++++++++++---------------- koji-setup/koji-deploy-web.sh | 11 +++++++++-- koji.yaml | 2 +- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/koji-setup/koji-add-builder.sh b/koji-setup/koji-add-builder.sh index 31d9e9b..12a7bf9 100644 --- a/koji-setup/koji-add-builder.sh +++ b/koji-setup/koji-add-builder.sh @@ -30,26 +30,13 @@ if [ ! -f "$SCRIPT_DIR"/koji-parameters.sh ] ; then exit 1 fi source "$SCRIPT_DIR"/koji-parameters.sh -KOJI_HUB_FQDN="$(hostname -f)" - -# pull down any required scripts -curl $SILENT $SCRIPT_GIT/koji-deploy-hub.sh > $SCRIPT_DIR/koji-deploy-hub.sh - -if [ ! -d $SCRIPT_DIR ] ; then mkdir -p $SCRIPT_DIR ; fi - -# install any required packages -if [[ -z $(dnf list installed | grep epel-release) ]] ; then - dnf install -y epel-release $QUIET -fi -if [[ -z $(dnf list installed | grep netcat) ]] ; then - dnf install -y netcat $QUIET -fi # if no build server given, deploy locally if [ -z $KOJI_BUILD_FQDN ] ; then KOJI_BUILD_FQDN=$KOJI_HUB_FQDN fi +# check that the target exists RESP=$(nc -z $KOJI_BUILD_FQDN 22 2>&1 | grep succeeded) if [[ -z $RESP ]] ; then echo "I cannot connect to $KOJI_BUILD_FQDN! Is it online? " @@ -59,6 +46,14 @@ if [[ -z $RESP ]] ; then exit 1 fi +# install any required packages +if [[ -z $(dnf list installed | grep epel-release) ]] ; then + dnf install -y epel-release $QUIET +fi +if [[ -z $(dnf list installed | grep netcat) ]] ; then + dnf install -y netcat $QUIET +fi + ## On the HUB # Add the host entry for the koji builder to the database sudo -u kojiadmin koji add-host "$KOJI_BUILD_FQDN" "$RPM_ARCH" @@ -69,10 +64,10 @@ sudo -u kojiadmin koji edit-host --capacity="$KOJID_CAPACITY" "$KOJI_BUILD_FQDN" # Generate a certificate for the builder if [ ! -f $SCRIPT_DIR/koji-gencert.sh ] ; then curl $SILENT $SCRIPT_GIT/koji-gencert.sh > $SCRIPT_DIR/koji-gencert.sh + chmod a+x $SCRIPT_DIR/koji-gencert.sh fi -cp $SCRIPT_DIR/koji-gencert.sh $KOJI_PKI_DIR/. pushd "$KOJI_PKI_DIR" -./koji-gencert.sh "$KOJI_BUILD_FQDN" "/C=$COUNTRY_CODE/ST=$STATE/L=$LOCATION/O=$ORGANIZATION/CN=$KOJI_BUILD_FQDN" +$SCRIPT_DIR/koji-gencert.sh "$KOJI_BUILD_FQDN" "/C=$COUNTRY_CODE/ST=$STATE/L=$LOCATION/O=$ORGANIZATION/CN=$KOJI_BUILD_FQDN" popd # check if local install or remote if [[ $KOJI_BUILD_FQDN = $KOJI_HUB_FQDN ]] ; then diff --git a/koji-setup/koji-deploy-web.sh b/koji-setup/koji-deploy-web.sh index 5292a9e..62abbc9 100644 --- a/koji-setup/koji-deploy-web.sh +++ b/koji-setup/koji-deploy-web.sh @@ -2,15 +2,17 @@ # SPDX-License-Identifier: Apache-2.0 set -e -KOJI_WEB_FQDN=$1 +KOJI_WEB_FQDN= DEBUG= SILENT="-s" QUIET="-q" -for param in $2 ; do +for param in $1 $2 ; do if [ $param ] ; then case $param in debug ) DEBUG="debug" ;; + * ) + KOJI_WEB_FQDN=$param ;; esac else break @@ -31,6 +33,10 @@ if [ ! -f "$SCRIPT_DIR"/koji-parameters.sh ] ; then fi source "$SCRIPT_DIR"/koji-parameters.sh +# if no build server given, deploy locally +if [[ -z $KOJI_WEB_FQDN ]] ; then KOJI_WEB_FQDN=$KOJI_HUB_FQDN ; fi + +# check if local or remote deploy if [[ "$KOJI_WEB_FQDN" != "$(hostname -f)" ]] ; then if [[ $DEBUG ]] ; then echo "Deploying remotely to $KOJI_WEB_FQDN" ; fi # deploy remotely to $KOJI_WEB_FQDN @@ -106,6 +112,7 @@ dnf install -y mod_ssl koji-web $QUIET # install locally # create secret SECRET="$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | head -c 32)" +# create config files mkdir -p /etc/kojiweb cat > /etc/kojiweb/web.conf <<- EOF [web] diff --git a/koji.yaml b/koji.yaml index a6113bd..b76f1ec 100644 --- a/koji.yaml +++ b/koji.yaml @@ -3,7 +3,7 @@ tasks: - name: Add required bundles for koji swupd: - name: koji postgresql web-server-basic + name: koji koji-hub koji-utils koji-web mod-ssl policycoreutils-python-utils postgresql web-server-basic state: present become: true - name: copy koji-setup scripts