Skip to content

Commit c4d3100

Browse files
author
Issac Trotts
committed
More error handling
1 parent 6f16d5e commit c4d3100

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

appengine/standard/wordpress/gen-wp-config

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,16 @@ DB_PASS is the root password to set for the instance.
2424
"
2525
fi
2626

27+
set -u
28+
set -o pipefail
29+
2730
log=$(mktemp)
2831

29-
db_conn_name=$(gcloud sql instances describe $db_instance \
30-
| grep connectionName \
31-
| sed 's/connectionName: //')
32+
instances=$(mktemp)
33+
gcloud sql instances describe $db_instance 2>$log >$instances \
34+
|| die "Failed to get description of Cloud SQL instance $db_instance: $(cat $log)"
35+
db_conn_name=$(grep connectionName $instances | sed 's/connectionName: //')
36+
if [[ $? != 0 ]]; then die "Failed to find connectionName in instance description."; fi
3237
db_host=":/cloudsql/$db_conn_name"
3338
echo "\
3439
<?php

appengine/standard/wordpress/update-wordpress

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ tar xzvf wordpress.tar.gz &>$log || die "Failed to untar wordpress tarball: $(ta
1616
curl -L https://github.com/wpCloud/wp-stateless/archive/2.1.1.tar.gz 2>$log >wp-stateless.tar.gz \
1717
|| die "Failed to fetch wp-stateless plugin: $(cat $log)"
1818
tar xzvf wp-stateless.tar.gz &>$log || die "Failed to untar wp-stateless tarball: $(tail $log)"
19-
mv wp-stateless-2.1.1 wordpress/wp-content/plugins &>$log \
20-
|| die "Failed to move wp-stateless plugin into place: $(cat $log)"
19+
rsync wp-stateless-2.1.1 wordpress/wp-content/plugins &>$log \
20+
|| die "Failed to copy wp-stateless plugin into place: $(cat $log)"
2121
cd wordpress || die "Failed to cd into wordpress."
2222
# Force WordPress not to prepend ABSPATH to UPLOADS since we have
2323
# defined UPLOADS to be an absolute path: /tmp.

0 commit comments

Comments
 (0)