update Lagrange trust store format

It changed as of v1.6.0:
https://github.com/skyjake/lagrange/releases/tag/v1.6.0
393f6b682c

Changes to `lagrange/generate-trust-store.sh` were erroneously included
in the previous commit.
This commit is contained in:
nervuri 2021-09-16 17:55:02 +00:00
parent d38a774479
commit 52c5365b18
Signed by: nervuri
GPG Key ID: C4769EEA7BA61672
2 changed files with 20 additions and 11 deletions

View File

@ -1,16 +1,17 @@
# Instructions for Lagrange
Lagrange's trust store is `~/.config/lagrange/trusted.txt` on GNU/Linux systems.
As of v1.6.0 (2021-07-26), Lagrange's trust store is `~/.config/lagrange/trusted.2.txt` on GNU/Linux and BSD systems.
You can replace it with the generated `trusted.txt`, or merge them using the provided script:
You can replace it with the generated `trusted.2.txt`, or merge them using the provided script:
```
# First a test run:
./merge-trust-stores.sh ~/.config/lagrange/trusted.txt
./merge-trust-stores.sh ~/.config/lagrange/trusted.2.txt
# The entries in ~/.config/lagrange/trusted.txt that are not included in the
# The entries in Lagrange's trust store that are not in the
# script-generated trust store will appear at the end of the output.
# If it looks ok, then run:
./merge-trust-stores.sh ~/.config/lagrange/trusted.txt > ~/.config/lagrange/trusted.txt
./merge-trust-stores.sh ~/.config/lagrange/trusted.2.txt > ~/.config/lagrange/trusted.2.txt
```
The script works for both the old `trusted.txt` and the new `trusted.2.txt`.

View File

@ -4,15 +4,23 @@ set -o errexit # (-e) exit immediately if any command has a non-zero exit statu
set -o nounset # (-u) don't accept undefined variables
#set -o xtrace # for debugging
if [ -z "${1:-}" ]; then
>&2 echo "The path to the user's trust store must be provided."
>&2 echo "The default on GNU/Linux is ~/.config/lagrange/trusted.txt"
input="${1:-}"
if [ -z "$input" ]; then
>&2 echo "The path to Lagrange's trust store must be provided."
>&2 echo "The default on GNU/Linux is ~/.config/lagrange/trusted.2.txt"
exit 1
fi
dir="$(dirname "$0")" # directory where this script is
trust_store=$(cat "$dir/trusted.txt") # script-generated trust store
# Read the script-generated trust store.
# If input ends with "trusted.txt", then use the old trust store format.
if echo "$input" | grep -q trusted\\.txt$; then
trust_store=$(cat "$dir/trusted.txt")
else
trust_store=$(cat "$dir/trusted.2.txt")
fi
# Loop through user's trust store.
while read -r line; do
@ -24,7 +32,7 @@ while read -r line; do
trust_store="$trust_store\n$line"
fi
done < "${1:-}"
done < "$input"
# Output to stdout.
echo "$trust_store"