annotate scripts/add_udpmsg4_chat @ 1020:bace90f3f318 draft

[scripts/add_udpmsg4_chat] [security] .gitignore seckey (thanks Ivo)
author d3v11 <d3v11@d3v11.ano>
date Sat, 06 Oct 2012 22:06:10 +0000
parents 115f429c1758
children 9c22f6ca8b1f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1004
115f429c1758 [scripts/add_udpmsg4_chat] new script for chanserv
d3v11 <d3v11@d3v11.ano>
parents:
diff changeset
1 #!/bin/sh
1020
bace90f3f318 [scripts/add_udpmsg4_chat] [security] .gitignore seckey (thanks Ivo)
d3v11 <d3v11@d3v11.ano>
parents: 1004
diff changeset
2 if [ -z $5 ]; then
bace90f3f318 [scripts/add_udpmsg4_chat] [security] .gitignore seckey (thanks Ivo)
d3v11 <d3v11@d3v11.ano>
parents: 1004
diff changeset
3 echo "Usage: $0 <chat> <owner> <pubkey> <seckey> <topic>" >&2; exit 255
1004
115f429c1758 [scripts/add_udpmsg4_chat] new script for chanserv
d3v11 <d3v11@d3v11.ano>
parents:
diff changeset
4 fi
115f429c1758 [scripts/add_udpmsg4_chat] new script for chanserv
d3v11 <d3v11@d3v11.ano>
parents:
diff changeset
5 chat="$1"
115f429c1758 [scripts/add_udpmsg4_chat] new script for chanserv
d3v11 <d3v11@d3v11.ano>
parents:
diff changeset
6 owner="$2"
115f429c1758 [scripts/add_udpmsg4_chat] new script for chanserv
d3v11 <d3v11@d3v11.ano>
parents:
diff changeset
7 pubkey="$3"
115f429c1758 [scripts/add_udpmsg4_chat] new script for chanserv
d3v11 <d3v11@d3v11.ano>
parents:
diff changeset
8 seckey="$4"
1020
bace90f3f318 [scripts/add_udpmsg4_chat] [security] .gitignore seckey (thanks Ivo)
d3v11 <d3v11@d3v11.ano>
parents: 1004
diff changeset
9 topic="$5"
1004
115f429c1758 [scripts/add_udpmsg4_chat] new script for chanserv
d3v11 <d3v11@d3v11.ano>
parents:
diff changeset
10
115f429c1758 [scripts/add_udpmsg4_chat] new script for chanserv
d3v11 <d3v11@d3v11.ano>
parents:
diff changeset
11 if [ "$(echo -n "${chat/chat\//}" | tr -d 'A-Za-z0-9_-' | wc -c | tr -d ' \t')" != 0 ]; then
115f429c1758 [scripts/add_udpmsg4_chat] new script for chanserv
d3v11 <d3v11@d3v11.ano>
parents:
diff changeset
12 echo "udpmsg4 chats do not allow funny chars." >&2; exit 255
115f429c1758 [scripts/add_udpmsg4_chat] new script for chanserv
d3v11 <d3v11@d3v11.ano>
parents:
diff changeset
13 fi
115f429c1758 [scripts/add_udpmsg4_chat] new script for chanserv
d3v11 <d3v11@d3v11.ano>
parents:
diff changeset
14 if ((`echo -n "${chat/chat\//}" | wc -c` > 32)); then
115f429c1758 [scripts/add_udpmsg4_chat] new script for chanserv
d3v11 <d3v11@d3v11.ano>
parents:
diff changeset
15 echo "udpmsg4 chats cannot be greater than 32 chars." >&2; exit 255
115f429c1758 [scripts/add_udpmsg4_chat] new script for chanserv
d3v11 <d3v11@d3v11.ano>
parents:
diff changeset
16 fi
115f429c1758 [scripts/add_udpmsg4_chat] new script for chanserv
d3v11 <d3v11@d3v11.ano>
parents:
diff changeset
17 if [ "$(echo "$chat" | head -c5)" != chat/ ]; then
115f429c1758 [scripts/add_udpmsg4_chat] new script for chanserv
d3v11 <d3v11@d3v11.ano>
parents:
diff changeset
18 echo "udpmsg4 chats start with chat/." >&2; exit 255
115f429c1758 [scripts/add_udpmsg4_chat] new script for chanserv
d3v11 <d3v11@d3v11.ano>
parents:
diff changeset
19 fi
115f429c1758 [scripts/add_udpmsg4_chat] new script for chanserv
d3v11 <d3v11@d3v11.ano>
parents:
diff changeset
20 if ((`echo -n "$pubkey$seckey" | tr -d 'a-fA-F0-9' | wc -c | tr -d ' \t'` != 0)); then
115f429c1758 [scripts/add_udpmsg4_chat] new script for chanserv
d3v11 <d3v11@d3v11.ano>
parents:
diff changeset
21 echo "nacl keys are hex chars." >&2; exit 255
115f429c1758 [scripts/add_udpmsg4_chat] new script for chanserv
d3v11 <d3v11@d3v11.ano>
parents:
diff changeset
22 fi
115f429c1758 [scripts/add_udpmsg4_chat] new script for chanserv
d3v11 <d3v11@d3v11.ano>
parents:
diff changeset
23 if ((`echo -n "$pubkey$seckey" | wc -c` != 128)); then
115f429c1758 [scripts/add_udpmsg4_chat] new script for chanserv
d3v11 <d3v11@d3v11.ano>
parents:
diff changeset
24 echo "nacl keys are 64 chars." >&2; exit 255
115f429c1758 [scripts/add_udpmsg4_chat] new script for chanserv
d3v11 <d3v11@d3v11.ano>
parents:
diff changeset
25 fi
115f429c1758 [scripts/add_udpmsg4_chat] new script for chanserv
d3v11 <d3v11@d3v11.ano>
parents:
diff changeset
26
115f429c1758 [scripts/add_udpmsg4_chat] new script for chanserv
d3v11 <d3v11@d3v11.ano>
parents:
diff changeset
27 fullchat=db/udpmsg4_chat/${chat/chat\//}
115f429c1758 [scripts/add_udpmsg4_chat] new script for chanserv
d3v11 <d3v11@d3v11.ano>
parents:
diff changeset
28 mkdir -p $fullchat || exit 1
115f429c1758 [scripts/add_udpmsg4_chat] new script for chanserv
d3v11 <d3v11@d3v11.ano>
parents:
diff changeset
29 mkdir -p $fullchat/@ || exit 1
115f429c1758 [scripts/add_udpmsg4_chat] new script for chanserv
d3v11 <d3v11@d3v11.ano>
parents:
diff changeset
30 echo -n "$owner" >"$fullchat/@/owner"
115f429c1758 [scripts/add_udpmsg4_chat] new script for chanserv
d3v11 <d3v11@d3v11.ano>
parents:
diff changeset
31 echo -n "$pubkey" >"$fullchat/@/pubkey"
115f429c1758 [scripts/add_udpmsg4_chat] new script for chanserv
d3v11 <d3v11@d3v11.ano>
parents:
diff changeset
32 echo -n "$seckey" >"$fullchat/@/seckey"
1020
bace90f3f318 [scripts/add_udpmsg4_chat] [security] .gitignore seckey (thanks Ivo)
d3v11 <d3v11@d3v11.ano>
parents: 1004
diff changeset
33 echo -n "$topic" >"$fullchat/@/topic"
bace90f3f318 [scripts/add_udpmsg4_chat] [security] .gitignore seckey (thanks Ivo)
d3v11 <d3v11@d3v11.ano>
parents: 1004
diff changeset
34 echo -n "seckey" >"$fullchat/@/.gitignore"