From 2454f268cae85fe49c5bf20da8d3a363b93a8b31 Mon Sep 17 00:00:00 2001 From: kebler Date: Tue, 7 Feb 2023 11:21:38 -0800 Subject: [PATCH] minor modules cleanup --- modules/scripting/bundle.func | 82 +++++++++++------------ modules/{utility => scripting}/iecho.func | 0 modules/scripting/path.sh | 2 +- modules/utility/github-bin-fetch.sh | 31 --------- modules/utility/security.lib | 2 + 5 files changed, 44 insertions(+), 73 deletions(-) rename modules/{utility => scripting}/iecho.func (100%) delete mode 100644 modules/utility/github-bin-fetch.sh diff --git a/modules/scripting/bundle.func b/modules/scripting/bundle.func index 24f7e70..a8166f3 100644 --- a/modules/scripting/bundle.func +++ b/modules/scripting/bundle.func @@ -10,51 +10,51 @@ bundle () { -local file + local file -if [[ $1 == "-m" ]]; then - shift 1 - file=$(module_find $1) - else - file=$1 -fi + if [[ $1 == "-m" ]]; then + shift 1 + file=$(module_find $1) + else + file=$1 + fi -[[ ! -f $file ]] && return 1 -module_load file + [[ ! -f $file ]] && return 1 + module_load file -if [[ ! $2 == "__recurse__" ]]; then -tmp_file=$( mktemp -t TEMP_FILE_bundle.XXXXXXXX ) -chmod 600 "$tmp_file" -\cp $file $tmp_file -else -tmp_file=$file -fi -# echo current temp file: $tmp_file -modules=$(sed -n -e 's/^module_load //p' < $tmp_file) -# echo found: $modules -# return -if [[ $modules ]]; then - # echo Modules: $modules - sed -i '/module_load/d' $tmp_file - for module in $(printf '%s\n' "${modules[@]}"|tac); - do - # echo module: $module - # echo module path: $(module_find $module) - prepend_file $(module_find $module) $tmp_file - done - bundle $tmp_file __recurse__ -fi - -if [[ ! $2 == "__recurse__" ]]; then - if [[ $2 ]]; then - \cp $tmp_file $2 - # echo $2 - else - echo -e "$(cat $tmp_file)" + if [[ ! $2 == "__recurse__" ]]; then + tmp_file=$( mktemp -t TEMP_FILE_bundle.XXXXXXXX ) + chmod 600 "$tmp_file" + \cp $file $tmp_file + else + tmp_file=$file + fi + # echo current temp file: $tmp_file + modules=$(sed -n -e 's/^module_load //p' < $tmp_file) + # echo found: $modules + # return + if [[ $modules ]]; then + # echo Modules: $modules + sed -i '/module_load/d' $tmp_file + for module in $(printf '%s\n' "${modules[@]}"|tac); + do + # echo module: $module + # echo module path: $(module_find $module) + prepend_file $(module_find $module) $tmp_file + done + bundle $tmp_file __recurse__ + fi + + if [[ ! $2 == "__recurse__" ]]; then + if [[ $2 ]]; then + \cp $tmp_file $2 + # echo $2 + else + echo -e "$(cat $tmp_file)" + fi + rm -f $tmp_file; + return 0 fi - rm -f $tmp_file; - return 0 - fi } # # if script was executed then call the function diff --git a/modules/utility/iecho.func b/modules/scripting/iecho.func similarity index 100% rename from modules/utility/iecho.func rename to modules/scripting/iecho.func diff --git a/modules/scripting/path.sh b/modules/scripting/path.sh index 8e99bbf..0c8e03d 100644 --- a/modules/scripting/path.sh +++ b/modules/scripting/path.sh @@ -3,7 +3,7 @@ isAbsPath() { if [[ "${1:0:1}" == / || "${1:0:2}" == ~[/a-z] ]] then - echo "true" + echo $1 return 0 else return 1 diff --git a/modules/utility/github-bin-fetch.sh b/modules/utility/github-bin-fetch.sh deleted file mode 100644 index e23408b..0000000 --- a/modules/utility/github-bin-fetch.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash -# if you have run into github api anonymous access limits which happens during debugging/dev then add user and token here or sourced from a separate file -# set to location for tokens in file -# DEPRECATED use python based lastversion https://github.com/dvershinin/lastversion -source ~/githubapitoken - -if [ "$GITHUB_TOKEN" != "" ]; then -echo using access token with script -echo $GITHUB_USER $GITHUB_TOKEN -fi - -DIR=$(dirname "$(readlink -f "$0")") || exit - -ORG=$1 -REPO=$2 -TYPE=$3 -NAME=$4 -EXCLUDE=$5 - -URL=$(curl -s https://api.github.com/repos/$ORG/$REPO/releases/latest \ -# | grep 'browser_download_url.*'$TYPE'' -# | sed -n -e 's/^.*: //p' \ -# | sed 's/"//g' - ) - - - echo "Pulling $URL" -TODO put back tokens here. -# wget $URL -O $NAME.$TYPE -# chmod +x $DIR/$NAME.$TYPE -# ln -s $DIR/$NAME.$TYPE /opt/bin/$NAME diff --git a/modules/utility/security.lib b/modules/utility/security.lib index 397e968..400b610 100644 --- a/modules/utility/security.lib +++ b/modules/utility/security.lib @@ -3,6 +3,8 @@ module_load confirm module_load helpers + +alias aud="acladduserdir" #source ${BASH_SOURCE[0]}/confirm.sh # Usage: