Skip to content

Commit

Permalink
Merge pull request #513 from chef/revert-494-maint/shellcheck
Browse files Browse the repository at this point in the history
Revert "fix or suppress all shellcheck warnings"
Seth Thomas committed Dec 21, 2015

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents 046deb7 + e69df42 commit 3adda37
Showing 28 changed files with 110 additions and 118 deletions.
6 changes: 3 additions & 3 deletions scripts/centos/cleanup.sh
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ elif [ -s /etc/enterprise-release ]; then
distro='oracle'
elif [ -s /etc/redhat-release ]; then
# should ouput 'centos' OR 'red hat'
distro=$(sed 's/^\(CentOS\|Red Hat\).*/\1/i' /etc/redhat-release | tr '[:upper:]' '[:lower:]')
distro=`cat /etc/redhat-release | sed 's/^\(CentOS\|Red Hat\).*/\1/i' | tr '[:upper:]' '[:lower:]'`
fi


@@ -23,8 +23,8 @@ mkdir -p /etc/udev/rules.d/70-persistent-net.rules;
rm -f /lib/udev/rules.d/75-persistent-net-generator.rules;
rm -rf /dev/.udev/;

for ndev in /etc/sysconfig/network-scripts/ifcfg-*; do
if [ "$(basename "$ndev")" != "ifcfg-lo" ]; then
for ndev in `ls -1 /etc/sysconfig/network-scripts/ifcfg-*`; do
if [ "`basename $ndev`" != "ifcfg-lo" ]; then
sed -i '/^HWADDR/d' "$ndev";
sed -i '/^UUID/d' "$ndev";
fi
2 changes: 1 addition & 1 deletion scripts/centos/networking.sh
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
case "$PACKER_BUILDER_TYPE" in

virtualbox-iso|virtualbox-ovf)
major_version="$(sed 's/^.\+ release \([.0-9]\+\).*/\1/' /etc/redhat-release | awk -F. '{print $1}')";
major_version="`sed 's/^.\+ release \([.0-9]\+\).*/\1/' /etc/redhat-release | awk -F. '{print $1}'`";

if [ "$major_version" -ge 6 ]; then
# Fix slow DNS:
4 changes: 2 additions & 2 deletions scripts/common/minimize.sh
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ case "$PACKER_BUILDER_TYPE" in
esac

set +e
swapuuid="$(/sbin/blkid -o value -l -s UUID -t TYPE=swap)";
swapuuid="`/sbin/blkid -o value -l -s UUID -t TYPE=swap`";
case "$?" in
2|0) ;;
*) exit 1 ;;
@@ -15,7 +15,7 @@ set -e
if [ "x${swapuuid}" != "x" ]; then
# Whiteout the swap partition to reduce box size
# Swap is disabled till reboot
swappart="$(readlink -f /dev/disk/by-uuid/"$swapuuid")";
swappart="`readlink -f /dev/disk/by-uuid/$swapuuid`";
/sbin/swapoff "$swappart";
dd if=/dev/zero of="$swappart" bs=1M || echo "dd exit code $? is suppressed";
/sbin/mkswap -U "$swapuuid" "$swappart";
2 changes: 0 additions & 2 deletions scripts/common/shutdown.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
#!/bin/sh -eux

shutdown -P now
1 change: 0 additions & 1 deletion scripts/common/sshd.sh
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@
SSHD_CONFIG="/etc/ssh/sshd_config"

# ensure that there is a trailing newline before attempting to concatenate
# shellcheck disable=SC1003
sed -i -e '$a\' "$SSHD_CONFIG"

USEDNS="UseDNS no"
12 changes: 6 additions & 6 deletions scripts/common/vagrant.sh
Original file line number Diff line number Diff line change
@@ -4,16 +4,16 @@
HOME_DIR="${HOME_DIR:-/home/vagrant}";

