comparison scripts/add_udpmsg4_chat @ 1004:115f429c1758 draft

[scripts/add_udpmsg4_chat] new script for chanserv
author d3v11 <d3v11@d3v11.ano>
date Sun, 02 Sep 2012 00:45:13 +0000
parents
children bace90f3f318
comparison
equal deleted inserted replaced
1003:c3bf76d62a4b 1004:115f429c1758
1 #!/bin/sh
2 if [ -z $3 ]; then
3 echo "Usage: $0 <chat> <owner> <pubkey> <seckey>" >&2; exit 255
4 fi
5 chat="$1"
6 owner="$2"
7 pubkey="$3"
8 seckey="$4"
9
10 if [ "$(echo -n "${chat/chat\//}" | tr -d 'A-Za-z0-9_-' | wc -c | tr -d ' \t')" != 0 ]; then
11 echo "udpmsg4 chats do not allow funny chars." >&2; exit 255
12 fi
13 if ((`echo -n "${chat/chat\//}" | wc -c` > 32)); then
14 echo "udpmsg4 chats cannot be greater than 32 chars." >&2; exit 255
15 fi
16 if [ "$(echo "$chat" | head -c5)" != chat/ ]; then
17 echo "udpmsg4 chats start with chat/." >&2; exit 255
18 fi
19 if ((`echo -n "$pubkey$seckey" | tr -d 'a-fA-F0-9' | wc -c | tr -d ' \t'` != 0)); then
20 echo "nacl keys are hex chars." >&2; exit 255
21 fi
22 if ((`echo -n "$pubkey$seckey" | wc -c` != 128)); then
23 echo "nacl keys are 64 chars." >&2; exit 255
24 fi
25
26 fullchat=db/udpmsg4_chat/${chat/chat\//}
27 mkdir -p $fullchat || exit 1
28 mkdir -p $fullchat/@ || exit 1
29 echo -n "$owner" >"$fullchat/@/owner"
30 echo -n "$pubkey" >"$fullchat/@/pubkey"
31 echo -n "$seckey" >"$fullchat/@/seckey"