Make Bash scripts more robust
Change-Id: I54c10966e3526840dec5053ade67309c6504de57
diff --git a/gce/freebsd-ci-homedir.sh b/gce/freebsd-ci-homedir.sh
index 5729868..7bbb728 100644
--- a/gce/freebsd-ci-homedir.sh
+++ b/gce/freebsd-ci-homedir.sh
@@ -20,6 +20,6 @@
destination="${CI_HOME}/.bazel/${BAZEL_VERSION}"
rm -fr "${destination}"
mkdir -p "${destination}/binary"
-ln -s `which bazel` "${destination}/binary/bazel"
+ln -s $(which bazel) "${destination}/binary/bazel"
ln -s "${destination}" "${CI_HOME}/.bazel/latest"
chown -R ci "${CI_HOME}/.bazel"
diff --git a/gce/init.sh b/gce/init.sh
index 01cb340..5f9fe70 100755
--- a/gce/init.sh
+++ b/gce/init.sh
@@ -107,7 +107,7 @@
echo "checking for its existence. It will also overwrite the firewall rules."
echo -n "Are you sure you want to do that? [y/N] "
read ans
- [ "$ans" = "y" -o "$ans" = "Y" ] || exit 1
+ [ "$ans" = "y" ] || [ "$ans" = "Y" ] || exit 1
action create "$@"
;;
"firewall")
diff --git a/gce/utils/network.sh b/gce/utils/network.sh
index 0603673..1d20a5b 100644
--- a/gce/utils/network.sh
+++ b/gce/utils/network.sh
@@ -55,7 +55,7 @@
local counter=0
if $restrict_http; then
for i in "${restrict_ips[@]}"; do
- counter=$(($counter+1))
+ counter=$((counter+1))
gcloud compute firewall-rules create "${network}-allow-http-https-icmp-${counter}" \
--network="${network}" \
--allow="tcp:80,udp:80,tcp:443,udp:443,icmp" \
@@ -75,7 +75,7 @@
log "Enabling incoming SSH, RDP, Jenkins-API and ICMP traffic to VMs for network ${network}"
counter=0
for i in "${restrict_ips[@]}"; do
- counter=$(($counter+1))
+ counter=$((counter+1))
gcloud compute firewall-rules create "${network}-allow-ssh-rdp-jenkins-icmp-${counter}" \
--network="${network}" \
--allow=tcp:22,tcp:3389,tcp:50000,icmp \
diff --git a/gerrit-github-sync/gerrit-github-sync.sh b/gerrit-github-sync/gerrit-github-sync.sh
index 7e6993d..c9686f9 100644
--- a/gerrit-github-sync/gerrit-github-sync.sh
+++ b/gerrit-github-sync/gerrit-github-sync.sh
@@ -28,7 +28,7 @@
)
# Install certificates
-(cd /usr/share/ca-certificates && find -type f -name '*.crt' \
+(cd /usr/share/ca-certificates && find . -type f -name '*.crt' \
| sed -e 's|^\./||') > /etc/ca-certificates.conf
update-ca-certificates
diff --git a/jenkins/slave_setup.sh b/jenkins/slave_setup.sh
index e71e084..dd4357b 100644
--- a/jenkins/slave_setup.sh
+++ b/jenkins/slave_setup.sh
@@ -20,7 +20,7 @@
HOME_FS={{ variables.HOME_FS }}
# Install certificates
-(cd /usr/share/ca-certificates && find -type f -name '*.crt' \
+(cd /usr/share/ca-certificates && find . -type f -name '*.crt' \
| sed -e 's|^\./||') > /etc/ca-certificates.conf
update-ca-certificates