#!/usr/bin/env bash
#Variables
# -------------------------
REPO="$HOME/Sandbox/hinode-template"
SRC="$REPO/public/"
DSRC="$REPO/docs-server/"
DSRBTS="$DSRC/robots.txt"
REMOTE="216.189.157.213"
DST="/var/www/htdocs/corruptlamar"
DSDST="/var/www/htdocs/docs"
USERNAME="anoduck"
API="f18dd78af41a4d1ab6d15d7099522c61"
KEYFILE="$SRC/$API.txt"
# ------------------------------------------
rbts="User-agent: *
Disallow: /"
# ------------------------------------------
# request='POST /IndexNow HTTP/1.1
# Content-Type: application/json; charset=utf-8
# Host: api.indexnow.org
# {
# "host": "corruptlamar.com",
# "key": "f18dd78af41a4d1ab6d15d7099522c61",
# "keyLocation": "https://corruptlamar.com/f18dd78af41a4d1ab6d15d7099522c61.txt",
# "urlList": [
# "https://corruptlamar.com/url1",
# "https://corruptlamar.com/folder/url2",
# "https://corruptlamar.com/url3"
# ]
# }'
# ------------------------------------------
INDATA='{
"host": "corruptlamar.com",
"key": "f18dd78af41a4d1ab6d15d7099522c61",
"keyLocation": "https://corruptlamar.com/f18dd78af41a4d1ab6d15d7099522c61.txt",
"urlList": [
"https://corruptlamar.com/",
"https://corruptlamar.com/evidence",
"https://corruptlamar.com/legal",
"https://corruptlamar.com/posts",
"https://corruptlamar.com/persons",
"https://corruptlamar.com/communication",
"https://corruptlamar.com/video",
]
}'
INHEADER="Content-Type: application/json; charset=utf-8"
INHOST="api.indexnow.org"
# ------------------------------------------
compush() {
git add .
git commit -am "$1"
setver autopatch
}
build() {
npm run build
cp -r static/emails/* public/emails/
}
# alt_files() {
# rg --files-with-matches --fixed-strings '' |
# xargs -I % sed -i '//d' %
# }
sync() {
# $SRC_PATH must be _closed_ and ends _with_ a "/".
# $DST_PATH must be _open_ and ends _with_ _NO_ "/".
rsync -azv -e ssh --delete "$SRC" "$USERNAME"@"$REMOTE":"$DST"
rsync -azv -e ssh --delete "$DSRC" "$USERNAME"@"$REMOTE":"$DSDST"
}
indexnow() {
curl --data "$INDATA" --header "$INHEADER" "$INHOST"
}
generate_key() {
if ! [[ -e "$KEYFILE" ]] ; then
echo "$KEY" > "$KEYFILE"
fi
}
generate_robots() {
if ! [[ -e "$DSRBTS" ]]; then
echo "$rbts" > "$DSRBTS"
fi
}
# ------------------------------------------
if [[ ! "$PWD" == "$REPO" ]]; then
cd "$REPO" || return
fi
# compush
build
cd "$SRC" || return
generate_key && indexnow && generate_robots
#alt_files
echo "Skipping cleaning of alt files"
cd "$REPO" || return
sync