generated from me/template-mit
Compare commits
9 Commits
672d8d424a
..
prod
| Author | SHA1 | Date | |
|---|---|---|---|
| 55fa6357b3 | |||
| 4a6de24d26 | |||
| d523ae939a | |||
| 0fccd614e7 | |||
| 35a64c49a3 | |||
| af9009f1e4 | |||
| 40d6450428 | |||
| 18b4ef7a8a | |||
| c0762fb23e |
+92
-9
@@ -257,7 +257,7 @@ function pull {
|
||||
|
||||
function push {
|
||||
if [[ -d .git ]]; then
|
||||
git push && load-stage && load-prod
|
||||
git push && eval load-stage && eval load-prod
|
||||
else
|
||||
send-master
|
||||
fi
|
||||
@@ -306,7 +306,7 @@ function sync-all {
|
||||
echo -e "`date` - Done.\n"
|
||||
}
|
||||
function sync-all-loop {
|
||||
typeset -i sleep_time
|
||||
typeset -i sleep_time count
|
||||
if [[ "$1" ]]; then
|
||||
sleep_time="$1"
|
||||
fi
|
||||
@@ -314,10 +314,12 @@ function sync-all-loop {
|
||||
sleep_time="300"
|
||||
fi
|
||||
log "`date` - Sleep timer set for '$sleep_time' seconds."
|
||||
count=0
|
||||
while true; do
|
||||
sync-all
|
||||
echo -e "\n\n*** Sleeping... ***\n\n"
|
||||
sleep 300
|
||||
count=$(( count + 1 ))
|
||||
echo -e "\n\n*** Sleeping for '$sleep_time' after run# '$count'! ***\n\n"
|
||||
sleep $sleep_time
|
||||
done
|
||||
}
|
||||
|
||||
@@ -479,7 +481,7 @@ function process-video {
|
||||
return $status
|
||||
}
|
||||
alias pv="process-video"
|
||||
alias qpv="pv ./raw/YouCut*.mp4 $(basename `pwd`).mp4"
|
||||
alias qpv='pv ./raw/YouCut*.mp4 $(basename `pwd`).mp4'
|
||||
|
||||
# Allow converting video to audio and other smaller
|
||||
# tasks than what process-video is intended to do.
|
||||
@@ -581,13 +583,92 @@ alias pull-audio="v2a"
|
||||
alias pa="v2a"
|
||||
|
||||
|
||||
### Web ###
|
||||
|
||||
function download-website {
|
||||
website="$1"
|
||||
if [[ -z "$website" ]]; then
|
||||
echo "ERROR: Website not provided. $website"
|
||||
return
|
||||
fi
|
||||
if [[ "$website" != "http"* ]]; then
|
||||
website="http://$website"
|
||||
fi
|
||||
# https://simpleit.rocks/linux/how-to-download-a-website-with-wget-the-right-way/
|
||||
# Does not simplify the links for offline usage.
|
||||
# wget --wait=2 \
|
||||
# --level=inf \
|
||||
# --limit-rate=20K \
|
||||
# --recursive \
|
||||
# --page-requisites \
|
||||
# --user-agent=Mozilla \
|
||||
# --no-parent \
|
||||
# --convert-links \
|
||||
# --adjust-extension \
|
||||
# --no-clobber \
|
||||
# -e robots=off \
|
||||
# $website &&
|
||||
|
||||
# https://www.digitalcitizen.life/how-to-download-entire-website-for-offline-viewing/
|
||||
# This one is supposed to work too and is much smaller.
|
||||
# wget --mirror \
|
||||
# --convert-links \
|
||||
# --adjust-extension \
|
||||
# --page-requisites \
|
||||
# --no-parent \
|
||||
# $website &&
|
||||
|
||||
# Combine the two by using mirow and removing the rate limit.
|
||||
wget --mirror \
|
||||
--wait=2 \
|
||||
--level=inf \
|
||||
--recursive \
|
||||
--page-requisites \
|
||||
--user-agent=Mozilla \
|
||||
--no-parent \
|
||||
--convert-links \
|
||||
--adjust-extension \
|
||||
--no-clobber \
|
||||
-e robots=off \
|
||||
--timeout=15 \
|
||||
--tries=0 \
|
||||
--continue \
|
||||
--waitretry=5 \
|
||||
--random-wait \
|
||||
$website &&
|
||||
{
|
||||
echo -e "\nSuccess!"
|
||||
} || {
|
||||
echo -e "\nERROR: Command reported a failure. (Error code '$?')"
|
||||
echo "This may mean that the URL was not converted to local links."
|
||||
echo "Please check the error and contents and try again if needed."
|
||||
}
|
||||
}
|
||||
alias website-download="download-website"
|
||||
alias curl-site="download-website"
|
||||
alias pull-site="download-website"
|
||||
alias site-pull="download-website"
|
||||
alias curl-www="download-website"
|
||||
alias pull-www="download-website"
|
||||
alias www-pull="download-website"
|
||||
|
||||
function run-site {
|
||||
python3 -m http.server
|
||||
}
|
||||
alias run-html="run-site"
|
||||
alias exec-site="run-site"
|
||||
alias exec-html="run-site"
|
||||
alias site-host="run-site"
|
||||
alias host-site="run-site"
|
||||
|
||||
|
||||
## Finalize ##
|
||||
|
||||
# Export all functions! #
|
||||
eval "$(declare -F | grep -v _ | sed 's/-f /-fx /')"
|
||||
|
||||
# Run update checker in background.
|
||||
(
|
||||
if [[ "$USER" != "root" ]]; then
|
||||
(
|
||||
if [[ -d "$PROJECT_SHARED" ]]; then
|
||||
git -C "$PROJECT_SHARED" fetch >/dev/null 2>&1 \
|
||||
@@ -613,12 +694,14 @@ eval "$(declare -F | grep -v _ | sed 's/-f /-fx /')"
|
||||
notify-send "$title" "$message"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
) >> "$HOME"/Reports/env-shared.log.txt 2>&1 &
|
||||
)
|
||||
fi >> "$HOME"/Reports/env-shared.log.txt 2>&1 &
|
||||
)
|
||||
fi
|
||||
|
||||
|
||||
## Complete! ##
|
||||
|
||||
[[ $(whoami) != "root" ]] &&
|
||||
echo "`date` - Shared RC Config - Complete!"
|
||||
|
||||
export _LOADED_SHARED_RC=true
|
||||
|
||||
Reference in New Issue
Block a user