warbo-utilities: 0bcbd938da80a228badae27e319cc6e776896001

     1: #!/usr/bin/env bash
     2: set -e
     3: 
     4: mount | grep -q s3_repos || {
     5:     echo "$HOME/Drives/s3_repos not mounted, skipping render" 1>&2
     6:     exit 0
     7: }
     8: 
     9: cd "$1"
    10: 
    11: NAME=$(basename "$PWD" .git)
    12: 
    13: PAGES=$(repoPath="$PWD" htmlInOut=1 inNixedDir genGitHtml)
    14: export PAGES
    15: DEST="$HOME/Drives/s3_repos/$NAME"
    16: 
    17: git2ipfs "$PWD" || echo "Failed to push to IPFS, carrying on anyway..." 1>&2
    18: 
    19: if [[ -n "$PAGES" ]]
    20: then
    21:     echo "Pushing '$PAGES' to Web" 1>&2
    22: 
    23:     #export RCLONE_S3_REGION=eu-west-1
    24:     #export RCLONE_S3_PROVIDER=AWS
    25:     #export RCLONE_S3_ENV_AUTH=true
    26:     # Don't include repo.git, since we can use the real, canonical one
    27:     #with-aws-creds rclone sync "$PAGES" ":s3:www.chriswarbo.net/git/$NAME"
    28:     rsync --checksum --delete --ignore-times --progress --copy-unsafe-links \
    29:           --archive --no-perms --no-owner --no-group \
    30:           --exclude /repo.git --exclude /branches/master "$PAGES/" "$DEST" || {
    31:         CODE="$?"
    32:         if [[ "$CODE" -eq 23 ]]
    33:         then
    34:             echo "Ignoring rsync error about attributes (it's S3's fault)" 1>&2
    35:         else
    36:             echo "Unexpected rsync problem, aborting" 1>&2
    37:             exit "$CODE"
    38:         fi
    39:     }
    40: 
    41:     # Edit repo link to point at canonical /git repo
    42:     sed -e "s@repo.git@/git/$NAME.git@g" -i "$DEST/index.html"
    43: fi
    44: 
    45: # Ensure there's no snapshot
    46: F="$DEST/repo.git"
    47: if [[ -e "$F" ]]
    48: then
    49:   echo "WARNING: Shouldn't have '$F', canonical URL should be used" 1>&2
    50: fi
    51: 
    52: # Ensure we use canonical URL
    53: URL="/git/$NAME.git"
    54:   F="$DEST/index.html"
    55: 
    56: # shellcheck disable=SC2029
    57: if grep -q "$URL" < "$F"
    58: then
    59:     true
    60: else
    61:     echo "WARNING: Didn't find canonical URL '$URL' in '$F'" 1>&2
    62: fi

Generated by git2html.