Commit 99632759931138b75a0c377236b80bbe2042a18d
Support multiple config files for generating pages
cel committed on 9/27/2019, 7:51:52 PMParent: 4820fa19862722663667a28a0fb741b17c440cc5
Files changed
geninvitecodepage.sh | changed |
geninvitecodepages.sh | changed |
geninvitecodepaths.sh | changed |
geninvitecodepage.sh | ||
---|---|---|
@@ -1,11 +1,17 @@ | ||
1 | 1 … | #!/bin/sh |
2 | 2 … | invite_code=${1?invite_code} |
3 … | +config_file=${2:-config.ps} | |
4 … | +if [ ! -s "$config_file" ]; then | |
5 … | + printf "missing config file %s\n" "$config_file" >&2 | |
6 … | + exit 1 | |
7 … | +fi | |
8 … | + | |
3 | 9 … | invite_code="$(printf "%s" "$invite_code" | sed 's/\//\\\//g')" |
4 | -op_name="$(grep op_name config.ps | sed 's/.*\?(//; s/).*\?//; s/\//\\\//g')" | |
5 | -op_id="$(grep op_id config.ps | grep -o @.*ed25519 | sed 's/\//\\\//g')" | |
6 | -pub_name="$(grep pub_name config.ps | sed 's/.*\?(//; s/).*\?//; s/\//\\\//g')" | |
7 | -pub_id="$(grep pub_id config.ps | grep -o @.*ed25519 | sed 's/\//\\\//g')" | |
10 … | +op_name="$(grep op_name "$config_file" | sed 's/.*\?(//; s/).*\?//; s/\//\\\//g')" | |
11 … | +op_id="$(grep op_id "$config_file" | grep -o @.*ed25519 | sed 's/\//\\\//g')" | |
12 … | +pub_name="$(grep pub_name "$config_file" | sed 's/.*\?(//; s/).*\?//; s/\//\\\//g')" | |
13 … | +pub_id="$(grep pub_id "$config_file" | grep -o @.*ed25519 | sed 's/\//\\\//g')" | |
8 | 14 … | exec sed -e "s/{{invite_code}}/$invite_code/g" \ |
9 | 15 … | -e "s/{{op_name}}/$op_name/g" \ |
10 | 16 … | -e "s/{{op_id}}/$op_id/g" \ |
11 | 17 … | -e "s/{{pub_name}}/$pub_name/g" \ |
geninvitecodepages.sh | ||
---|---|---|
@@ -3,10 +3,10 @@ | ||
3 | 3 … | base=${2?base} |
4 | 4 … | mkdir -p "$dir" |
5 | 5 … | cd "$(dirname "$0")" |
6 | 6 … | test -s "$dir"/invite-letterhead.jpg || cp invite-letterhead.jpg "$dir"/ |
7 | -while read -r path invite | |
7 … | +while read -r path invite name | |
8 | 8 … | do |
9 | 9 … | mkdir -p "$(dirname "$dir/$path")" |
10 | - ./geninvitecodepage.sh "$invite" > "$dir/$path" | |
10 … | + ./geninvitecodepage.sh "$invite" "config${name:+-}$name.ps" > "$dir/$path" | |
11 | 11 … | echo "$base/$path" |
12 | 12 … | done |
geninvitecodepaths.sh | ||
---|---|---|
@@ -1,7 +1,13 @@ | ||
1 | 1 … | #!/bin/sh |
2 | 2 … | count=${1?count} |
3 | -pwgen -sAB 6 "$count" | sed "s/\(.\)\(.....\)/\1\/\2\.html/" | while read -r path | |
3 … | +size=${2:-6} | |
4 … | +name=$3 | |
5 … | +case "$size" in | |
6 … | + 6) pwgen -sAB 6 "$count" | sed "s/\(.\)\(.....\)/\1\/\2\.html/" ;; | |
7 … | + 10) pwgen -sAB 10 "$count" | sed "s/\(.\)\(.........\)/\1\/\2\.html/" ;; | |
8 … | + *) echo 'invalid length' >&2; exit 1;; | |
9 … | +esac | while read -r path | |
4 | 10 … | do |
5 | 11 … | invite="$(./geninvitecode.sh)" || exit 1 |
6 | - printf "%s\t%s\n" "$path" "$invite" | |
12 … | + printf "%s\t%s\t%s\n" "$path" "$invite" "$name" | |
7 | 13 … | done |
Built with git-ssb-web