2023-09-01 00:53:11 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-09-04 02:51:05 +02:00
|
|
|
set -e
|
2023-09-01 08:59:55 +02:00
|
|
|
DEBUG=
|
|
|
|
for param in $1 $2 $3 ; do
|
2023-09-01 06:07:07 +02:00
|
|
|
if [ $param ] ; then
|
|
|
|
case $param in
|
|
|
|
debug )
|
2023-09-04 02:51:05 +02:00
|
|
|
DEBUG="debug" ;;
|
2023-09-01 06:07:07 +02:00
|
|
|
esac
|
|
|
|
else
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
2023-09-01 00:53:11 +02:00
|
|
|
|
2023-09-01 08:59:55 +02:00
|
|
|
SILENT="-s"
|
|
|
|
QUIET="-q"
|
2023-09-01 06:07:07 +02:00
|
|
|
if [ $DEBUG ] ; then
|
|
|
|
set -xe
|
2023-09-01 08:59:55 +02:00
|
|
|
SILENT=
|
|
|
|
QUIET="-v"
|
2023-09-01 06:07:07 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# pull down the deploy scripts
|
|
|
|
SCRIPT_GIT="https://src.koozali.org/smedev/smeserver-koji/raw/branch/master/koji-setup"
|
|
|
|
SCRIPT_DIR="$(echo ~)/bin"
|
2023-09-02 06:37:19 +02:00
|
|
|
|
2023-09-01 06:07:07 +02:00
|
|
|
mkdir -p $SCRIPT_DIR
|
2023-09-04 02:51:05 +02:00
|
|
|
curl $SILENT $SCRIPT_GIT/koji-deploy-hub.sh > $SCRIPT_DIR/koji-deploy-hub.sh
|
2023-09-04 09:56:38 +02:00
|
|
|
curl $SILENT $SCRIPT_GIT/koji-add-builder.sh > $SCRIPT_DIR/koji-add-builder.sh
|
2023-09-04 02:51:05 +02:00
|
|
|
curl $SILENT $SCRIPT_GIT/koji-bootstrap-build.sh > $SCRIPT_DIR/koji-bootstrap-build.sh
|
2023-09-01 06:26:34 +02:00
|
|
|
chmod o+x $SCRIPT_DIR/*.sh
|
2023-09-01 06:07:07 +02:00
|
|
|
|
2023-09-02 07:39:30 +02:00
|
|
|
# install any required packages
|
2023-09-04 12:53:48 +02:00
|
|
|
if [[ -z $(dnf list installed | grep epel-release) ]] ; then
|
2023-09-04 02:51:05 +02:00
|
|
|
dnf install -y epel-release $QUIET
|
|
|
|
fi
|
2023-09-04 12:53:48 +02:00
|
|
|
if [[ -z $(dnf list installed | grep netcat) ]] ; then
|
2023-09-04 02:51:05 +02:00
|
|
|
dnf install -y netcat $QUIET
|
|
|
|
fi
|
2023-09-02 07:39:30 +02:00
|
|
|
|
2023-09-01 06:07:07 +02:00
|
|
|
# ask for required parameters (ssh settings and build server FQDN)
|
2023-09-04 13:50:21 +02:00
|
|
|
echo "Please enter the following details for generating your SSL keys"
|
2023-09-01 06:07:07 +02:00
|
|
|
while true ; do
|
2023-09-04 13:50:21 +02:00
|
|
|
read -p "Country Code (eg, US): " COUNTRY_CODE
|
2023-09-01 06:23:15 +02:00
|
|
|
if [ ${#COUNTRY_CODE} -ne 2 ] ; then
|
2023-09-01 06:07:07 +02:00
|
|
|
echo "You must enter a 2 character country code"
|
|
|
|
else
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
while true ; do
|
2023-09-04 13:50:21 +02:00
|
|
|
read -p "State/Region (eg. Ohio): " STATE
|
2023-09-01 06:07:07 +02:00
|
|
|
if [ $STATE ] ; then break ; else echo "State MUST be entered" ; fi
|
|
|
|
done
|
|
|
|
while true ; do
|
2023-09-04 13:50:21 +02:00
|
|
|
read -p "City/Location (eg. Columbus): " LOCATION
|
2023-09-01 06:07:07 +02:00
|
|
|
if [ $LOCATION ] ; then break ; else echo "City MUST be entered" ; fi
|
|
|
|
done
|
|
|
|
while true ; do
|
2023-09-04 13:50:21 +02:00
|
|
|
read -p "Organisation (eg. Koozali): " ORGANIZATION
|
2023-09-01 06:07:07 +02:00
|
|
|
if [ $ORGANIZATION ] ; then break ; else echo "Organization MUST be entered" ; fi
|
|
|
|
done
|
|
|
|
while true ; do
|
2023-09-04 13:50:21 +02:00
|
|
|
read -p "Org Unit (eg. Koji): " ORG_UNIT
|
2023-09-01 06:07:07 +02:00
|
|
|
if [ $ORG_UNIT ] ; then break ; else echo "Organizational Unit MUST be entered" ; fi
|
|
|
|
done
|
2023-09-01 00:53:11 +02:00
|
|
|
|
2023-09-04 02:51:05 +02:00
|
|
|
# setup default parameters
|
|
|
|
KOJI_HUB_FQDN="$(hostname -f)"
|
2023-09-04 07:38:11 +02:00
|
|
|
HTTPD_USER=apache
|
|
|
|
HTTPD_DOCUMENT_ROOT=/var/www/html
|
2023-09-04 02:51:05 +02:00
|
|
|
KOJI_DIR="/mnt/koji"
|
|
|
|
TAG_NAME="sme"
|
2023-09-04 07:48:02 +02:00
|
|
|
KOJI_PKI_DIR=/etc/pki/koji
|
2023-09-04 02:51:05 +02:00
|
|
|
RPM_ARCH="x86_64 noarch"
|
|
|
|
KOJID_CAPACITY=16
|
|
|
|
SRC_RPM_DIR=
|
|
|
|
BIN_RPM_DIR=
|
|
|
|
DEBUG_RPM_DIR=
|
2023-09-04 03:01:52 +02:00
|
|
|
EXTERNAL_REPO="http://buildsys.koozali.org/build/7/os/\$arch/"
|
2023-09-04 07:38:11 +02:00
|
|
|
POSTGRES_USER=postgres
|
|
|
|
POSTGRES_DIR=/var/lib/pgsql
|
2023-09-01 06:07:07 +02:00
|
|
|
|
2023-09-04 02:51:05 +02:00
|
|
|
# create the parameter script used by koji scripts
|
|
|
|
cat > $SCRIPT_DIR/koji-parameters.sh <<- EOT
|
|
|
|
#!/bin/bash
|
2023-09-04 07:10:17 +02:00
|
|
|
## HTTPD settings
|
2023-09-04 07:38:11 +02:00
|
|
|
export HTTPD_USER=$HTTPD_USER
|
|
|
|
export HTTPD_DOCUMENT_ROOT=$HTTPD_DOCUMENT_ROOT
|
2023-09-01 01:44:52 +02:00
|
|
|
## KOJI RPM BUILD AND TRACKER
|
2023-09-04 02:51:05 +02:00
|
|
|
export SCRIPT_GIT=$SCRIPT_GIT
|
2023-09-04 07:54:44 +02:00
|
|
|
export KOJI_DIR=$KOJI_DIR
|
2023-09-04 08:07:57 +02:00
|
|
|
export KOJI_HUB_FQDN=$KOJI_HUB_FQDN
|
|
|
|
export KOJI_URL=http://$KOJI_HUB_FQDN
|
2023-09-02 07:39:30 +02:00
|
|
|
export KOJID_CAPACITY=$KOJID_CAPACITY
|
2023-09-04 02:51:05 +02:00
|
|
|
export TAG_NAME=$TAG_NAME
|
2023-09-01 01:44:52 +02:00
|
|
|
# Use for koji SSL certificates
|
2023-09-04 07:38:11 +02:00
|
|
|
export KOJI_PKI_DIR=$KOJI_PKI_DIR
|
2023-09-01 01:44:52 +02:00
|
|
|
export COUNTRY_CODE='$COUNTRY_CODE'
|
|
|
|
export STATE='$STATE'
|
|
|
|
export LOCATION='$LOCATION'
|
|
|
|
export ORGANIZATION='$ORGANIZATION'
|
|
|
|
export ORG_UNIT='$ORG_UNIT'
|
|
|
|
# Use for importing existing RPMs
|
2023-09-04 02:51:05 +02:00
|
|
|
export RPM_ARCH=$RPM_ARCH
|
|
|
|
export SRC_RPM_DIR=$SRC_RPM_DIR
|
|
|
|
export BIN_RPM_DIR=$BIN_RPM_DIR
|
|
|
|
export DEBUG_RPM_DIR=$DEBUG_PRM_DIR
|
2023-09-01 01:44:52 +02:00
|
|
|
# Comment the following if supplying all RPMs as an upstream and not a downstream
|
2023-09-04 02:51:05 +02:00
|
|
|
export EXTERNAL_REPO=$EXTERNAL_REPO
|
2023-09-01 01:44:52 +02:00
|
|
|
## POSTGRESQL DATABASE
|
2023-09-04 07:38:11 +02:00
|
|
|
export POSTGRES_USER=$POSTGRES_USER
|
|
|
|
export POSTGRES_DIR=$POSTGRES_DIR
|
2023-09-01 01:44:52 +02:00
|
|
|
EOT
|
2023-09-04 03:39:25 +02:00
|
|
|
chmod o+x $SCRIPT_DIR/koji-parameters.sh
|
2023-09-01 06:07:07 +02:00
|
|
|
|
2023-09-04 02:51:05 +02:00
|
|
|
# deploy the central koji components
|
|
|
|
koji-deploy-hub.sh $DEBUG
|
2023-09-01 06:07:07 +02:00
|
|
|
|
2023-09-04 02:51:05 +02:00
|
|
|
# add builders
|
|
|
|
PROMPT="Build server FQDN (will default to hub '$KOJI_HUB_FQDN' if left blank) "
|
2023-09-02 06:37:19 +02:00
|
|
|
BSNO=1
|
|
|
|
while true ; do
|
|
|
|
read -p "$PROMPT" KOJI_BUILD_FQDN
|
|
|
|
PROMPT="Build server FQDN. (will stop asking if left blank) "
|
|
|
|
if [ -z $KOJI_BUILD_FQDN ] ; then
|
|
|
|
if [[ $BSNO -gt 1 ]] ; then
|
|
|
|
break
|
|
|
|
else
|
|
|
|
echo "All-in-one: Hub will now be a build server as well"
|
2023-09-04 02:51:05 +02:00
|
|
|
koji-add-builder.sh $DEBUG
|
2023-09-02 06:37:19 +02:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
# check if server available on port 22
|
|
|
|
until (nc -z $KOJI_BUILD_FQDN 22)
|
|
|
|
do
|
|
|
|
echo "I cannot connect to $KOJI_BUILD_FQDN! Is it online? "
|
|
|
|
echo "Options:"
|
|
|
|
echo "- FQDN=<FQDN of build server> # if you've mis-typed the name"
|
|
|
|
echo "- IP=<IP of build server> # I'll add this to your /etc/hosts file"
|
|
|
|
echo "- <enter> # try again (I've started the server)"
|
2023-09-04 02:51:05 +02:00
|
|
|
echo "- Q # quit this loop (give up)"
|
2023-09-02 06:37:19 +02:00
|
|
|
read RESPONSE
|
|
|
|
case $RESPONSE in
|
|
|
|
Q | q )
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
null )
|
|
|
|
continue
|
|
|
|
;;
|
|
|
|
IP=* )
|
|
|
|
BIP=${RESPONSE#*=}
|
2023-09-02 07:39:30 +02:00
|
|
|
# add this builder into the hosts file
|
2023-09-02 06:37:19 +02:00
|
|
|
echo "$BIP $KOJI_BUILD_FQDN\n" >> /etc/hosts
|
|
|
|
continue
|
|
|
|
;;
|
|
|
|
FQDN=* )
|
|
|
|
KOJI_BUILD_FQDN=${RESPONSE#*=}
|
2023-09-02 07:39:30 +02:00
|
|
|
continue
|
2023-09-02 06:37:19 +02:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
continue
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
2023-09-04 02:51:05 +02:00
|
|
|
|
2023-09-02 06:37:19 +02:00
|
|
|
# we found the server and will deploy to it
|
|
|
|
echo "$KOJI_BUILD_FQDN will be Koji Build server No. $BSNO"
|
|
|
|
((BSNO=BSNO+1))
|
2023-09-04 02:51:05 +02:00
|
|
|
koji-add-builder.sh $KOJI_BUILD_FQDN $DEBUG
|
2023-09-02 06:37:19 +02:00
|
|
|
|
2023-09-04 02:51:05 +02:00
|
|
|
done
|
2023-09-01 06:07:07 +02:00
|
|
|
|
|
|
|
#
|
2023-09-04 02:51:05 +02:00
|
|
|
koji-bootstrap-build.sh
|