INNER CODE UNIT · Shell

config_repo

haugene/docker-transmission-openvpn · openvpn/fetch-external-configs.sh:52

  config_repo=/config/vpn-configs-contrib

  # Add safe directory for repo folder
  git config --global --add safe.directory "${config_repo}"

  echo "Will get configs from ${GITHUB_CONFIG_REPO_URL}"
  # Check if git repo exists and clone or pull based on that
  if [[ -d ${config_repo} ]]; then
    GITHUB_CONFIG_SOURCE_LOCAL=$(git -C "${config_repo}" remote -v | head -1 | awk '{print $2}' | sed -e 's/https:\/\/github.com\///' -e 's/.git//')
    if [ "$GITHUB_CONFIG_SOURCE_LOCAL" == "$GITHUB_CONFIG_SOURCE_REPO" ]; then
      echo "Repository is already cloned, updating"
      if git -C "${config_repo}" fetch origin; then
        if git -C "${config_repo}" reset --hard "origin/${GITHUB_CONFIG_SOURCE_REVISION}" && \
           git -C "${config_repo}" clean -fd; then
          echo "Repository updated successfully"
        else
          echo "ERROR: Fetched from origin but failed to reset to ${GITHUB_CONFIG_SOURCE_REVISION} or clean ${config_repo}"
          exit 1

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…