diff options
author | Philipp Hemmelmayr <fips.hem@gmail.com> | 2017-12-10 20:16:21 +0100 |
---|---|---|
committer | Pavan Jadhaw <pavanjadhaw96@gmail.com> | 2017-12-10 19:16:21 +0000 |
commit | e802862b35ea51e915be3f4e1da91c8f0139691e (patch) | |
tree | d50b40ef11a5ed1ee8309ad95c8c90218eebaed3 | |
parent | 5b2378200b566cd7a78401d077cf073ce2be5f27 (diff) |
Added random image of dir when a dir is passed (#6)
If the user passes a directory when updating via-u <dir> then this code selects a random file from the directory and uses it instead.
This is useful so one can update the lock image on boot and have a random image every reboot (Adds variety)
-rwxr-xr-x | lock.sh | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -197,8 +197,15 @@ case "$1" in mkdir -p "$folder" fi + # get random file in dir if passed argument is a dir + user_input=$2 + if [ -d $user_input ]; then + user_input=($user_input/*) + user_input=${user_input[RANDOM % ${#user_input[@]}]} + fi + # get user image - cp "$2" "$user_image" + cp "$user_input" "$user_image" if [ ! -f $user_image ]; then echo "Please specify the path to the image you would like to use" exit 1 |