shell-base/modules/scripting/btpl.lib

29 lines
962 B
Bash
Executable File

#!/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
wget -O "$BTPLDIR"/btpl https://raw.githubusercontent.com/TekWizely/bash-tpl/main/bash-tpl
chmod +x "$BTPLDIR"/btpl
# 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
[[ ! -f $BTPLDIR/btpl ]] && btpl_fetch
for btpl in *.btpl; do
[[ -f "$btpl" ]] || break
echo processing $btpl ...
# 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)
done
if [[ $dir ]]; then popd 1>/dev/null || return; fi
}