Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 51 additions & 41 deletions ci/setup-cfengine-build-host.sh
Original file line number Diff line number Diff line change
Expand Up @@ -126,52 +126,57 @@ if grep 6.10 /etc/issue; then
urlget https://cfengine-package-repos.s3.amazonaws.com/enterprise/Enterprise-3.24.3/misc/cfengine-masterfiles-3.24.3-1.pkg.tar.gz
fi

if [ -x /var/cfengine/bin/cf-agent ]; then
echo "Case of pre-installed CFEngine so skipping cf-remote install and assuming download of masterfiles earlier in the script."
else
echo "Installing cf-remote for possible package install and masterfiles download"
# try pipx first for debian as pip won't work.
# If that fails to install CFEngine then try python3-pip for redhats.
PIP=""
software python3-venv || true # on ubuntu-20 this is needed, debian-12 it is not but won't hurt
if software pipx; then
PIP=pipx
export PATH=$HOME/.local/bin:$PATH
elif software python3-pip; then
if command -v pip; then
PIP=pip
elif command -v pip3; then
PIP=pip3
fi
elif software python-pip; then
if command -v pip; then
PIP=pip
if grep suse /etc/os-release; then
if grep -i version=\"12 /etc/os-release; then
echo "SUSE-12 found, cf-remote cannot be installed here so download directly similar to CentOS-6."
if [ ! -x /var/cfengine/bin/cf-agent ]; then
urlget https://cfengine-package-repos.s3.amazonaws.com/pub/gpg.key
rpm --import gpg.key
rm -rf cfengine-nova*rpm
urlget https://cfengine-package-repos.s3.amazonaws.com/enterprise/Enterprise-3.24.3/agent/agent_suse12_x86_64/cfengine-nova-3.24.3-1.suse12.x86_64.rpm
zypper in -y cfengine-nova-3.24.3-1.suse12.x86_64.rpm
fi
else
echo "Tried installing pipx, python3-pip and python-pip, none of which resulted in pipx, pip3 or pip being available. Exiting."
exit 23
urlget https://cfengine-package-repos.s3.amazonaws.com/enterprise/Enterprise-3.24.3/misc/cfengine-masterfiles-3.24.3-1.pkg.tar.gz
fi
export PATH=/usr/local/bin:$PATH # some pip/pipx use /usr/local/bin

$PIP uninstall cf-remote || true # just in case a previous is there and would cause the install to fail
$PIP install cf-remote
fi

if ! command -v cf-remote; then
echo "cf-remote was not installed, it is required so exiting now"
exit 42
echo "Installing cf-remote for possible package install and masterfiles download"
# try pipx first for debian as pip won't work.
# If that fails to install CFEngine then try python3-pip for redhats.
PIP=""
software python3-venv || true # on ubuntu-20 this is needed, debian-12 it is not but won't hurt
if software pipx; then
PIP=pipx
export PATH=$HOME/.local/bin:$PATH
elif software python3-pip; then
if command -v pip; then
PIP=pip
elif command -v pip3; then
PIP=pip3
fi
elif software python-pip; then
if command -v pip; then
PIP=pip
fi
else
echo "Tried installing pipx, python3-pip and python-pip, none of which resulted in pipx, pip3 or pip being available. Exiting."
exit 23
fi
export PATH=/usr/local/bin:$PATH # some pip/pipx use /usr/local/bin

echo "Checking for pre-installed CFEngine (chicken/egg problem)"
# We need a cf-agent to run build host setup policy and redhat-10-arm did not have a previous package to install.
if ! /var/cfengine/bin/cf-agent -V; then
echo "No existing CFEngine install found, try cf-remote..."
if [ -n "$DEBIAN_STRETCH" ]; then
_VERSION="--version 3.21.8"
else
_VERSION="--version master"
fi
cf-remote --log-level info $_VERSION install --clients localhost || true
$PIP uninstall cf-remote || true # just in case a previous is there and would cause the install to fail
$PIP install cf-remote || true # if this fails we will try to install from source

echo "Checking for pre-installed CFEngine (chicken/egg problem)"
# We need a cf-agent to run build host setup policy and redhat-10-arm did not have a previous package to install.
if ! /var/cfengine/bin/cf-agent -V; then
echo "No existing CFEngine install found, try cf-remote..."
if [ -n "$DEBIAN_STRETCH" ]; then
_VERSION="--version 3.21.8"
else
_VERSION=""
fi
cf-remote --log-level info $_VERSION install --clients localhost || true
fi

if [ ! -x /var/cfengine/bin/cf-agent ]; then
Expand All @@ -188,7 +193,12 @@ fi

# download masterfiles if not already present (such as in case of centos-6 above, hard-coded 3.24.3 download)
if ! ls cfengine-masterfiles*gz; then
cf-remote download masterfiles --output-dir .
# if we are using a CFEngine pre-installed (chicken/egg) image we would skip cf-remote install so need to download directly
if ! command -v cf-remote; then
urlget https://cfengine-package-repos.s3.amazonaws.com/enterprise/Enterprise-3.27.0/misc/cfengine-masterfiles-3.27.0-1.pkg.tar.gz
else
cf-remote download masterfiles --output-dir .
fi
fi
tar xf cfengine-masterfiles-*tar.gz
cp -a masterfiles/* /var/cfengine/inputs/
Expand Down