Skip to content

Commit

Permalink
Fixes #116 Show banner when installing packages using yum
Browse files Browse the repository at this point in the history
  • Loading branch information
gbraad committed Jul 20, 2017
1 parent 481e600 commit d4d252a
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 4 deletions.
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
BUILD_DIR=$(shell pwd)/build
BIN_DIR=$(BUILD_DIR)/bin
HANDLE_USER_DATA=$(shell base64 -w 0 scripts/handle-user-data)
YUM_WRAPPER=$(shell base64 -w 0 scripts/yum-wrapper)
CERT_GEN=$(shell base64 -w 0 scripts/cert-gen.sh)
VERSION=1.0.0
GITTAG=$(shell git rev-parse --short HEAD)
Expand Down Expand Up @@ -37,8 +38,9 @@ rhel_iso: iso_creation

.PHONY: iso_creation
iso_creation: init
@handle_user_data='$(HANDLE_USER_DATA)' cert_gen='$(CERT_GEN)' version='$(VERSION)' build_id='$(GITTAG)-$(TODAY)-$(BUILD_ID)' \
envsubst < $(KICKSTART_TEMPLATE) > $(BUILD_DIR)/$(KICKSTART_FILE)
@handle_user_data='$(HANDLE_USER_DATA)' yum_wrapper='$(YUM_WRAPPER)' cert_gen='$(CERT_GEN)' \
version='$(VERSION)' build_id='$(GITTAG)-$(TODAY)-$(BUILD_ID)' \
envsubst < $(KICKSTART_TEMPLATE) > $(BUILD_DIR)/$(KICKSTART_FILE)
cd $(BUILD_DIR); sudo livecd-creator --config $(BUILD_DIR)/$(KICKSTART_FILE) --logfile=$(BUILD_DIR)/livecd-creator.log --fslabel $(ISO_NAME)
# http://askubuntu.com/questions/153833/why-cant-i-mount-the-ubuntu-12-04-installer-isos-in-mac-os-x
# http://www.syslinux.org/wiki/index.php?title=Doc/isolinux#HYBRID_CD-ROM.2FHARD_DISK_MODE
Expand Down
16 changes: 15 additions & 1 deletion centos-7.template
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ echo "LANG=\"C\"" > /etc/locale.conf
echo "%docker ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/docker
sed -i "s/^.*requiretty/#Defaults requiretty/" /etc/sudoers

# Place holder for base64 encrypt handle-user-data script
# Place holder for base64 encode handle-user-data script
cat > handle-user-data.base64 << EOF
${handle_user_data}
EOF
Expand All @@ -95,6 +95,7 @@ echo "VARIANT_VERSION=\"${version}\"" >> /etc/os-release
echo "BUILD_ID=\"${build_id}\"" >> /etc/os-release

base64 -d < handle-user-data.base64 > handle-user-data
rm handle-user-data.base64
mv handle-user-data /etc/rc.d/init.d/

chmod +x /etc/rc.d/init.d/handle-user-data
Expand All @@ -117,6 +118,7 @@ ${cert_gen}
EOF

base64 -d < cert-gen.sh.base64 > cert-gen.sh
rm cert-gen.sh.base64
chmod +x cert-gen.sh
mv cert-gen.sh /opt

Expand Down Expand Up @@ -166,6 +168,18 @@ EOF

systemctl enable docker

# Show a warning banner when using yum to install software
mv /usr/bin/yum /usr/bin/yum-unsupported
# Place holder for base64 encode yum-wrapper script
cat > yum-wrapper.base64 << EOF
${yum_wrapper}
EOF
base64 -d < yum-wrapper.base64 > yum-wrapper
rm yum-wrapper.base64
mv yum-wrapper /usr/bin/yum
chmod +x /usr/bin/yum

# Clean
rm -rf /usr/lib/locale/locale-archive
rm -rf /var/cache/yum/*

Expand Down
15 changes: 14 additions & 1 deletion rhel-7.template
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ TYPE="Ethernet"
PERSISTENT_DHCLIENT="yes"
EOF

# Place holder for base64 encrypt handle-user-data script
# Place holder for base64 encode handle-user-data script
cat > handle-user-data.base64 << EOF
${handle_user_data}
EOF
Expand All @@ -112,6 +112,7 @@ echo "VARIANT_VERSION=\"${version}\"" >> /etc/os-release
echo "BUILD_ID=\"${build_id}\"" >> /etc/os-release

base64 -d < handle-user-data.base64 > handle-user-data
rm handle-user-data.base64
mv handle-user-data /etc/rc.d/init.d/

chmod +x /etc/rc.d/init.d/handle-user-data
Expand All @@ -134,6 +135,7 @@ ${cert_gen}
EOF

base64 -d < cert-gen.sh.base64 > cert-gen.sh
rm cert-gen.sh.base64
chmod +x cert-gen.sh
mv cert-gen.sh /opt

Expand Down Expand Up @@ -186,6 +188,17 @@ EOF
systemctl enable docker
systemctl enable rhel-push-plugin

# Show a warning banner when using yum to install software
mv /usr/bin/yum /usr/bin/yum-unsupported
# Place holder for base64 encode yum-wrapper script
cat > yum-wrapper.base64 << EOF
${yum_wrapper}
EOF
base64 -d < yum-wrapper.base64 > yum-wrapper
rm yum-wrapper.base64
mv yum-wrapper /usr/bin/yum
chmod +x /usr/bin/yum

rm -f /etc/resolv.conf
rm -rf /usr/lib/locale/locale-archive
rm -rf /var/cache/yum/*
Expand Down
11 changes: 11 additions & 0 deletions scripts/yum-wrapper
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
echo "Installing additional packages is not supported. Continue [y/n]"

if echo "$@" | grep -iq " -y" ; then
answer="y"
else
read answer
fi
if echo "$answer" | grep -iq "^y" ; then
yum-unsupported $@
fi

0 comments on commit d4d252a

Please sign in to comment.