2024-08-03 14:47:32 -07:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
BTPLDIR=$(dirname $(module_find btpl))
|
|
|
|
export BTPLDIR
|
|
|
|
|
|
|
|
btpl_fetch () {
|
|
|
|
# /opt/python/apps/bin/lastversion --assets --output /shell/base/modules/scripting/btpl.lib download bash-tpl
|
2024-08-05 17:02:24 -07:00
|
|
|
wget -O "$BTPLDIR"/btpl https://raw.githubusercontent.com/TekWizely/bash-tpl/main/bash-tpl
|
|
|
|
chmod +x "$BTPLDIR"/btpl
|
2024-08-03 14:47:32 -07:00
|
|
|
# sed -i 's/\bmain\b/btpl/g' /shell/base/modules/scripting/btpl.lib
|
|
|
|
}
|
|
|
|
|
|
|
|
btpl () {
|
|
|
|
local dir
|
|
|
|
if [[ $1 == "-d" ]]; then shift; dir=$1; shift; pushd $dir 1>/dev/null || return; fi
|
|
|
|
[[ ! $BTPLDIR ]] && echo unable to establish Bash Template directory && return 2
|
2024-08-05 17:02:24 -07:00
|
|
|
[[ ! -f $BTPLDIR/btpl ]] && btpl_fetch
|
2024-08-03 14:47:32 -07:00
|
|
|
for btpl in *.btpl; do
|
|
|
|
[[ -f "$btpl" ]] || break
|
|
|
|
echo processing $btpl ...
|
2024-08-05 17:02:24 -07:00
|
|
|
# echo sudo $BTPLDIR/btpl --output-file $(basename $btpl .btpl)$([[ $1 ]] && echo .$1) $btpl
|
|
|
|
$BTPLDIR/btpl $btpl
|
|
|
|
source <($BTPLDIR/btpl $btpl) | sudo tee $(basename $btpl .btpl)$([[ $1 ]] && echo .$1)
|
2024-08-03 14:47:32 -07:00
|
|
|
done
|
|
|
|
if [[ $dir ]]; then popd 1>/dev/null || return; fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|