pubkey_url="https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub";
mkdir -p "$HOME_DIR"/.ssh;
mkdir -p $HOME_DIR/.ssh;
if command -v wget >/dev/null 2>&1; then
wget --no-check-certificate "$pubkey_url" -O "$HOME_DIR"/.ssh/authorized_keys;
wget --no-check-certificate "$pubkey_url" -O $HOME_DIR/.ssh/authorized_keys;
elif command -v curl >/dev/null 2>&1; then
curl --insecure --location "$pubkey_url" > "$HOME_DIR"/.ssh/authorized_keys;
curl --insecure --location "$pubkey_url" > $HOME_DIR/.ssh/authorized_keys;
elif command -v fetch >/dev/null 2>&1; then
fetch -am -o "$HOME_DIR"/.ssh/authorized_keys "$pubkey_url";
fetch -am -o $HOME_DIR/.ssh/authorized_keys "$pubkey_url";
else
echo "Cannot download vagrant public key";
exit 1;
fi
chown -R vagrant "$HOME_DIR"/.ssh;
chmod -R go-rwsx "$HOME_DIR"/.ssh;
chown -R vagrant $HOME_DIR/.ssh;
chmod -R go-rwsx $HOME_DIR/.ssh;
14 changes: 7 additions & 7 deletions scripts/common/vmtools.sh
Original file line number Diff line number Diff line change
@@ -7,31 +7,31 @@ case "$PACKER_BUILDER_TYPE" in

