From 53155d55874ff17bf960929767c94ae265b9a700 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=9F=E9=85=8C=20=E9=B5=AC=E5=85=84?= Date: Tue, 24 Nov 2015 15:56:43 +0800 Subject: [PATCH] test for uuidgen --- bash/bashrc/rbashrc | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/bash/bashrc/rbashrc b/bash/bashrc/rbashrc index aaf75fc..3345681 100644 --- a/bash/bashrc/rbashrc +++ b/bash/bashrc/rbashrc @@ -110,9 +110,17 @@ function __cacheDownload { fi } +function __uuid { + if [ -x uuidgen ]; then + uuidgen + else + cat /proc/sys/kernel/random/uuid + fi +} + function rbash_upgrade { echo "Updating the .bashrc" - TMPFILE=/tmp/$( cat /proc/sys/kernel/random/uuid ) + TMPFILE=/tmp/$( __uuid ) curl -s "http://git.astropenguin.net/?p=utils.git;a=blob_plain;f=bash/bashrc/rbashrc;hb=HEAD" > $TMPFILE if [ -z "$1" ]; then @@ -123,8 +131,8 @@ function rbash_upgrade { MCC_NAME=$2 fi - UUID=$( cat /proc/sys/kernel/random/uuid ) - PASS=$( cat /proc/sys/kernel/random/uuid ) + UUID=$( __uuid ) + PASS=$( __uuid ) PMC_NAME=$( echo "#_MACHINE_NAME_#" | sed -e "s/#_//g" ) PMCC_NAME=$( echo "#_MACHINE_COLORED_NAME_#" | sed -e "s/#_//g" ) UUID_TOK=$( echo "#_UUID_#" | sed -e "s/#_//g" ) @@ -144,7 +152,7 @@ function rbash_run { echo "Getting: $1" __cacheDownload "http://git.astropenguin.net/?p=utils.git;a=blob_plain;f=bash/$1;hb=HEAD" shift - TMPFILE=/tmp/$( cat /proc/sys/kernel/random/uuid ) + TMPFILE=/tmp/$( __uuid ) __cryptd "$__CFILE" "$TMPFILE" bash "$TMPFILE" $@ @@ -166,7 +174,7 @@ function __ns { echo " $1" __cacheDownload "http://git.astropenguin.net/?p=utils.git;a=blob_plain;f=bash/bashrc/$FPATH;hb=HEAD" shift - TMPFILE=/tmp/$( cat /proc/sys/kernel/random/uuid ) + TMPFILE=/tmp/$( __uuid ) __cryptd "$__CFILE" "$TMPFILE" . $TMPFILE rm $TMPFILE