Last active
October 4, 2023 10:06
-
-
Save st3b1t/e99d7a8f7a55b221a3d69da881318d5b to your computer and use it in GitHub Desktop.
waits for a file to have read group permissions before running a certain command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Copyright @st3b1t 2023 | |
# | |
# usage: ./wait-for-chmod.sh /path/to/file/to/check <next-command> | |
# | |
# example, check bitcoin cookie file is readable by group: | |
# ./wait-for-chmod.sh /home/bitcoin/.bitcoin/.cookie <next-command> | |
# | |
set -e | |
perm='-rw-r-----' | |
file="$1" | |
shift | |
cmd="$@" | |
#set -x | |
until [[ `stat -c %A $file | cut -c5 ` = 'r' ]]; do | |
>&2 echo "Group permissions is not readable..." | |
echo `stat -c %A $file` | |
sleep 1 | |
done | |
>&2 echo "Group permissions is readable" | |
exec $cmd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment