Add a way to skip repos in generated files and add a few unset variables.

This commit is contained in:
GRMrGecko 2024-02-18 20:17:40 -06:00
parent 9aea1cbf26
commit 2a3eb4b7f5
2 changed files with 15 additions and 3 deletions

View File

@ -460,6 +460,9 @@ The repo icon, will default to tux if not defined. The icon can be defined as an
### repo_descriotion
A description to show at the bottom of the repo card.
### repo_skip
This repo should not be put in generated files.
### disable_size_calc
Should be set to a 1 if you do not want a size to be calculated.
@ -474,6 +477,7 @@ If you have a repo that is not synced via the mirror-sync, but want to customize
* repo_title
* repo_icon
* repo_description
* repo_skip
* disable_size_calc
* timestamp_file_stat

View File

@ -10,7 +10,7 @@ PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:$HOME/.local/
# Variables about this program.
PROGRAM="mirror-file-generator"
VERSION="20240217"
VERSION="20240218"
PIDFILE="/tmp/$PROGRAM.pid"
LOGFILE="/var/log/mirror-sync/$PROGRAM.log"
@ -370,6 +370,7 @@ for ((i=0; i<${#selected_mirrors[@]}; i++)); do
eval icon="\${${MODULE}_repo_icon:-}"
eval repo_description="\${${MODULE}_repo_description:-}"
eval disable_size_calc="\${${CUSTOM_MODULE}_disable_size_calc:-0}"
eval repo_skip="\${${CUSTOM_MODULE}_repo_skip:-0}"
eval timestamp_file_stat="\${${CUSTOM_MODULE}_timestamp_file_stat:-}"
# If a timestamp file exists, grab and format the date.
@ -378,7 +379,7 @@ for ((i=0; i<${#selected_mirrors[@]}; i++)); do
fi
# If a directory usage summary exists, parse the size.
if [[ -f ${dusum:?} ]]; then
if [[ -f ${dusum:?} ]] && ((${repo_skip:-0} == 0)); then
repo_size_kb=$(grep "$real_dir" "${dusum:?}" | awk '{print $1}')
if [[ -n $repo_size_kb ]]; then
totalKBytes=$((totalKBytes+repo_size_kb))
@ -402,9 +403,14 @@ for ((i=0; i<${#selected_mirrors[@]}; i++)); do
eval icon="\${${CUSTOM_MODULE}_repo_icon:-}"
eval repo_description="\${${CUSTOM_MODULE}_repo_description:-}"
eval disable_size_calc="\${${CUSTOM_MODULE}_disable_size_calc:-0}"
eval repo_skip="\${${CUSTOM_MODULE}_repo_skip:-0}"
eval timestamp_file_stat="\${${CUSTOM_MODULE}_timestamp_file_stat:-}"
fi
done
if ((${repo_skip:-0})); then
continue
fi
# If a timstamp file stat is configured and the path exists, get the timestamp via stat.
if [[ -e ${timestamp_file_stat:-} ]]; then
@ -479,7 +485,9 @@ for ((i=0; i<${#selected_mirrors[@]}; i++)); do
fi
# Unset all vars for next repo.
unset repo_path repo_icon repo_title repo_size repo_size_kb repo_sync_time repo_description timestamp dusum section icon
unset repo_path repo_icon repo_title repo_size repo_size_kb \
repo_sync_time repo_description timestamp dusum section \
icon repo_skip disable_size_calc timestamp_file_stat
done
# If the index should be generated, add each section and footer.