summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus@mullvad.net>2022-04-02 13:30:17 +0200
committerRasmus Dahlberg <rasmus@mullvad.net>2022-04-02 13:30:17 +0200
commit502dd20c30178782554fb35f7dad1c232860f8a4 (patch)
treed35504c410df20f78da0df9acc40d154ce9af584
parentdb025fc63557452bb6d3364428bce5c257e8af87 (diff)
add new-pad URL generator
-rwxr-xr-xscripts/new-pad40
1 files changed, 40 insertions, 0 deletions
diff --git a/scripts/new-pad b/scripts/new-pad
new file mode 100755
index 0000000..782eb36
--- /dev/null
+++ b/scripts/new-pad
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+set -euE
+trap 'bye $?' EXIT
+
+URL=https://pad.sigsum.org/p
+
+LETTERS="a-f"
+NUMBERS="0-9"
+GROUP_SEP="-"
+
+NUM_LETTERS=2
+NUM_NUMBERS=2
+
+function main() {
+ group_num=$1; shift
+
+ name=""
+ for i in `seq 1 $group_num`; do
+ name="$name$(new_group $LETTERS $NUM_LETTERS)"
+ name="$name$(new_group $NUMBERS $NUM_NUMBERS)"
+ name="$name$GROUP_SEP"
+ done
+
+ echo $URL/${name::-${#GROUP_SEP}}
+}
+
+function new_group() {
+ echo -n $(tr -dc $1 </dev/urandom | head -c $2)
+}
+
+function bye() {
+ if [[ $1 != 0 ]]; then
+ echo "Usage: new-pad NUM_GROUPS" >&2
+ fi
+
+ return $1
+}
+
+main $@