mybin

my ~/bin
git clone https://a3nm.net/git/mybin/
Log | Files | Refs | README

duuid (400B)


      1 #!/bin/bash
      2 
      3 # get disk uuid from volume name
      4 
      5 VOLUME="$1"
      6 HOST=$(hostname | cut -d'.' -f1)
      7 FOLDER="$HOME/config/private/duuid"
      8 
      9 # hack: search first in local file, then in all files
     10 ID="$(grep "^$VOLUME " $FOLDER/$HOST $FOLDER/* | cut -d' ' -f2 | head -1)"
     11 
     12 if [[ -z "$ID" ]]
     13 then
     14   >&2 echo "no volume $VOLUME"
     15   # just in case
     16   echo "/dev/zero"
     17   exit 2
     18 fi
     19 
     20 echo "/dev/disk/by-uuid/$ID"
     21 
     22 exit 0
     23