minor modules cleanup

master
Kebler Network System Administrator 2023-02-07 11:21:38 -08:00
parent 9eaef445af
commit 2454f268ca
5 changed files with 44 additions and 73 deletions

View File

@ -10,51 +10,51 @@
bundle () { bundle () {
local file local file
if [[ $1 == "-m" ]]; then if [[ $1 == "-m" ]]; then
shift 1 shift 1
file=$(module_find $1) file=$(module_find $1)
else else
file=$1 file=$1
fi fi
[[ ! -f $file ]] && return 1 [[ ! -f $file ]] && return 1
module_load file module_load file
if [[ ! $2 == "__recurse__" ]]; then if [[ ! $2 == "__recurse__" ]]; then
tmp_file=$( mktemp -t TEMP_FILE_bundle.XXXXXXXX ) tmp_file=$( mktemp -t TEMP_FILE_bundle.XXXXXXXX )
chmod 600 "$tmp_file" chmod 600 "$tmp_file"
\cp $file $tmp_file \cp $file $tmp_file
else else
tmp_file=$file tmp_file=$file
fi fi
# echo current temp file: $tmp_file # echo current temp file: $tmp_file
modules=$(sed -n -e 's/^module_load //p' < $tmp_file) modules=$(sed -n -e 's/^module_load //p' < $tmp_file)
# echo found: $modules # echo found: $modules
# return # return
if [[ $modules ]]; then if [[ $modules ]]; then
# echo Modules: $modules # echo Modules: $modules
sed -i '/module_load/d' $tmp_file sed -i '/module_load/d' $tmp_file
for module in $(printf '%s\n' "${modules[@]}"|tac); for module in $(printf '%s\n' "${modules[@]}"|tac);
do do
# echo module: $module # echo module: $module
# echo module path: $(module_find $module) # echo module path: $(module_find $module)
prepend_file $(module_find $module) $tmp_file prepend_file $(module_find $module) $tmp_file
done done
bundle $tmp_file __recurse__ bundle $tmp_file __recurse__
fi fi
if [[ ! $2 == "__recurse__" ]]; then if [[ ! $2 == "__recurse__" ]]; then
if [[ $2 ]]; then if [[ $2 ]]; then
\cp $tmp_file $2 \cp $tmp_file $2
# echo $2 # echo $2
else else
echo -e "$(cat $tmp_file)" echo -e "$(cat $tmp_file)"
fi
rm -f $tmp_file;
return 0
fi fi
rm -f $tmp_file;
return 0
fi
} }
# # if script was executed then call the function # # if script was executed then call the function

View File

@ -3,7 +3,7 @@
isAbsPath() { isAbsPath() {
if [[ "${1:0:1}" == / || "${1:0:2}" == ~[/a-z] ]] if [[ "${1:0:1}" == / || "${1:0:2}" == ~[/a-z] ]]
then then
echo "true" echo $1
return 0 return 0
else else
return 1 return 1

View File

@ -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

View File

@ -3,6 +3,8 @@
module_load confirm module_load confirm
module_load helpers module_load helpers
alias aud="acladduserdir"
#source ${BASH_SOURCE[0]}/confirm.sh #source ${BASH_SOURCE[0]}/confirm.sh
# Usage: # Usage: