diff --git a/elements/base/install.d/50-store-build-settings b/elements/base/install.d/50-store-build-settings index 8c11aa38a..8da0c06a7 100755 --- a/elements/base/install.d/50-store-build-settings +++ b/elements/base/install.d/50-store-build-settings @@ -5,9 +5,9 @@ set -eu set -o pipefail if [ -e "/tmp/in_target.d/dib_environment" ]; then - cp /tmp/in_target.d/dib_environment /etc/ + cp /tmp/in_target.d/dib_environment /etc/ fi if [ -e "/tmp/in_target.d/dib_arguments" ]; then - cp /tmp/in_target.d/dib_arguments /etc/ + cp /tmp/in_target.d/dib_arguments /etc/ fi diff --git a/elements/base/pre-install.d/03-baseline-tools b/elements/base/pre-install.d/03-baseline-tools index 39361da38..e7eac4b06 100755 --- a/elements/base/pre-install.d/03-baseline-tools +++ b/elements/base/pre-install.d/03-baseline-tools @@ -8,10 +8,10 @@ set -o pipefail DISTRO=`lsb_release -si` || true case $DISTRO in - 'Ubuntu'|'Debian') - # Note: add-apt-repository would be nice for RPM platforms too - so when we - # need something like it, create a wrapper in dpkg/bin and fedora/bin. - apt-get -y update - install-packages python-software-properties - ;; + 'Ubuntu'|'Debian') + # Note: add-apt-repository would be nice for RPM platforms too - so when we + # need something like it, create a wrapper in dpkg/bin and fedora/bin. + apt-get -y update + install-packages python-software-properties + ;; esac diff --git a/elements/cache-url/bin/cache-url b/elements/cache-url/bin/cache-url index f37e3212d..5b0de9447 100755 --- a/elements/cache-url/bin/cache-url +++ b/elements/cache-url/bin/cache-url @@ -26,12 +26,12 @@ dest=$2 time_cond= if [ -p $dest ]; then - type="fifo" - tmp=$(mktemp --tmpdir download.XXXXXXXX) + type="fifo" + tmp=$(mktemp --tmpdir download.XXXXXXXX) else - type="normal" - mkdir -p $(dirname $dest) - tmp=$(mktemp $(dirname $dest)/.download.XXXXXXXX) + type="normal" + mkdir -p $(dirname $dest) + tmp=$(mktemp $(dirname $dest)/.download.XXXXXXXX) fi if [ -f $dest -a -s $dest ] ; then @@ -52,14 +52,14 @@ if [ "$rcode" == "200" -o "${url:0:7}" == "file://" ] ; then else echo $success if [ "fifo" = "$type" ]; then - cp $tmp $dest - rm $tmp + cp $tmp $dest + rm $tmp else - mv $tmp $dest + mv $tmp $dest fi fi -# 213 is the response to a ftp MDTM command, curl outputs a 213 as the status -# if the url redirected to a ftp server and Not-Modified + # 213 is the response to a ftp MDTM command, curl outputs a 213 as the status + # if the url redirected to a ftp server and Not-Modified elif [ "$rcode" = "304" -o "$rcode" = "213" ] ; then echo "Server copy has not changed. Using locally cached $url" rm -f $tmp diff --git a/elements/dhcp-all-interfaces/install.d/dhcp-all-interfaces.sh b/elements/dhcp-all-interfaces/install.d/dhcp-all-interfaces.sh index 0c9b7a775..f3c425e97 100755 --- a/elements/dhcp-all-interfaces/install.d/dhcp-all-interfaces.sh +++ b/elements/dhcp-all-interfaces/install.d/dhcp-all-interfaces.sh @@ -20,46 +20,46 @@ fi ARGS="$0 $@" function serialize_me() { - if [ "$CONF_TYPE" == "eni" ]; then - # Serialize runs so that we don't miss hot-add interfaces - FLOCKED=${FLOCKED:-} - if [ -z "$FLOCKED" ] ; then - FLOCKED=true exec flock -x $ENI_FILE $ARGS - fi - fi + if [ "$CONF_TYPE" == "eni" ]; then + # Serialize runs so that we don't miss hot-add interfaces + FLOCKED=${FLOCKED:-} + if [ -z "$FLOCKED" ] ; then + FLOCKED=true exec flock -x $ENI_FILE $ARGS + fi + fi } function get_if_link() { - cat /sys/class/net/${1}/carrier + cat /sys/class/net/${1}/carrier } function enable_interface() { - local interface=$1 + local interface=$1 - serialize_me - if [ "$CONF_TYPE" == "eni" ]; then - printf "auto $interface\niface $interface inet dhcp\n\n" >>$ENI_FILE - elif [ "$CONF_TYPE" == "netscripts" ]; then - printf "DEVICE=\"$interface\"\nBOOTPROTO=\"dhcp\"\nONBOOT=\"yes\"\nTYPE=\"Ethernet\"" >"/etc/sysconfig/network-scripts/ifcfg-$interface" - fi - echo "Configured $1" + serialize_me + if [ "$CONF_TYPE" == "eni" ]; then + printf "auto $interface\niface $interface inet dhcp\n\n" >>$ENI_FILE + elif [ "$CONF_TYPE" == "netscripts" ]; then + printf "DEVICE=\"$interface\"\nBOOTPROTO=\"dhcp\"\nONBOOT=\"yes\"\nTYPE=\"Ethernet\"" >"/etc/sysconfig/network-scripts/ifcfg-$interface" + fi + echo "Configured $1" } function disable_interface() { - local interface=$1 + local interface=$1 - serialize_me - if [ "$CONF_TYPE" == "netscripts" ]; then - local IFCFG_FILE="/etc/sysconfig/network-scripts/ifcfg-$interface" - if [ -f "$IFCFG_FILE" ]; then - rm $IFCFG_FILE - else - echo "No link detected, skipping" - fi - else - echo "No link detected, skipping" - fi + serialize_me + if [ "$CONF_TYPE" == "netscripts" ]; then + local IFCFG_FILE="/etc/sysconfig/network-scripts/ifcfg-$interface" + if [ -f "$IFCFG_FILE" ]; then + rm $IFCFG_FILE + else + echo "No link detected, skipping" + fi + else + echo "No link detected, skipping" + fi } function config_exists() { @@ -75,34 +75,34 @@ function config_exists() { } function inspect_interface() { - local interface=$1 - local mac_addr_type="$(cat /sys/class/net/${interface}/addr_assign_type)" + local interface=$1 + local mac_addr_type="$(cat /sys/class/net/${interface}/addr_assign_type)" - echo -n "Inspecting interface: $interface..." - if config_exists $interface; then - echo "Has config, skipping." - elif [ "$mac_addr_type" != "0" ]; then - echo "Device has generated MAC, skipping." - else - ip link set dev $interface up &>/dev/null - HAS_LINK="$(get_if_link $interface)" + echo -n "Inspecting interface: $interface..." + if config_exists $interface; then + echo "Has config, skipping." + elif [ "$mac_addr_type" != "0" ]; then + echo "Device has generated MAC, skipping." + else + ip link set dev $interface up &>/dev/null + HAS_LINK="$(get_if_link $interface)" - TRIES=10 - while [ "$HAS_LINK" == "0" -a $TRIES -gt 0 ]; do - HAS_LINK="$(get_if_link $interface)" - if [ "$HAS_LINK" == "1" ]; then - break - else - sleep 1 - fi - TRIES=$(( TRIES - 1 )) - done - if [ "$HAS_LINK" == "1" ] ; then - enable_interface "$interface" - else - disable_interface "$interface" + TRIES=10 + while [ "$HAS_LINK" == "0" -a $TRIES -gt 0 ]; do + HAS_LINK="$(get_if_link $interface)" + if [ "$HAS_LINK" == "1" ]; then + break + else + sleep 1 + fi + TRIES=$(( TRIES - 1 )) + done + if [ "$HAS_LINK" == "1" ] ; then + enable_interface "$interface" + else + disable_interface "$interface" + fi fi - fi } diff --git a/elements/dib-run-parts/bin/dib-run-parts b/elements/dib-run-parts/bin/dib-run-parts index c2a4e5e4e..85715ce74 100755 --- a/elements/dib-run-parts/bin/dib-run-parts +++ b/elements/dib-run-parts/bin/dib-run-parts @@ -62,10 +62,10 @@ fi targets=$(find $target_dir -maxdepth 1 -xtype f -executable -printf '%f\n' | grep -E "$allowed_regex" | LANG=C sort -n || echo "") if [ "$show_list" == "1" ] ; then - for target in $targets ; do - echo "${target_dir}/${target}" - done - exit 0 + for target in $targets ; do + echo "${target_dir}/${target}" + done + exit 0 fi PROFILE_DIR=$(mktemp -d /tmp/profiledir.XXXXXX) diff --git a/elements/dkms/post-install.d/99-dkms b/elements/dkms/post-install.d/99-dkms index 0abe0e03d..d462ce27a 100755 --- a/elements/dkms/post-install.d/99-dkms +++ b/elements/dkms/post-install.d/99-dkms @@ -9,19 +9,19 @@ modules=$(dkms status | tr ',:' ' ' | awk '{ print $1 "/" $2 }') kernels=$(ls /usr/src/linux-headers-*-*-* -d | sed -e 's|/usr/src/linux-headers-||' || echo "") # NOTE(bnemec): On Fedora, the versions can be found in /usr/src/kernels if [ -z "$kernels" ]; then - kernels=$(ls /usr/src/kernels/* -d | sed -e 's|/usr/src/kernels/||' || echo "") + kernels=$(ls /usr/src/kernels/* -d | sed -e 's|/usr/src/kernels/||' || echo "") fi if [ -z "$kernels" ]; then - echo "Warning: No kernel versions found for DKMS" + echo "Warning: No kernel versions found for DKMS" fi __ARCH=$ARCH unset ARCH for module in $modules ; do - for kernel in $kernels ; do - dkms build $module -k $kernel - dkms install $module -k $kernel - done + for kernel in $kernels ; do + dkms build $module -k $kernel + dkms install $module -k $kernel + done done ARCH=$__ARCH diff --git a/elements/dpkg/bin/install-packages b/elements/dpkg/bin/install-packages index 285bf267a..4ab7ad40e 100755 --- a/elements/dpkg/bin/install-packages +++ b/elements/dpkg/bin/install-packages @@ -20,18 +20,18 @@ set -o pipefail # install-packages package [package ...] install_deb_packages () { - DEBIAN_FRONTEND=noninteractive \ - http_proxy=${http_proxy:-} https_proxy=${https_proxy:-} \ - no_proxy=${no_proxy:-} \ - apt-get --option "Dpkg::Options::=--force-confold" --assume-yes "$@" + DEBIAN_FRONTEND=noninteractive \ + http_proxy=${http_proxy:-} https_proxy=${https_proxy:-} \ + no_proxy=${no_proxy:-} \ + apt-get --option "Dpkg::Options::=--force-confold" --assume-yes "$@" } if [ "$1" = "-u" ] ; then - install_deb_packages dist-upgrade - exit 0 + install_deb_packages dist-upgrade + exit 0 elif [ "$1" = "-e" ]; then - install_deb_packages remove $@ - shift + install_deb_packages remove $@ + shift else - install_deb_packages install $@ + install_deb_packages install $@ fi diff --git a/elements/dracut-network/install.d/11-patch-dracut b/elements/dracut-network/install.d/11-patch-dracut index f764ed842..1fc9deef9 100755 --- a/elements/dracut-network/install.d/11-patch-dracut +++ b/elements/dracut-network/install.d/11-patch-dracut @@ -13,7 +13,7 @@ IFCFG_FILE="/usr/lib/dracut/modules.d/45ifcfg/write-ifcfg.sh" NETGEN_FILE="/usr/lib/dracut/modules.d/40network/net-genrules.sh" if patch --dry-run $NETGEN_FILE < $(dirname $0)/../dracut-029-netgen.patch > /dev/null; then - patch $NETGEN_FILE < $(dirname $0)/../dracut-029-netgen.patch || true + patch $NETGEN_FILE < $(dirname $0)/../dracut-029-netgen.patch || true else - patch $IFCFG_FILE < $(dirname $0)/../dracut-write-ifcfg.patch || true + patch $IFCFG_FILE < $(dirname $0)/../dracut-write-ifcfg.patch || true fi diff --git a/elements/fedora/root.d/10-fedora-cloud-image b/elements/fedora/root.d/10-fedora-cloud-image index cc203087e..22f675106 100755 --- a/elements/fedora/root.d/10-fedora-cloud-image +++ b/elements/fedora/root.d/10-fedora-cloud-image @@ -7,7 +7,7 @@ set -o pipefail [ -n "$TARGET_ROOT" ] if [ 'amd64' = "$ARCH" ] ; then - ARCH="x86_64" + ARCH="x86_64" fi DIB_LOCAL_IMAGE=${DIB_LOCAL_IMAGE:-""} diff --git a/elements/local-config/extra-data.d/62-ssh-key b/elements/local-config/extra-data.d/62-ssh-key index f2d0d2185..87a2f135d 100755 --- a/elements/local-config/extra-data.d/62-ssh-key +++ b/elements/local-config/extra-data.d/62-ssh-key @@ -9,5 +9,5 @@ source $_LIB/die [ -n "$TMP_HOOKS_PATH" ] || die "Temp hook path not set" if [ -e ~/.ssh/authorized_keys ]; then - cat ~/.ssh/authorized_keys > $TMP_HOOKS_PATH/ssh-authorized-keys + cat ~/.ssh/authorized_keys > $TMP_HOOKS_PATH/ssh-authorized-keys fi diff --git a/elements/local-config/install.d/62-ssh-key b/elements/local-config/install.d/62-ssh-key index cbdb92c67..6d5714e7e 100755 --- a/elements/local-config/install.d/62-ssh-key +++ b/elements/local-config/install.d/62-ssh-key @@ -6,8 +6,8 @@ set -eu set -o pipefail if [ -e "/tmp/in_target.d/ssh-authorized-keys" ]; then - mkdir -p /root/.ssh - cat /tmp/in_target.d/ssh-authorized-keys >> /root/.ssh/authorized_keys - chmod 0700 /root/.ssh - chmod 0600 /root/.ssh/authorized_keys + mkdir -p /root/.ssh + cat /tmp/in_target.d/ssh-authorized-keys >> /root/.ssh/authorized_keys + chmod 0700 /root/.ssh + chmod 0600 /root/.ssh/authorized_keys fi diff --git a/elements/local-config/pre-install.d/02-proxy-settings b/elements/local-config/pre-install.d/02-proxy-settings index cd05ce8f9..6e7ae8341 100755 --- a/elements/local-config/pre-install.d/02-proxy-settings +++ b/elements/local-config/pre-install.d/02-proxy-settings @@ -13,60 +13,60 @@ http_proxy=${http_proxy:-""} https_proxy=${https_proxy:-""} if [ -d /etc/apt ] ; then - have_apt=1 + have_apt=1 fi if [ -e /etc/yum.conf ] ; then - have_yum=1 + have_yum=1 fi if [ -d /etc/zypp ] ; then - have_zypper=1 + have_zypper=1 fi if [ -n "$http_proxy" ]; then - if [ -d ~stack ]; then - echo export http_proxy=$http_proxy >> ~stack/.profile - fi - if [ -n "$have_apt" ] ; then - echo "Acquire::http::Proxy \"$http_proxy\";" > /etc/apt/apt.conf.d/02-use-http-proxy - fi - if [ -n "$have_yum" ] ; then - sed -i -e "s,\[main\],[main]\nproxy=$http_proxy," /etc/yum.conf - fi - if [ -n "$have_zypper" ] ; then - sed -i -e "s,^HTTP_PROXY=.*$,HTTP_PROXY=\"$http_proxy\"," /etc/sysconfig/proxy - fi + if [ -d ~stack ]; then + echo export http_proxy=$http_proxy >> ~stack/.profile + fi + if [ -n "$have_apt" ] ; then + echo "Acquire::http::Proxy \"$http_proxy\";" > /etc/apt/apt.conf.d/02-use-http-proxy + fi + if [ -n "$have_yum" ] ; then + sed -i -e "s,\[main\],[main]\nproxy=$http_proxy," /etc/yum.conf + fi + if [ -n "$have_zypper" ] ; then + sed -i -e "s,^HTTP_PROXY=.*$,HTTP_PROXY=\"$http_proxy\"," /etc/sysconfig/proxy + fi fi if [ -n "$https_proxy" ]; then - if [ -d ~stack ]; then - echo export https_proxy=$https_proxy >> ~stack/.profile - fi - if [ -n "$have_apt" ] ; then - echo "Acquire::https::Proxy \"$https_proxy\";" > /etc/apt/apt.conf.d/02-use-https-proxy - fi - if [ -n "$have_zypper" ] ; then - sed -i -e "s,^HTTPS_PROXY=.*$,HTTPS_PROXY=\"$https_proxy\"," /etc/sysconfig/proxy - fi + if [ -d ~stack ]; then + echo export https_proxy=$https_proxy >> ~stack/.profile + fi + if [ -n "$have_apt" ] ; then + echo "Acquire::https::Proxy \"$https_proxy\";" > /etc/apt/apt.conf.d/02-use-https-proxy + fi + if [ -n "$have_zypper" ] ; then + sed -i -e "s,^HTTPS_PROXY=.*$,HTTPS_PROXY=\"$https_proxy\"," /etc/sysconfig/proxy + fi fi no_proxy=${no_proxy:+"$no_proxy,192.0.2.1"} no_proxy=${no_proxy:-"192.0.2.1"} if [ -n "$no_proxy" ]; then - if [ -d ~stack ]; then - echo export no_proxy=$no_proxy >> ~stack/.profile - fi - if [ -n "$have_apt" ] ; then - for host in $(sed 's/,/ /g' <<<$no_proxy); do - echo "Acquire::http::Proxy::$host \"DIRECT\";" >> /etc/apt/apt.conf.d/02-no-proxy - done - fi - if [ -n "$have_zypper" ] ; then - sed -i -e "s,^\(NO_PROXY=.*\)\"$,\1\, $no_proxy\"," /etc/sysconfig/proxy - fi + if [ -d ~stack ]; then + echo export no_proxy=$no_proxy >> ~stack/.profile + fi + if [ -n "$have_apt" ] ; then + for host in $(sed 's/,/ /g' <<<$no_proxy); do + echo "Acquire::http::Proxy::$host \"DIRECT\";" >> /etc/apt/apt.conf.d/02-no-proxy + done + fi + if [ -n "$have_zypper" ] ; then + sed -i -e "s,^\(NO_PROXY=.*\)\"$,\1\, $no_proxy\"," /etc/sysconfig/proxy + fi fi if [ -n "$http_proxy" -o -n "$https_proxy" -o -n "$no_proxy" ]; then - if [ -n "$have_zypper" ] ; then - sed -i -e "s,^PROXY_ENABLED=.*$,PROXY_ENABLED=\"yes\"," /etc/sysconfig/proxy - fi + if [ -n "$have_zypper" ] ; then + sed -i -e "s,^PROXY_ENABLED=.*$,PROXY_ENABLED=\"yes\"," /etc/sysconfig/proxy + fi fi diff --git a/elements/opensuse/bin/install-packages b/elements/opensuse/bin/install-packages index 7585d308e..f59d502f8 100755 --- a/elements/opensuse/bin/install-packages +++ b/elements/opensuse/bin/install-packages @@ -18,16 +18,16 @@ set -eu set -o pipefail function run_zypper() { - # TODO: Uncertain if this can ever block wanting input from user - zypper --non-interactive --gpg-auto-import-keys "$@" + # TODO: Uncertain if this can ever block wanting input from user + zypper --non-interactive --gpg-auto-import-keys "$@" } if [ "$1" = "-u" ] ; then - run_zypper dist-upgrade - exit 0 + run_zypper dist-upgrade + exit 0 elif [ "$1" = "-d" ] ; then - EXTRA_ARGS="--download-only" - shift + EXTRA_ARGS="--download-only" + shift fi # Packages that aren't available in the distro but requested for installation @@ -36,12 +36,12 @@ BLACKLIST=(dkms) WHITELIST=() for i in "$@" do - if [[ ! ${BLACKLIST[*]} =~ $i ]]; then - WHITELIST+="$i " - else - echo "The package $i is not available and will not be installed" - fi + if [[ ! ${BLACKLIST[*]} =~ $i ]]; then + WHITELIST+="$i " + else + echo "The package $i is not available and will not be installed" + fi done if [ -n "$WHITELIST" ]; then - run_zypper install $EXTRA_ARGS $(map-packages $WHITELIST) + run_zypper install $EXTRA_ARGS $(map-packages $WHITELIST) fi diff --git a/elements/opensuse/extra-data.d/01-inject-defaults b/elements/opensuse/extra-data.d/01-inject-defaults index 102040003..12247d867 100755 --- a/elements/opensuse/extra-data.d/01-inject-defaults +++ b/elements/opensuse/extra-data.d/01-inject-defaults @@ -7,6 +7,6 @@ export OPENSUSE_EXTRAS_PATH="$TMP_MOUNT_PATH/tmp/opensuse-extras" mkdir -p $OPENSUSE_EXTRAS_PATH for file in common-defaults img-defaults ; do - cp $_LIB/$file $OPENSUSE_EXTRAS_PATH + cp $_LIB/$file $OPENSUSE_EXTRAS_PATH done diff --git a/elements/opensuse/root.d/10-opensuse-cloud-image b/elements/opensuse/root.d/10-opensuse-cloud-image index 074ff544f..8d467189d 100755 --- a/elements/opensuse/root.d/10-opensuse-cloud-image +++ b/elements/opensuse/root.d/10-opensuse-cloud-image @@ -26,12 +26,12 @@ if [ -z "$DIB_OFFLINE" ] ; then # https://bugzilla.novell.com/show_bug.cgi?id=853882 is deployed echo "Looking up current built of Base Image ($BASE_IMAGE_NAME):" BASE_IMAGE_FILE=${BASE_IMAGE_FILE:-$(curl $DIB_CLOUD_IMAGES | \ - sed -n "s/^.*\${DEPS_OUTPUT} + DEPS_OUTPUT="/etc/dib_binary_deps" + echo "Creating binary_deps record at: ${DEPS_OUTPUT}" + echo "$BINARY_DEPS" >${DEPS_OUTPUT} fi diff --git a/elements/redhat-common/bin/extract-image b/elements/redhat-common/bin/extract-image index db812610c..4092175d0 100755 --- a/elements/redhat-common/bin/extract-image +++ b/elements/redhat-common/bin/extract-image @@ -84,5 +84,5 @@ fi echo "Extracting base root image from $CACHED_TAR" sudo tar -C $TARGET_ROOT --numeric-owner -xzf $CACHED_TAR if [ -e "$TARGET_ROOT/lost+found" ]; then - sudo rmdir $TARGET_ROOT/lost+found + sudo rmdir $TARGET_ROOT/lost+found fi diff --git a/elements/redhat-common/finalise.d/99-setup-first-boot b/elements/redhat-common/finalise.d/99-setup-first-boot index 516d1b5bd..0211d8950 100755 --- a/elements/redhat-common/finalise.d/99-setup-first-boot +++ b/elements/redhat-common/finalise.d/99-setup-first-boot @@ -20,17 +20,17 @@ set -o xtrace dib-first-boot EOF - if [ $FILE_EXISTED ] - then - echo "mv $rc_local.REAL $rc_local" >> $rc_local - else - echo "rm \$0" >> $rc_local - fi - - echo "exit 0" >> $rc_local - - chmod 755 $rc_local - - # Enable the service - systemctl enable rc-local.service +if [ $FILE_EXISTED ] +then + echo "mv $rc_local.REAL $rc_local" >> $rc_local +else + echo "rm \$0" >> $rc_local +fi + +echo "exit 0" >> $rc_local + +chmod 755 $rc_local + +# Enable the service +systemctl enable rc-local.service fi diff --git a/elements/rhel/finalise.d/60-rhsm-unregister b/elements/rhel/finalise.d/60-rhsm-unregister index 3ec367f4a..134e32124 100755 --- a/elements/rhel/finalise.d/60-rhsm-unregister +++ b/elements/rhel/finalise.d/60-rhsm-unregister @@ -4,9 +4,9 @@ set -eu set -o pipefail if [ -n "$DIB_RHSM_USER" ] && [ -n "$DIB_RHSM_PASSWORD" ]; then - if [[ "$DIB_REG_TYPE" == "rhn" ]]; then - rm -rf /etc/sysconfig/rhn/systemid - else - subscription-manager unregister - fi + if [[ "$DIB_REG_TYPE" == "rhn" ]]; then + rm -rf /etc/sysconfig/rhn/systemid + else + subscription-manager unregister + fi fi diff --git a/elements/rhel/pre-install.d/00-rhsm b/elements/rhel/pre-install.d/00-rhsm index 17efd2394..75c18cec3 100755 --- a/elements/rhel/pre-install.d/00-rhsm +++ b/elements/rhel/pre-install.d/00-rhsm @@ -4,52 +4,52 @@ set -eu set -o pipefail if [ -n "$DIB_RHSM_USER" ] && [ -n "$DIB_RHSM_PASSWORD" ] - then +then opts="--force" if [[ -n "$DIB_SAT_KEY" ]]; then - opts="$opts --activationkey ${DIB_SAT_KEY}" + opts="$opts --activationkey ${DIB_SAT_KEY}" else - opts="$opts --username ${DIB_RHSM_USER} --password ${DIB_RHSM_PASSWORD}" + opts="$opts --username ${DIB_RHSM_USER} --password ${DIB_RHSM_PASSWORD}" fi if [[ -n "$DIB_SAT_URL" ]]; then - if [[ "$DIB_REG_TYPE" == "rhn" ]]; then - opts="$opts --serverUrl ${DIB_SAT_URL}" - else - opts="$opts --serverurl ${DIB_SAT_URL} --sslCACert /usr/share/rhn/RHN-ORG-TRUSTED-SSL-CERT" - fi + if [[ "$DIB_REG_TYPE" == "rhn" ]]; then + opts="$opts --serverUrl ${DIB_SAT_URL}" + else + opts="$opts --serverurl ${DIB_SAT_URL} --sslCACert /usr/share/rhn/RHN-ORG-TRUSTED-SSL-CERT" + fi fi if [[ -n "$DIB_SAT_CERT_RPM_URL" ]]; then - yum install -y ${DIB_SAT_CERT_RPM_URL} + yum install -y ${DIB_SAT_CERT_RPM_URL} fi if [[ "$DIB_REG_TYPE" == "rhn" ]]; then - rhnreg_ks $opts --norhnsd - sleep 1 - # optional channel required for diskimage-builder dependency - channels="-a -c rhel-x86_64-server-optional-6" - if [[ -n "$DIB_RHN_CHANNELS" ]]; then - for chan in $DIB_RHN_CHANNELS; do - channels="$channels -a -c $chan" - done - fi - rhn-channel --user=$DIB_RHSM_USER --password=$DIB_RHSM_PASSWORD $channels - rhn-channel -l + rhnreg_ks $opts --norhnsd + sleep 1 + # optional channel required for diskimage-builder dependency + channels="-a -c rhel-x86_64-server-optional-6" + if [[ -n "$DIB_RHN_CHANNELS" ]]; then + for chan in $DIB_RHN_CHANNELS; do + channels="$channels -a -c $chan" + done + fi + rhn-channel --user=$DIB_RHSM_USER --password=$DIB_RHSM_PASSWORD $channels + rhn-channel -l else - subscription-manager register $opts - # wait a second to ensure consumer certificate is finished writing to disk - sleep 1 - if [ -z $DIB_RHSM_POOL ]; then - subscription-manager attach --auto - else - subscription-manager attach --pool $DIB_RHSM_POOL - fi - # optional repo required for diskimage-builder dependency - repos="--enable rhel-6-server-optional-rpms" - if [[ -n "$DIB_RHSM_REPOS" ]]; then - for repo in $DIB_RHSM_REPOS; do - repos="$repos --enable $repo" - done - fi - subscription-manager repos $repos - subscription-manager repos --list + subscription-manager register $opts + # wait a second to ensure consumer certificate is finished writing to disk + sleep 1 + if [ -z $DIB_RHSM_POOL ]; then + subscription-manager attach --auto + else + subscription-manager attach --pool $DIB_RHSM_POOL + fi + # optional repo required for diskimage-builder dependency + repos="--enable rhel-6-server-optional-rpms" + if [[ -n "$DIB_RHSM_REPOS" ]]; then + for repo in $DIB_RHSM_REPOS; do + repos="$repos --enable $repo" + done + fi + subscription-manager repos $repos + subscription-manager repos --list fi fi diff --git a/elements/rhel/root.d/10-rhel-cloud-image b/elements/rhel/root.d/10-rhel-cloud-image index 9f4c24fb6..aae92d5bb 100755 --- a/elements/rhel/root.d/10-rhel-cloud-image +++ b/elements/rhel/root.d/10-rhel-cloud-image @@ -7,7 +7,7 @@ set -o pipefail [ -n "$TARGET_ROOT" ] if [ 'amd64' = "$ARCH" ] ; then - ARCH="x86_64" + ARCH="x86_64" fi DIB_RELEASE=${DIB_RELEASE:-"6.5-20140121.0"} @@ -38,8 +38,8 @@ else export LOOPDEV=$LOOPDEV echo "Loop device is set to: $LOOPDEV" if ! timeout 5 sh -c "while ! [ -e /dev/mapper/$LOOPDEV ]; do sleep 1; done"; then - echo "Error: Could not find /dev/mapper/$LOOPDEV" - exit 1 + echo "Error: Could not find /dev/mapper/$LOOPDEV" + exit 1 fi EACTION="sudo kpartx -d $WORKING/$RAW_FILE;$EACTION" trap "$EACTION" EXIT @@ -56,5 +56,5 @@ fi # image tarball and host OS e.g. when building RHEL image on an openSUSE host) sudo tar -C $TARGET_ROOT --numeric-owner -xzf $DIB_IMAGE_CACHE/$BASE_IMAGE_TAR if [ -e "$TARGET_ROOT/lost+found" ]; then - sudo rmdir $TARGET_ROOT/lost+found + sudo rmdir $TARGET_ROOT/lost+found fi diff --git a/elements/rhel7/root.d/10-rhel-cloud-image b/elements/rhel7/root.d/10-rhel-cloud-image index 33127a289..a11bf854a 100755 --- a/elements/rhel7/root.d/10-rhel-cloud-image +++ b/elements/rhel7/root.d/10-rhel-cloud-image @@ -7,7 +7,7 @@ set -o pipefail [ -n "$TARGET_ROOT" ] if [ 'amd64' = "$ARCH" ] ; then - ARCH="x86_64" + ARCH="x86_64" fi DIB_LOCAL_IMAGE=${DIB_LOCAL_IMAGE:-""} diff --git a/elements/rpm-distro/pre-install.d/01-override-yum-arch b/elements/rpm-distro/pre-install.d/01-override-yum-arch index 74ab9bb98..ca528547d 100755 --- a/elements/rpm-distro/pre-install.d/01-override-yum-arch +++ b/elements/rpm-distro/pre-install.d/01-override-yum-arch @@ -4,16 +4,16 @@ set -eu set -o pipefail if [ "i386" = "$ARCH" ]; then - basearch=i386 - arch=i686 + basearch=i386 + arch=i686 elif [ "amd64" = "$ARCH" ]; then - basearch=x86_64 - arch=x86_64 + basearch=x86_64 + arch=x86_64 else - echo "********************" - echo "Unknown arch '$ARCH'" - echo "********************" - exit 1 + echo "********************" + echo "Unknown arch '$ARCH'" + echo "********************" + exit 1 fi echo $basearch > /etc/yum/vars/basearch diff --git a/elements/ubuntu/finalise.d/99-setup-first-boot b/elements/ubuntu/finalise.d/99-setup-first-boot index e147244a8..40a7f8c43 100755 --- a/elements/ubuntu/finalise.d/99-setup-first-boot +++ b/elements/ubuntu/finalise.d/99-setup-first-boot @@ -18,5 +18,5 @@ mv $rc_local.REAL $rc_local exit 0 EOF - chmod 755 $rc_local +chmod 755 $rc_local fi diff --git a/elements/ubuntu/pre-install.d/00-remove-grub b/elements/ubuntu/pre-install.d/00-remove-grub index 76f1d0c26..446a9581b 100755 --- a/elements/ubuntu/pre-install.d/00-remove-grub +++ b/elements/ubuntu/pre-install.d/00-remove-grub @@ -7,9 +7,9 @@ set -eu set -o pipefail if dpkg-query -W grub-pc; then - apt-get -y remove grub-pc + apt-get -y remove grub-pc fi if dpkg-query -W grub2-common; then - apt-get -y remove grub2-common + apt-get -y remove grub2-common fi diff --git a/elements/ubuntu/root.d/10-cache-ubuntu-tarball b/elements/ubuntu/root.d/10-cache-ubuntu-tarball index 757fea153..99a52da7d 100755 --- a/elements/ubuntu/root.d/10-cache-ubuntu-tarball +++ b/elements/ubuntu/root.d/10-cache-ubuntu-tarball @@ -18,16 +18,16 @@ CACHED_FILE=$DIB_IMAGE_CACHE/$BASE_IMAGE_FILE if [ -n "$DIB_OFFLINE" -a -f "$CACHED_FILE" ] ; then echo "Not checking freshness of cached $CACHED_FILE." else - echo "Fetching Base Image" - $TMP_HOOKS_PATH/bin/cache-url $SHA256SUMS $DIB_IMAGE_CACHE/SHA256SUMS.ubuntu.$DIB_RELEASE.$ARCH - $TMP_HOOKS_PATH/bin/cache-url $DIB_CLOUD_IMAGES/$DIB_RELEASE/current/$BASE_IMAGE_FILE $CACHED_FILE - pushd $DIB_IMAGE_CACHE - grep "$BASE_IMAGE_FILE" SHA256SUMS.ubuntu.$DIB_RELEASE.$ARCH | sha256sum --check - - popd + echo "Fetching Base Image" + $TMP_HOOKS_PATH/bin/cache-url $SHA256SUMS $DIB_IMAGE_CACHE/SHA256SUMS.ubuntu.$DIB_RELEASE.$ARCH + $TMP_HOOKS_PATH/bin/cache-url $DIB_CLOUD_IMAGES/$DIB_RELEASE/current/$BASE_IMAGE_FILE $CACHED_FILE + pushd $DIB_IMAGE_CACHE + grep "$BASE_IMAGE_FILE" SHA256SUMS.ubuntu.$DIB_RELEASE.$ARCH | sha256sum --check - + popd fi # Extract the base image (use --numeric-owner to avoid UID/GID mismatch between # image tarball and host OS e.g. when building Ubuntu image on an openSUSE host) sudo tar -C $TARGET_ROOT --numeric-owner -xzf $DIB_IMAGE_CACHE/$BASE_IMAGE_FILE if [ -e "$TARGET_ROOT/lost+found" ]; then - sudo rmdir $TARGET_ROOT/lost+found + sudo rmdir $TARGET_ROOT/lost+found fi diff --git a/elements/vm/finalise.d/51-bootloader b/elements/vm/finalise.d/51-bootloader index 71021ae3e..1938200d3 100755 --- a/elements/vm/finalise.d/51-bootloader +++ b/elements/vm/finalise.d/51-bootloader @@ -52,9 +52,9 @@ function install_extlinux { DEFAULT linux LABEL linux - KERNEL $kernel - APPEND ro root=LABEL=cloudimg-rootfs console=tty0 console=ttyS0,115200 - INITRD $initrd + KERNEL $kernel + APPEND ro root=LABEL=cloudimg-rootfs console=tty0 console=ttyS0,115200 + INITRD $initrd _EOF_ } @@ -89,35 +89,35 @@ function install_grub2 { # - and for UEFI too. # GRUB_OPTS="$GRUB_OPTS --target=i386-pc" if [[ ! $GRUB_OPTS == *--target* ]] && [[ $($GRUBNAME --version) =~ ' 2.' ]]; then - # /sys/ comes from the host machine. If the host machine is using EFI - # but the image being built doesn't have EFI boot-images installed we - # should set the --target to use a BIOS-based boot-image. - # - # * --target tells grub what's the target platform - # * the boot images are placed in /usr/lib/grub/- - # * i386-pc is used for BIOS-based machines - # http://www.gnu.org/software/grub/manual/grub.html#Installation - # - if [ -d /sys/firmware/efi ]; then - if [ ! -d /usr/lib/grub/*-efi ]; then - case $ARCH in - "x86_64"|"amd64") - GRUB_OPTS="$GRUB_OPTS --target=i386-pc" - ;; - "i386") - target=i386-pc - if [ -e /proc/device-tree ]; then - for x in /proc/device-tree/*; do - if [ -e "$x" ]; then - target="i386-ieee1275" - fi - done - fi - GRUB_OPTS="$GRUB_OPTS --target=$target" - ;; - esac + # /sys/ comes from the host machine. If the host machine is using EFI + # but the image being built doesn't have EFI boot-images installed we + # should set the --target to use a BIOS-based boot-image. + # + # * --target tells grub what's the target platform + # * the boot images are placed in /usr/lib/grub/- + # * i386-pc is used for BIOS-based machines + # http://www.gnu.org/software/grub/manual/grub.html#Installation + # + if [ -d /sys/firmware/efi ]; then + if [ ! -d /usr/lib/grub/*-efi ]; then + case $ARCH in + "x86_64"|"amd64") + GRUB_OPTS="$GRUB_OPTS --target=i386-pc" + ;; + "i386") + target=i386-pc + if [ -e /proc/device-tree ]; then + for x in /proc/device-tree/*; do + if [ -e "$x" ]; then + target="i386-ieee1275" + fi + done + fi + GRUB_OPTS="$GRUB_OPTS --target=$target" + ;; + esac + fi fi - fi fi $GRUBNAME --modules="biosdisk part_msdos" $GRUB_OPTS $BOOT_DEV @@ -125,9 +125,9 @@ function install_grub2 { # This might be better factored out into a per-distro 'install-bootblock' # helper. if [ -d /boot/grub2 ]; then - GRUB_CFG=/boot/grub2/grub.cfg + GRUB_CFG=/boot/grub2/grub.cfg elif [ -d /boot/grub ]; then - GRUB_CFG=/boot/grub/grub.cfg + GRUB_CFG=/boot/grub/grub.cfg fi DIST=`lsb_release -is` @@ -136,15 +136,15 @@ function install_grub2 { echo 'GRUB_GFXPAYLOAD_LINUX=text' >>/etc/default/grub GRUB_MKCONFIG="grub2-mkconfig -o $GRUB_CFG" case $DIST in - 'Ubuntu'|'Debian') - sed -i -e 's/\(^GRUB_CMDLINE_LINUX.*\)"$/\1 nofb nomodeset vga=normal"/' /etc/default/grub - GRUB_MKCONFIG=update-grub + 'Ubuntu'|'Debian') + sed -i -e 's/\(^GRUB_CMDLINE_LINUX.*\)"$/\1 nofb nomodeset vga=normal"/' /etc/default/grub + GRUB_MKCONFIG=update-grub ;; - 'Fedora') - echo 'GRUB_CMDLINE_LINUX="nofb nomodeset vga=normal"' >>/etc/default/grub + 'Fedora') + echo 'GRUB_CMDLINE_LINUX="nofb nomodeset vga=normal"' >>/etc/default/grub ;; - 'openSUSE project') - sed -i -e 's/\(^GRUB_CMDLINE_LINUX.*\)"$/\1 nofb nomodeset vga=normal"/' /etc/default/grub + 'openSUSE project') + sed -i -e 's/\(^GRUB_CMDLINE_LINUX.*\)"$/\1 nofb nomodeset vga=normal"/' /etc/default/grub ;; esac $GRUB_MKCONFIG @@ -154,8 +154,8 @@ function install_grub2 { # grub-mkconfig generates a config with the device in it, # This shouldn't be needed, but old code has bugs if [ $RELEASE = 'precise' ] || [ $RELEASE = 'wheezy' ]; then - sed -i "s%search --no.*%%" $GRUB_CFG - sed -i "s%set root=.*%set root=(hd0,1)%" $GRUB_CFG + sed -i "s%search --no.*%%" $GRUB_CFG + sed -i "s%set root=.*%set root=(hd0,1)%" $GRUB_CFG fi # force use of a LABEL: # NOTE: Updating the grub config by hand once deployed should work, its just @@ -164,15 +164,15 @@ function install_grub2 { sed -i "s%search --no-floppy --fs-uuid --set=root .*$%search --no-floppy --set=root --label cloudimg-rootfs%" $GRUB_CFG sed -i "s%root=UUID=[A-Za-z0-9\-]*%root=LABEL=cloudimg-rootfs%" $GRUB_CFG if [ "$DIST" = 'Fedora' ] ; then - # enable serial console - sed -i "s%LABEL=cloudimg-rootfs%LABEL=cloudimg-rootfs console=tty0 console=ttyS0,115200%" $GRUB_CFG - if [ $(lsb_release -rs) = '19' ]; then - sed -i "s%UUID=[A-Za-z0-9\-]*%LABEL=cloudimg-rootfs%" /etc/fstab - fi - # Fix efi specific instructions in grub config file - if [ -d /sys/firmware/efi ]; then - sed -i 's%\(initrd\|linux\)efi /boot%\1 /boot%g' $GRUB_CFG - fi + # enable serial console + sed -i "s%LABEL=cloudimg-rootfs%LABEL=cloudimg-rootfs console=tty0 console=ttyS0,115200%" $GRUB_CFG + if [ $(lsb_release -rs) = '19' ]; then + sed -i "s%UUID=[A-Za-z0-9\-]*%LABEL=cloudimg-rootfs%" /etc/fstab + fi + # Fix efi specific instructions in grub config file + if [ -d /sys/firmware/efi ]; then + sed -i 's%\(initrd\|linux\)efi /boot%\1 /boot%g' $GRUB_CFG + fi fi } diff --git a/elements/yum/bin/install-packages b/elements/yum/bin/install-packages index 98c0ced0f..218dd5342 100755 --- a/elements/yum/bin/install-packages +++ b/elements/yum/bin/install-packages @@ -21,14 +21,14 @@ EXTRA_ARGS= ACTION=install if [ "$1" = "-u" ] ; then - yum -y update - exit 0 + yum -y update + exit 0 elif [ "$1" = "-d" ] ; then - EXTRA_ARGS="--downloadonly" - shift + EXTRA_ARGS="--downloadonly" + shift elif [ "$1" = "-e" ]; then - ACTION=erase - shift + ACTION=erase + shift fi # Packages that aren't available in the distro but requested for installation @@ -37,20 +37,20 @@ BLACKLIST=$(cat /tmp/yum-blacklist 2>/dev/null || echo "") WHITELIST=() for i in "$@" do - if [[ ! ${BLACKLIST[*]} =~ $i ]]; then - WHITELIST+="$i " - else - echo "The package $i is not available and will not be installed" - fi + if [[ ! ${BLACKLIST[*]} =~ $i ]]; then + WHITELIST+="$i " + else + echo "The package $i is not available and will not be installed" + fi done if [ -n "$WHITELIST" ]; then - if [ -f /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release ]; then - rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release - fi - yum -y $ACTION $EXTRA_ARGS $(map-packages $WHITELIST) - for pkg in "$@"; do - if [ "$pkg" = "python-pip" ] ; then - alternatives --install /usr/bin/pip pip /usr/bin/pip-python 10 + if [ -f /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release ]; then + rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release fi - done + yum -y $ACTION $EXTRA_ARGS $(map-packages $WHITELIST) + for pkg in "$@"; do + if [ "$pkg" = "python-pip" ] ; then + alternatives --install /usr/bin/pip pip /usr/bin/pip-python 10 + fi + done fi