aboutsummaryrefslogtreecommitdiffhomepage
path: root/threadcat-write.sh
blob: 18b2d32deb54e70db48de8380888c9fcd653e3b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/bash

BOARD_NAME=$1
THREAD_NAME=$2
THREAD_BOARD_PATH="/opt/threadcat"

if [ -z "${THREAD_NAME}" ]; then
    THREAD_NAME=$BOARD_NAME
    BOARD_NAME=""
    THREAD_PATH="/opt/threadcat/$THREAD_NAME"
else
    THREAD_BOARD_PATH="/opt/threadcat/$BOARD_NAME"
    THREAD_PATH="/opt/threadcat/$BOARD_NAME/$THREAD_NAME"
fi


if [ ! -z "${THREAD_NAME}" ]; then
    cat - | ssh $THREADCAT_USER "umask 002 && mkdir -p $THREAD_BOARD_PATH && echo >> $THREAD_PATH && echo $THREADCAT_USER -- `date` >> $THREAD_PATH && cat - >> $THREAD_PATH"
    echo "Posted to $BOARD_NAME/$THREAD_NAME"
else
    echo You did not provide a thread name.
    echo USAGE: "cat YOURMESSAGE | threadcat write [BOARD] THREAD"
fi