virtualbox-iso|virtualbox-ovf)
mkdir -p /tmp/vbox;
ver="$(cat /home/vagrant/.vbox_version)";
mount -o loop "$HOME_DIR/VBoxGuestAdditions_${ver}.iso" /tmp/vbox;
ver="`cat /home/vagrant/.vbox_version`";
mount -o loop $HOME_DIR/VBoxGuestAdditions_${ver}.iso /tmp/vbox;
sh /tmp/vbox/VBoxLinuxAdditions.run \
|| echo "VBoxLinuxAdditions.run exited $? and is suppressed." \
"For more read https://www.virtualbox.org/ticket/12479";
umount /tmp/vbox;
rm -rf /tmp/vbox;
rm -f "$HOME_DIR"/*.iso;
rm -f $HOME_DIR/*.iso;
;;

vmware-iso|vmware-vmx)
mkdir -p /tmp/vmfusion;
mkdir -p /tmp/vmfusion-archive;
mount -o loop "$HOME_DIR/linux.iso" /tmp/vmfusion;
mount -o loop $HOME_DIR/linux.iso /tmp/vmfusion;
tar xzf /tmp/vmfusion/VMwareTools-*.tar.gz -C /tmp/vmfusion-archive;
/tmp/vmfusion-archive/vmware-tools-distrib/vmware-install.pl --force-install;
umount /tmp/vmfusion;
rm -rf /tmp/vmfusion;
rm -rf /tmp/vmfusion-archive;
rm -f "$HOME_DIR"/*.iso;
rm -f $HOME_DIR/*.iso;
;;

parallels-iso|parallels-pvm)
mkdir -p /tmp/parallels;
mount -o loop "$HOME_DIR/prl-tools-lin.iso" /tmp/parallels;
mount -o loop $HOME_DIR/prl-tools-lin.iso /tmp/parallels;
/tmp/parallels/install --install-unattended-with-deps \
|| (code="$?"; \
echo "Parallels tools installation exited $code, attempting" \
@@ -40,7 +40,7 @@ parallels-iso|parallels-pvm)
exit $code);
umount /tmp/parallels;
rm -rf /tmp/parallels;
rm -f "$HOME_DIR"/*.iso;
rm -f $HOME_DIR/*.iso;
;;

qemu)
2 changes: 1 addition & 1 deletion scripts/debian/cleanup.sh
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ dpkg --list \
dpkg --list \
| awk '{ print $2 }' \
| grep 'linux-image-[234].*' \
| grep -v "$(uname -r)" \
| grep -v `uname -r` \
| xargs apt-get -y purge;

# Delete Linux source
6 changes: 3 additions & 3 deletions scripts/debian/update.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/bin/sh -eux

arch="$(uname -r | sed 's/^.*[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}\(-[0-9]\{1,2\}\)-//')"
arch="`uname -r | sed 's/^.*[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}\(-[0-9]\{1,2\}\)-//'`"

apt-get update;

apt-get -y "upgrade linux-image-$arch";
apt-get -y "install linux-headers-$(uname -r)";
apt-get -y upgrade linux-image-$arch;
apt-get -y install linux-headers-`uname -r`;

if [ -d /etc/init ]; then
# update package index on boot
2 changes: 1 addition & 1 deletion scripts/fedora/22-build-tools.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash -eux
# Installing build tools here because Fedora 22 will not do so during kickstart
dnf -y install "kernel-headers-$(uname -r)" "kernel-devel-$(uname -r)" gcc make perl
dnf -y install kernel-headers-$(uname -r) kernel-devel-$(uname -r) gcc make perl
2 changes: 0 additions & 2 deletions scripts/fedora/shutdown.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
#!/bin/sh -eux

/sbin/halt -h -p
6 changes: 3 additions & 3 deletions scripts/freebsd/update.sh
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
[ -z "$http_proxy" ] && unset http_proxy
[ -z "$https_proxy" ] && unset https_proxy

major_version="$(uname -r | awk -F. '{print $1}')";
major_version="`uname -r | awk -F. '{print $1}'`";

if [ "$major_version" -lt 10 ]; then
# Allow freebsd-update to run fetch without stdin attached to a terminal
@@ -19,8 +19,8 @@ fi

# Update FreeBSD
# NOTE: this will fail if there aren't any patches available for the release yet
env PAGER=/bin/cat "$freebsd_update" fetch;
env PAGER=/bin/cat "$freebsd_update" install;
env PAGER=/bin/cat $freebsd_update fetch;
env PAGER=/bin/cat $freebsd_update install;

# Always use pkgng - pkg_add is EOL as of 1 September 2014
env ASSUME_ALWAYS_YES=true pkg bootstrap;
8 changes: 4 additions & 4 deletions scripts/freebsd/vmtools.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh -eux

freebsd_major="$(uname -r | awk -F. '{print $1}')";
freebsd_major="`uname -r | awk -F. '{print $1}'`";

case "$PACKER_BUILDER_TYPE" in

@@ -35,21 +35,21 @@ virtualbox-iso|virtualbox-ovf)
vmware-iso|vmware-vmx)
# Install Perl and other software needed by vmware-install.pl
pkg install -y perl5;
pkg install -y "compat6x-$(uname -m)";
pkg install -y compat6x-`uname -m`;
# the install script is very picky about location of perl command
ln -s /usr/local/bin/perl /usr/bin/perl;

mkdir -p /tmp/vmfusion;
mkdir -p /tmp/vmfusion-archive;
mdconfig -a -t vnode -f "$HOME_DIR/freebsd.iso" -u 0;
mdconfig -a -t vnode -f $HOME_DIR/freebsd.iso -u 0;
mount -t cd9660 /dev/md0 /tmp/vmfusion;
tar xzf /tmp/vmfusion/vmware-freebsd-tools.tar.gz -C /tmp/vmfusion-archive;
/tmp/vmfusion-archive/vmware-tools-distrib/vmware-install.pl --force-install;
echo 'ifconfig_vxn0="dhcp"' >>/etc/rc.conf;
umount /tmp/vmfusion;
rm -rf /tmp/vmfusion;
rm -rf /tmp/vmfusion-archive;
rm -f "$HOME_DIR/*.iso";
rm -f $HOME_DIR/*.iso;

rm -f /usr/bin/perl;
;;
2 changes: 1 addition & 1 deletion scripts/macosx/hostname.sh
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
# Major thanks to @timsutton's osx-vm-templates:
# https://github.com/timsutton/osx-vm-templates

osx_minor_version="$(sw_vers -productVersion | awk -F '.' '{print $2}')";
osx_minor_version="`sw_vers -productVersion | awk -F '.' '{print $2}'`";

# Set computer/hostname
computer_name="macosx-10-${osx_minor_version}";
10 changes: 5 additions & 5 deletions scripts/macosx/vagrant.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/bin/bash -eux

pubkey_url="https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub";
mkdir -p "$HOME_DIR/.ssh";
mkdir -p $HOME_DIR/.ssh;
if command -v wget >/dev/null 2>&1; then
wget --no-check-certificate "$pubkey_url" -O "$HOME_DIR/.ssh/authorized_keys";
wget --no-check-certificate "$pubkey_url" -O $HOME_DIR/.ssh/authorized_keys;
elif command -v curl >/dev/null 2>&1; then
curl --insecure --location "$pubkey_url" > "$HOME_DIR/.ssh/authorized_keys";
curl --insecure --location "$pubkey_url" > $HOME_DIR/.ssh/authorized_keys;
else
echo "Cannot download vagrant public key";
exit 1;
fi
chown -R vagrant "$HOME_DIR/.ssh";
chmod -R go-rwsx "$HOME_DIR/.ssh";
chown -R vagrant $HOME_DIR/.ssh;
chmod -R go-rwsx $HOME_DIR/.ssh;
4 changes: 2 additions & 2 deletions scripts/macosx/vmtools.sh
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ virtualbox-iso|virtualbox-ovf)

vmware-iso|vmware-vmx)
iso_name="/tmp/vmtools.iso";
mount_point="$(mktemp -d /tmp/vmware-tools.XXXX)";
mount_point="`mktemp -d /tmp/vmware-tools.XXXX`";
#Run install, unmount ISO and remove it
hdiutil attach "$iso_name" -mountpoint "$mount_point";
installer -pkg "$mount_point/Install VMware Tools.app/Contents/Resources/VMware Tools.pkg" -target /;
@@ -25,7 +25,7 @@ vmware-iso|vmware-vmx)

parallels-iso|parallels-pvm)
TOOLS_PATH="$HOME_DIR/prl-tools-mac.iso";
TMPMOUNT="$(/usr/bin/mktemp -d /tmp/parallels-tools.XXXX)";
TMPMOUNT="`/usr/bin/mktemp -d /tmp/parallels-tools.XXXX`";

#Run install, unmount ISO and remove it
hdiutil attach "$TOOLS_PATH" -mountpoint "$TMPMOUNT";
2 changes: 1 addition & 1 deletion scripts/omnios/postinstall.sh
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@ svcadm restart ssh

# update grub menu to lower timeout and remove unnecessary second entry
echo "Updating Grub boot menu"
sed -i -e 's/^timeout.*$/timeout 5/' -e "/^title omniosvar/,$(wc -l /rpool/boot/grub/menu.lst | awk '{ print $1 }') d" /rpool/boot/grub/menu.lst
sed -i -e 's/^timeout.*$/timeout 5/' -e "/^title omniosvar/,`wc -l /rpool/boot/grub/menu.lst | awk '{ print $1 }'` d" /rpool/boot/grub/menu.lst

# Reset resolv.conf
echo "Resetting resolv.conf"
28 changes: 13 additions & 15 deletions scripts/omnios/vmtools.sh
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
#!/bin/bash
#!/bin/sh

if [ "$PACKER_BUILDER_TYPE" == 'virtualbox' ]; then
if [ $PACKER_BUILDER_TYPE == 'virtualbox' ]; then
echo "Installing VirtualBox Guest Additions"
{
echo -e "mail=\ninstance=overwrite\npartial=quit"
echo -e "runlevel=nocheck\nidepend=quit\nrdepend=quit"
echo -e "space=quit\nsetuid=nocheck\nconflict=nocheck"
echo -e "action=nocheck\nbasedir=default"
} > /tmp/noask.admin
echo "mail=\ninstance=overwrite\npartial=quit" > /tmp/noask.admin
echo "runlevel=nocheck\nidepend=quit\nrdepend=quit" >> /tmp/noask.admin
echo "space=quit\nsetuid=nocheck\nconflict=nocheck" >> /tmp/noask.admin
echo "action=nocheck\nbasedir=default" >> /tmp/noask.admin
mkdir /mnt/vbga
VBGADEV=$(lofiadm -a VBoxGuestAdditions.iso)
mount -o ro -F hsfs "$VBGADEV" /mnt/vbga
VBGADEV=`lofiadm -a VBoxGuestAdditions.iso`
mount -o ro -F hsfs $VBGADEV /mnt/vbga
pkgadd -a /tmp/noask.admin -G -d /mnt/vbga/VBoxSolarisAdditions.pkg all
umount /mnt/vbga
lofiadm -d "$VBGADEV"
lofiadm -d $VBGADEV
rm -f VBoxGuestAdditions.iso
fi

if [ "$PACKER_BUILDER_TYPE" == 'vmware' ]; then
if [ $PACKER_BUILDER_TYPE == 'vmware' ]; then
mkdir /mnt/vmtools
VMTOOLSDEV=$(lofiadm -a solaris.iso)
mount -o ro -F hsfs "$VMTOOLSDEV" /mnt/vmtools
VMTOOLSDEV=`lofiadm -a solaris.iso`
mount -o ro -F hsfs $VMTOOLSDEV /mnt/vmtools
mkdir /tmp/vmfusion-archive
tar zxvf /mnt/vmtools/vmware-solaris-tools.tar.gz -C /tmp/vmfusion-archive
/tmp/vmfusion-archive/vmware-tools-distrib/vmware-install.pl --force-install
umount /mnt/vmtools
lofiadm -d "$VMTOOLSDEV"
lofiadm -d $VMTOOLSDEV
rmdir /mnt/vmtools
rm -rf /tmp/vmfusion-archive
rm -f solaris.iso
2 changes: 1 addition & 1 deletion scripts/opensuse/sudoers.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash -eux
#!/bin/sh -eux

# update sudoers - can't do this in autoinst.xml
echo -e "\nupdate sudoers ..."
22 changes: 14 additions & 8 deletions scripts/sles/remove-dvd-source.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
#!/bin/bash -eux
#!/bin/sh -eux

oslevel=$(grep VERSION /etc/SuSE-release | awk '{ print $3 }')
patchlevel=$(grep PATCHLEVEL /etc/SuSE-release | awk '{ print $3 }')
if [ 'x86_64' == `uname -m` ]; then
arch_suffix=x64
else
arch_suffix=x86
fi

oslevel=`grep VERSION /etc/SuSE-release | awk '{ print $3 }'`
patchlevel=`grep PATCHLEVEL /etc/SuSE-release | awk '{ print $3 }'`

if [ "$oslevel" == '11' ]; then
if [ "$patchlevel" == '2' ]; then
if [ $oslevel == '11' ]; then
if [ $patchlevel == '2' ]; then
repo_ver="11.2.2-1.234"
elif [ "$patchlevel" == '3' ]; then
elif [ $patchlevel == '3' ]; then
repo_ver="11.3.3-1.138"
elif [ "$patchlevel" == '4' ]; then
elif [ $patchlevel == '4' ]; then
repo_ver="11.4.4-1.109"
else
echo "Failed to remove DVD source; don't know how to deal with patchlevel $patchlevel"
exit 1
fi
zypper removerepo "SUSE-Linux-Enterprise-Server-11-SP$patchlevel $repo_ver"

elif [ "$oslevel" == '12' ]; then
elif [ $oslevel == '12' ]; then
zypper removerepo "SLES12-12-$patchlevel";
fi

2 changes: 0 additions & 2 deletions scripts/sles/sudoers.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/bin/bash -eux

# update sudoers - can't do this in autoinst.xml
echo -e "\nupdate sudoers ..."
echo -e "vagrant ALL=(ALL) NOPASSWD: ALL\n" >> /etc/sudoers
4 changes: 2 additions & 2 deletions scripts/sles/zypper-locks.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash -eux
#!/bin/sh -eux

# remove zypper locks on removed packages to avoid later dependency problems
any_package_locks=$(zypper --non-interactive ll | grep package);
any_package_locks=`zypper --non-interactive ll | grep package`;

if [ 'There are no package locks defined.' == "$any_package_locks" ]; then
echo 'There are no package locks defined. Doing nothing.';
Loading

0 comments on commit 3adda37

Please sign in to comment.