improve shell script
This commit is contained in:
parent
6461102325
commit
801e4681fe
1 changed files with 7 additions and 7 deletions
|
|
@ -13,26 +13,26 @@ first_missing=$(
|
||||||
. as $root
|
. as $root
|
||||||
| $root.managed_clients[]
|
| $root.managed_clients[]
|
||||||
| select($root.hashes[.] | not)
|
| select($root.hashes[.] | not)
|
||||||
' $FILEPATH \
|
' "$FILEPATH" \
|
||||||
| head -n 1 \
|
| head -n 1 \
|
||||||
)
|
)
|
||||||
[ -z "$first_missing" ] && echo "Done" >&2 && exit 0
|
[ -z "$first_missing" ] && echo "Done" >&2 && exit 0
|
||||||
|
|
||||||
echo "Generating cerificate for $first_missing"
|
echo "Generating cerificate for $first_missing"
|
||||||
mkdir $tmp/$first_missing
|
mkdir "$tmp/$first_missing"
|
||||||
hash=$(
|
hash=$(
|
||||||
syncthing generate \
|
syncthing generate \
|
||||||
--config $tmp/$first_missing \
|
--config "$tmp/$first_missing" \
|
||||||
--data $tmp/$first_missing/data \
|
--data "$tmp/$first_missing/data" \
|
||||||
| grep -oP '(?<=device=)[A-Z0-9-]+' \
|
| grep -oP '(?<=device=)[A-Z0-9-]+' \
|
||||||
)
|
)
|
||||||
|
|
||||||
mkdir -p $PKI_PATH
|
mkdir -p "$PKI_PATH"
|
||||||
mv $tmp/$first_missing/cert.pem $PKI_PATH/$first_missing.cert
|
mv "$tmp/$first_missing/cert.pem" "$PKI_PATH/$first_missing.cert"
|
||||||
|
|
||||||
# Remove the file so agenix does not try to decrypt
|
# Remove the file so agenix does not try to decrypt
|
||||||
[ -f "$SECRETS_PATH/$first_missing.age" ] && rm "$SECRETS_PATH/$first_missing.age"
|
[ -f "$SECRETS_PATH/$first_missing.age" ] && rm "$SECRETS_PATH/$first_missing.age"
|
||||||
agenix -e $SECRETS_PATH/$first_missing.age < $tmp/$first_missing/key.pem
|
agenix -e "$SECRETS_PATH/$first_missing.age" < "$tmp/$first_missing/key.pem"
|
||||||
|
|
||||||
jq --arg client "$first_missing" \
|
jq --arg client "$first_missing" \
|
||||||
--arg hash "$hash" \
|
--arg hash "$hash" \
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue