penguin/utils

my env utils

commit 53155d55874ff17bf960929767c94ae265b9a700

author斟酌 鵬兄 <tgckpg@gmail.com>
date2015-11-24T07:56:43Z
subjecttest for uuidgen
commit 53155d55874ff17bf960929767c94ae265b9a700
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date:   2015-11-24T07:56:43Z

    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" -e "s/_#/>/g" )
     PMCC_NAME=$( echo "#_MACHINE_COLORED_NAME_#" | sed -e "s/#_/</g" -e "s/_#/>/g" )
     UUID_TOK=$( echo "#_UUID_#" | sed -e "s/#_/</g" -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