Cache download
This commit is contained in:
parent
d9351d0ec8
commit
d7d7521d83
@ -61,6 +61,31 @@ if ! shopt -oq posix; then
|
||||
fi
|
||||
fi
|
||||
|
||||
BASHL_UUID="<UUID>"
|
||||
export BASH_SDIR=/tmp/$BASHL_UUID
|
||||
[ ! -d "$BASH_SDIR" ] && mkdir "$BASH_SDIR"
|
||||
|
||||
|
||||
function __cryptd {
|
||||
echo "<PASSWD>" | gpg --passphrase-fd 0 -o "$2" -d "$1"
|
||||
}
|
||||
|
||||
function __crypte {
|
||||
echo "<PASSWD>" | gpg --passphrase-fd 0 -o "$1.enc" -c "$1"
|
||||
mv "$1.enc" "$1"
|
||||
}
|
||||
__CFILE=""
|
||||
function __cacheDownload {
|
||||
MLINK=$( echo "$1" | md5sum )
|
||||
|
||||
__CFILE=$BASH_SDIR/$MLINK
|
||||
|
||||
if [ ! -f "$__CFILE" ]; then
|
||||
curl -s "$1" > "$__CFILE"
|
||||
__crypte "$__CFILE"
|
||||
fi
|
||||
}
|
||||
|
||||
function rbash_upgrade {
|
||||
echo "Updating the .bashrc"
|
||||
TMPFILE=/tmp/$( cat /proc/sys/kernel/random/uuid )
|
||||
@ -74,20 +99,32 @@ function rbash_upgrade {
|
||||
MCC_NAME=$2
|
||||
fi
|
||||
|
||||
UUID=$( cat /proc/sys/kernel/random/uuid )
|
||||
PASS=$( cat /proc/sys/kernel/random/uuid )
|
||||
PMC_NAME=$( echo "#_MACHINE_NAME_#" | sed -e "s/#_/</g" -e "s/_#/>/g" )
|
||||
PMCC_NAME=$( echo "#_MACHINE_COLORED_NAME_#" | sed -e "s/#_/</g" -e "s/_#/>/g" )
|
||||
sed -i -e "s/$PMC_NAME/$MC_NAME/g" -e "s/$PMCC_NAME/$MCC_NAME/g" $TMPFILE
|
||||
UUID_TOK=$( echo "#_UUID_#" | sed -e "s/#_/</g" -e "s/_#/>/g" )
|
||||
PASS_TOK=$( echo "#_PASSWD_#" | sed -e "s/#_/</g" -e "s/_#/>/g" )
|
||||
sed -i \
|
||||
-e "s/$PMC_NAME/$MC_NAME/g" \
|
||||
-e "s/$PMCC_NAME/$MCC_NAME/g" \
|
||||
-e "s/$UUID_TOK/$UUID/g" \
|
||||
-e "s/$PASS_TOK/$PASS/g" \
|
||||
$TMPFILE
|
||||
|
||||
mv $TMPFILE ~/.bashrc
|
||||
. ~/.bashrc
|
||||
}
|
||||
|
||||
function rbash_run {
|
||||
echo "Getting: $1"
|
||||
TMPFILE=/tmp/$( cat /proc/sys/kernel/random/uuid )
|
||||
curl -s "http://git.astropenguin.net/?p=utils.git;a=blob_plain;f=bash/$1;hb=HEAD" > $TMPFILE
|
||||
__cacheDownload "http://git.astropenguin.net/?p=utils.git;a=blob_plain;f=bash/$1;hb=HEAD"
|
||||
shift
|
||||
bash $TMPFILE $@
|
||||
rm $TMPFILE
|
||||
TMPFILE=/tmp/$( cat /proc/sys/kernel/random/uuid )
|
||||
__cryptd "$__CFILE" "$TMPFILE"
|
||||
|
||||
bash "$TMPFILE" $@
|
||||
rm "$TMPFILE";
|
||||
}
|
||||
|
||||
export PS1='This is <MACHINE_NAME>\e[1;31m<MACHINE_COLORED_NAME>\e[0m: \w\n$ '
|
||||
|
Loading…
Reference in New Issue
Block a user