diff options
Diffstat (limited to 'lib')
| -rwxr-xr-x | lib/_ak_network_yggdrasil | 3 | ||||
| -rwxr-xr-x | lib/_ak_utils | 12 | ||||
| -rwxr-xr-x | lib/_ak_zblock | 15 | ||||
| -rwxr-xr-x | lib/_ak_zchain | 5 | 
4 files changed, 25 insertions, 10 deletions
| diff --git a/lib/_ak_network_yggdrasil b/lib/_ak_network_yggdrasil index a551cd6..27fc0c8 100755 --- a/lib/_ak_network_yggdrasil +++ b/lib/_ak_network_yggdrasil @@ -18,6 +18,7 @@  ### along with this program.  If not, see <http://www.gnu.org/licenses/>.  ###  source $AK_LIBDIR/_ak_log +source $AK_LIBDIR/_ak_utils  function _ak_network_yggdrasil_scan_full(){      # This scan is using HIA resources to scan the whole cjdns network for peers @@ -65,7 +66,7 @@ function _ak_network_yggdrasil_scan_full(){          count="$(( $count + 1 ))"          _ak_log_debug "Scanning [${count}/${max}] $ip..."          node_fs_path="$AK_ZPEERSDIR/ygg/$(echo -n $ip| sed 's/://g')" -        scan_ts="$(date -u +%s)" +        scan_ts="$(_ak_datetime_unix)"          if [ ! -d ${node_fs_path} ]          then              mkdir -p ${node_fs_path} diff --git a/lib/_ak_utils b/lib/_ak_utils index d437cb9..d9204e9 100755 --- a/lib/_ak_utils +++ b/lib/_ak_utils @@ -21,6 +21,18 @@ function _ak_datetime_unix(){      date -u +%s | tr -d '\n'  } +function _ak_datetime_unix_nanosecs(){ +    date -u +%s.%N | tr -d '\n' +} + +function _ak_datetime_human(){ +    date -u +%Y%m%d_%H%M%S +} + +function _ak_datetime_human_date_only(){ +    date -u +%Y%m%d +} +  function _ak_datetime_unix_to_human(){      if [ ! -z $1 ] && [ -n "$1" ] && [ "$(echo $1 | sed -e 's/[0-9]\{10\}//g')" == "" ]      then diff --git a/lib/_ak_zblock b/lib/_ak_zblock index b4a546b..1313127 100755 --- a/lib/_ak_zblock +++ b/lib/_ak_zblock @@ -20,6 +20,7 @@  #set -x  source $AK_LIBDIR/_ak_log  source $AK_LIBDIR/_ak_script +source $AK_LIBDIR/_ak_utils  source $AK_LIBDIR/_ak_gpg  source $AK_LIBDIR/_ak_html  source $AK_LIBDIR/_ak_ipfs @@ -452,7 +453,7 @@ function _ak_zblock_show(){  # }  function _ak_zblock_gen_html(){ -    time_started=$(date -u +%s.%N) +    time_started=$(_ak_datetime_unix_nanosecs)      ss=$(echo $time_started | cut -d '.' -f 1)      nss=$(echo $time_started | cut -d '.' -f 2)      # Check if there are enough arguments @@ -475,11 +476,11 @@ function _ak_zblock_gen_html(){      _ak_zblock_show "$1" | jq > $arg      _ak_generate_html_header > zblock-$1.html      _ak_generate_html_zblock $arg >> zblock-$1.html -    time_ended=$(date -u +%s.%N) +    time_ended=$(_ak_datetime_unix_nanosecs)      se=$(echo $time_ended | cut -d '.' -f 1)      nse=$(echo $time_ended | cut -d '.' -f 2)      printf '    <hr>\n' >> zblock-$1.html -    printf '    <footer>Generated by %s on %s in %s.' "$PROGRAM" "$(datehuman)" "$(( $se - $ss ))">> zblock-$1.html +    printf '    <footer>Generated by %s on %s in %s.' "$PROGRAM" "$(_ak_datetime_human)" "$(( $se - $ss ))">> zblock-$1.html      if [ $nse -lt $nss ]      then          printf '%s seconds</footer>\n' "$(( 1$nse - $nss ))" >> zblock-$1.html @@ -591,7 +592,7 @@ function _ak_zblock_repack(){      PREVIOUS="$zblock_to_repack_at"      _ak_log_debug "Previous: $PREVIOUS"      # We create a block of json like this: -    printf '{"timestamp":"%s","action":"%s","data":"%s","detach":"%s","gpg":"%s","previous":"%s"}' $(date -u +%s) $ACTION $MESSAGE_HASH $MESSAGE_SIGNATURE $GPG_PUB_KEY $PREVIOUS > block +    printf '{"timestamp":"%s","action":"%s","data":"%s","detach":"%s","gpg":"%s","previous":"%s"}' $(_ak_datetime_unix) $ACTION $MESSAGE_HASH $MESSAGE_SIGNATURE $GPG_PUB_KEY $PREVIOUS > block      BLOCK="block"      BLOCK_SIG=$BLOCK".asc"      # We have a block now, so we sign it @@ -614,7 +615,7 @@ function _ak_zblock_repack(){      # Optional or extending with      # python send_as_ak_tx $ZBLOCK      # or for "offline" use -    archivaltime="$(date -u +%s)" +    archivaltime="$(_ak_datetime_unix)"      echo "${archivaltime} $(cat $AK_ZLATEST)" >> $AK_ZLATEST_HISTORY      echo $ZBLOCK > $AK_ZLATEST      _ak_ipfs_name_publish zchain /ipfs/$ZBLOCK #> /dev/null 2>&1 @@ -694,7 +695,7 @@ function _ak_zblock_pack(){              # Acquire last block of information, to chain this one with previous posted              PREVIOUS="$(cat $AK_ZLATEST)"              # We create a block of json like this: -            printf '{"timestamp":"%s","action":"%s","data":"%s","detach":"%s","gpg":"%s","previous":"%s"}' "$(date -u +%s)" "$ACTION" "$MESSAGE_HASH" "$MESSAGE_SIGNATURE" "$GPG_PUB_KEY" "$PREVIOUS" > block +            printf '{"timestamp":"%s","action":"%s","data":"%s","detach":"%s","gpg":"%s","previous":"%s"}' "$(_ak_datetime_unix)" "$ACTION" "$MESSAGE_HASH" "$MESSAGE_SIGNATURE" "$GPG_PUB_KEY" "$PREVIOUS" > block              BLOCK="block"              BLOCK_SIG="${BLOCK}.asc"              # We have a block now, so we sign it @@ -717,7 +718,7 @@ function _ak_zblock_pack(){          # Optional or extending with          # python send_as_ak_tx $ZBLOCK          # or for "offline" use -        archivaltime="$(date -u +%s)" +        archivaltime="$(_ak_datetime_unix)"          echo "${archivaltime} $(cat $AK_ZLATEST)" >> $AK_ZLATEST_HISTORY          echo $ZBLOCK > $AK_ZLATEST          _ak_ipfs_name_publish zchain /ipfs/$ZBLOCK > /dev/null 2>&1 diff --git a/lib/_ak_zchain b/lib/_ak_zchain index d015afd..547e773 100755 --- a/lib/_ak_zchain +++ b/lib/_ak_zchain @@ -17,6 +17,7 @@  ### You should have received a copy of the GNU General Public License  ### along with this program.  If not, see <http://www.gnu.org/licenses/>.  ### +source $AK_LIBDIR/_ak_utils  source $AK_LIBDIR/_ak_log  source $AK_LIBDIR/_ak_ipfs  source $AK_LIBDIR/_ak_zblock @@ -48,7 +49,7 @@ function _ak_zchain_reset(){      if [ $? -eq 0 ]      then          _ak_log_info "Archive the previous AK_ZLATEST" -        _ak_ipfs_files_cp /zlatest /zarchive/$(date -u +%s)-$(_ak_ipfs_files_stat /zlatest | head -n 1) +        _ak_ipfs_files_cp /zlatest /zarchive/$(_ak_datetime_unix)-$(_ak_ipfs_files_stat /zlatest | head -n 1)          if [ $? -ne 0 ]          then              _ak_log_error "Failed to copy /zlatest to /zarchive" @@ -99,7 +100,7 @@ function _ak_zchain_rebase(){      _ak_ipfs_files_mkdir /zarchive      if [ $? != 0 ]; then echo "Folder already there"; fi      echo "Archive the previous ZLATEST" -    _ak_ipfs_files_cp /zlatest /zarchive/$(date -u +%s)-$(_ak_ipfs_files_stat /zlatest | head -n 1) +    _ak_ipfs_files_cp /zlatest /zarchive/$(_ak_datetime_unix)-$(_ak_ipfs_files_stat /zlatest | head -n 1)      if [ $? != 0 ]; then exit 1; fi      echo "Removing previous /zlatest entry"      _ak_ipfs_files_rm /zlatest | 
