forked from openshift/ironic-image
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprepare-image.sh
executable file
·85 lines (66 loc) · 3.12 KB
/
prepare-image.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/bash
set -euxo pipefail
echo "install_weak_deps=False" >> /etc/dnf/dnf.conf
# Tell RPM to skip installing documentation
echo "tsflags=nodocs" >> /etc/dnf/dnf.conf
dnf upgrade -y
xargs -rtd'\n' dnf install -y < /tmp/${PKGS_LIST}
if [ $(uname -m) = "x86_64" ]; then
dnf install -y syslinux-nonlinux;
fi
if [[ -n "${EXTRA_PKGS_LIST:-}" ]]; then
if [[ -s "/tmp/${EXTRA_PKGS_LIST}" ]]; then
xargs -rtd'\n' dnf install -y < /tmp/"${EXTRA_PKGS_LIST}"
fi
fi
### cachito magic works for OCP only
if [[ -f /tmp/main-packages-list.ocp ]]; then
REQS="${REMOTE_SOURCES_DIR}/requirements.cachito"
IRONIC_UID=1002
IRONIC_GID=1003
INSPECTOR_GID=1004
ls -la "${REMOTE_SOURCES_DIR}/" # DEBUG
# load cachito variables only if they're available
if [[ -d "${REMOTE_SOURCES_DIR}/cachito-gomod-with-deps" ]]; then
source "${REMOTE_SOURCES_DIR}/cachito-gomod-with-deps/cachito.env"
REQS="${REMOTE_SOURCES_DIR}/cachito-gomod-with-deps/app/requirements.cachito"
fi
### source install ###
BUILD_DEPS="python3-devel gcc gcc-c++"
dnf install -y python3-pip python3-setuptools $BUILD_DEPS
# NOTE(elfosardo): --no-index is used to install the packages emulating
# an isolated environment in CI. Do not use the option for downstream
# builds.
# NOTE(janders): adding --no-compile option to avoid issues in FIPS
# enabled environments. See https://issues.redhat.com/browse/RHEL-29028
# for more information
PIP_OPTIONS="--no-compile"
if [[ ! -d "${REMOTE_SOURCES_DIR}/cachito-gomod-with-deps" ]]; then
PIP_OPTIONS="$PIP_OPTIONS --no-index"
fi
python3 -m pip install $PIP_OPTIONS --prefix /usr -r "${REQS}"
# NOTE(janders) since we set --no-compile at install time, we need to
# compile post-install (see RHEL-29028)
python3 -m compileall --invalidation-mode=timestamp /usr
# ironic and ironic-inspector system configuration
mkdir -p /var/log/ironic /var/log/ironic-inspector /var/lib/ironic /var/lib/ironic-inspector
getent group ironic >/dev/null || groupadd -r -g "${IRONIC_GID}" ironic
getent passwd ironic >/dev/null || useradd -r -g ironic -s /sbin/nologin -u "${IRONIC_UID}" ironic -d /var/lib/ironic
getent group ironic-inspector >/dev/null || groupadd -r -g "${INSPECTOR_GID}" ironic-inspector
getent passwd ironic-inspector >/dev/null || useradd -r -g ironic-inspector -s /sbin/nologin ironic-inspector -d /var/lib/ironic-inspector
dnf remove -y $BUILD_DEPS
if [[ -d "${REMOTE_SOURCES_DIR}/cachito-gomod-with-deps" ]]; then
rm -rf $REMOTE_SOURCES_DIR
fi
fi
###
chown ironic:ironic /var/log/ironic
# This file is generated after installing mod_ssl and it affects our configuration
rm -f /etc/httpd/conf.d/ssl.conf /etc/httpd/conf.d/autoindex.conf /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.modules.d/*.conf
# RDO-provided configuration forces creating log files
rm -f /usr/share/ironic/ironic-dist.conf /etc/ironic-inspector/inspector-dist.conf
# add ironic and ironic-inspector to apache group
usermod -aG ironic apache
usermod -aG ironic-inspector apache
dnf clean all
rm -rf /var/cache/{yum,dnf}/*