mirror of
https://src.koozali.org/infra/smeserver-koji.git
synced 2024-11-21 17:17:28 +01:00
170 lines
4.7 KiB
Bash
170 lines
4.7 KiB
Bash
#!/bin/bash
|
|
|
|
set -e
|
|
DEBUG=
|
|
for param in $1 $2 $3 ; do
|
|
if [ $param ] ; then
|
|
case $param in
|
|
debug )
|
|
DEBUG="debug" ;;
|
|
esac
|
|
else
|
|
break
|
|
fi
|
|
done
|
|
|
|
SILENT="-s"
|
|
QUIET="-q"
|
|
if [ $DEBUG ] ; then
|
|
set -xe
|
|
SILENT=
|
|
QUIET="-v"
|
|
fi
|
|
|
|
# pull down the deploy scripts
|
|
SCRIPT_GIT="https://src.koozali.org/smedev/smeserver-koji/raw/branch/master/koji-setup"
|
|
SCRIPT_DIR="$(echo ~)/bin"
|
|
|
|
mkdir -p $SCRIPT_DIR
|
|
curl $SILENT $SCRIPT_GIT/koji-deploy-hub.sh > $SCRIPT_DIR/koji-deploy-hub.sh
|
|
curl $SILENT $SCRIPT_GIT/koji-bootstrap-build.sh > $SCRIPT_DIR/koji-bootstrap-build.sh
|
|
chmod o+x $SCRIPT_DIR/*.sh
|
|
|
|
# install any required packages
|
|
if [ ! "dnf list installed | grep epel-release" ] ; then
|
|
dnf install -y epel-release $QUIET
|
|
fi
|
|
if [ ! "dnf list installed | grep netcat" ] ; then
|
|
dnf install -y netcat $QUIET
|
|
fi
|
|
|
|
# ask for required parameters (ssh settings and build server FQDN)
|
|
while true ; do
|
|
read -p "Country Code (eg, US) " COUNTRY_CODE
|
|
if [ ${#COUNTRY_CODE} -ne 2 ] ; then
|
|
echo "You must enter a 2 character country code"
|
|
else
|
|
break
|
|
fi
|
|
done
|
|
while true ; do
|
|
read -p "State (eg. Ohio) " STATE
|
|
if [ $STATE ] ; then break ; else echo "State MUST be entered" ; fi
|
|
done
|
|
while true ; do
|
|
read -p "City (eg. Columbus) " LOCATION
|
|
if [ $LOCATION ] ; then break ; else echo "City MUST be entered" ; fi
|
|
done
|
|
while true ; do
|
|
read -p "Organisation (eg. Koozali) " ORGANIZATION
|
|
if [ $ORGANIZATION ] ; then break ; else echo "Organization MUST be entered" ; fi
|
|
done
|
|
while true ; do
|
|
read -p "Org Unit (eg. Koji) " ORG_UNIT
|
|
if [ $ORG_UNIT ] ; then break ; else echo "Organizational Unit MUST be entered" ; fi
|
|
done
|
|
|
|
# setup default parameters
|
|
KOJI_HUB_FQDN="$(hostname -f)"
|
|
KOJI_DIR="/mnt/koji"
|
|
TAG_NAME="sme"
|
|
RPM_ARCH="x86_64 noarch"
|
|
KOJID_CAPACITY=16
|
|
SRC_RPM_DIR=
|
|
BIN_RPM_DIR=
|
|
DEBUG_RPM_DIR=
|
|
EXTERNAL_REPO="http://mirrorlist.centos.org/releases/10/smeos/"
|
|
|
|
# create the parameter script used by koji scripts
|
|
cat > $SCRIPT_DIR/koji-parameters.sh <<- EOT
|
|
#!/bin/bash
|
|
## Standard locations
|
|
export POSTGRES_USER=postgres
|
|
export POSTGRES_DEFAULT_DIR=/var/lib/pgsql
|
|
export HTTPD_USER=apache
|
|
export HTTPD_DOCUMENT_ROOT=/var/www/html
|
|
export KOJI_PKI_DIR=/etc/pki/koji
|
|
## KOJI RPM BUILD AND TRACKER
|
|
export SCRIPT_GIT=$SCRIPT_GIT
|
|
export KOJI_DIR=$KOJID_DIR
|
|
export KOJI_HUB_FQDN="$KOJI_HUB_FQDN"
|
|
export KOJI_URL=http://"$KOJI_HUB_FQDN"
|
|
export KOJID_CAPACITY=$KOJID_CAPACITY
|
|
export TAG_NAME=$TAG_NAME
|
|
# Use for koji SSL certificates
|
|
export COUNTRY_CODE='$COUNTRY_CODE'
|
|
export STATE='$STATE'
|
|
export LOCATION='$LOCATION'
|
|
export ORGANIZATION='$ORGANIZATION'
|
|
export ORG_UNIT='$ORG_UNIT'
|
|
# Use for importing existing RPMs
|
|
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
|
|
# Comment the following if supplying all RPMs as an upstream and not a downstream
|
|
export EXTERNAL_REPO=$EXTERNAL_REPO
|
|
## POSTGRESQL DATABASE
|
|
export POSTGRES_DIR=/var/lib/pgsql
|
|
EOT
|
|
|
|
# deploy the central koji components
|
|
koji-deploy-hub.sh $DEBUG
|
|
|
|
# add builders
|
|
PROMPT="Build server FQDN (will default to hub '$KOJI_HUB_FQDN' if left blank) "
|
|
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"
|
|
koji-add-builder.sh $DEBUG
|
|
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)"
|
|
echo "- Q # quit this loop (give up)"
|
|
read RESPONSE
|
|
case $RESPONSE in
|
|
Q | q )
|
|
break
|
|
;;
|
|
null )
|
|
continue
|
|
;;
|
|
IP=* )
|
|
BIP=${RESPONSE#*=}
|
|
# add this builder into the hosts file
|
|
echo "$BIP $KOJI_BUILD_FQDN\n" >> /etc/hosts
|
|
continue
|
|
;;
|
|
FQDN=* )
|
|
KOJI_BUILD_FQDN=${RESPONSE#*=}
|
|
continue
|
|
;;
|
|
*)
|
|
continue
|
|
;;
|
|
esac
|
|
done
|
|
|
|
# we found the server and will deploy to it
|
|
echo "$KOJI_BUILD_FQDN will be Koji Build server No. $BSNO"
|
|
((BSNO=BSNO+1))
|
|
koji-add-builder.sh $KOJI_BUILD_FQDN $DEBUG
|
|
|
|
done
|
|
|
|
#
|
|
koji-bootstrap-build.sh |