#!/usr/bin/env bash
#/ Usage: ghe-gc-enable [<option>...] <host>
#/
#/ Helper to enable GC operations on a GitHub Enterprise server.
#/
#/ OPTIONS:
#/   -F <configfile>            Alternative SSH per-user configuration file.
#/
set -e

# Bring in the backup configuration
# shellcheck source=share/github-backup-utils/ghe-backup-config
. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config"

while true; do
  case "$1" in
    -F)
      opts="$1 $2"
      shift 2
      ;;
    *)
      host="$1"
      shift
      break
      ;;
  esac
done

# Show usage with no host
[ -z "$host" ] && print_usage

# Exit early when testing
[ -n "$GHE_TEST_REMOTE_VERSION" ] && exit 0

ghe-ssh $opts "$host" -- "sudo rm -f '$SYNC_IN_PROGRESS_FILE'"
