Skip to content

Commit

Permalink
Merge pull request #86 from lildude/improve-compatibility
Browse files Browse the repository at this point in the history
Improve cross-platform compatibility
  • Loading branch information
rtomayko committed Dec 12, 2014
2 parents fc8d2d8 + f7c15c5 commit 9d3895c
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions bin/ghe-host-check
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ set -e
if [ $rc -ne 0 ]; then
case $rc in
255)
if echo "$output" | grep -i -q "port 22: connection refused"; then
if echo "$output" | grep -i "port 22: connection refused" >/dev/null; then
exec "$0" "$hostname:122"
fi

Expand All @@ -44,7 +44,7 @@ if [ $rc -ne 0 ]; then
echo "Error: couldn't read GitHub Enterprise fingerprint on '$host' or this isn't a GitHub appliance." 1>&2
;;
1)
if [ "${port:-22}" -eq 22 ] && echo "$output" | grep -q "use port 122"; then
if [ "${port:-22}" -eq 22 ] && echo "$output" | grep "use port 122" >/dev/null; then
exec "$0" "$hostname:122"
else
echo "$output" 1>&2
Expand Down
2 changes: 1 addition & 1 deletion bin/ghe-restore
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ fi

# Restoring Elasticsearch to 11.10.3x via rsync requires GNU tar
if [ "$GHE_VERSION_MAJOR" -le 1 ] && [ "$GHE_BACKUP_STRATEGY" = "rsync" ]; then
if ! tar --version | grep -q GNU; then
if ! tar --version | grep GNU >/dev/null; then
if ! command -v gtar >/dev/null 2>&1; then
echo "GNU tar is required. Aborting." >&2
exit 1
Expand Down
2 changes: 1 addition & 1 deletion share/github-backup-utils/ghe-backup-repositories-rsync
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ echo "
while [ \$sanity -lt $GHE_GIT_COOLDOWN_PERIOD ]; do
# note: the bracket synta[x] below is to prevent matches against the
# grep process itself.
if ps axo args | grep -q -E -e '^git( -.*)? nw-repac[k]( |$)' -e '^git( -.*)? g[c]( |$)'; then
if ps axo args | grep -E -e '^git( -.*)? nw-repac[k]( |$)' -e '^git( -.*)? g[c]( |$)' >/dev/null; then
sleep 1
sanity=\$(( sanity + 1 ))
else
Expand Down
2 changes: 1 addition & 1 deletion share/github-backup-utils/ghe-restore-es-rsync
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ elif [ "$GHE_VERSION_MAJOR" -gt 1 ]; then
else
# Use GNU tar on BSDs.
TAR=tar
if ! tar --version | grep -q GNU; then
if ! tar --version | grep GNU >/dev/null; then
TAR=gtar
fi
cd "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT"
Expand Down
4 changes: 2 additions & 2 deletions share/github-backup-utils/ghe-restore-settings
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ GHE_RESTORE_SNAPSHOT_PATH="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT"
echo "Restoring settings ..."
if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then
# work around issue importing settings with bad storage mode values
cat "$GHE_RESTORE_SNAPSHOT_PATH/settings.json" |
( cat "$GHE_RESTORE_SNAPSHOT_PATH/settings.json" && echo ) |
sed 's/"storage_mode": "device"/"storage_mode": "rootfs"/' |
ghe-ssh "$GHE_HOSTNAME" -- '/usr/bin/env GHEBUVER=2 ghe-import-settings' 1>&3
else
cat "$GHE_RESTORE_SNAPSHOT_PATH/settings.json" |
( cat "$GHE_RESTORE_SNAPSHOT_PATH/settings.json" && echo ) |
ghe-ssh "$GHE_HOSTNAME" -- '/usr/bin/env GHEBUVER=2 ghe-import-settings' 1>&3
fi

Expand Down
2 changes: 1 addition & 1 deletion share/github-backup-utils/ghe-ssh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ opts="-l $user $opts"

# Bail out with error if the simple command form is used with complex commands.
# Complex
if echo "$*" | grep -q "[|;]" || [ $(echo "$*" | wc -l) -gt 1 ]; then
if echo "$*" | grep "[|;]" >/dev/null || [ $(echo "$*" | wc -l) -gt 1 ]; then
echo "fatal: ghe-ssh: Attempt to invoke complex command with simple command form." 1>&2
echo "See ghe-ssh --help for more on correcting." 1>&2
exit 1
Expand Down

0 comments on commit 9d3895c

Please sign in to comment.