aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorColin Okay <colin@cicadas.surf>2022-08-15 07:28:58 -0500
committerColin Okay <colin@cicadas.surf>2022-08-15 07:28:58 -0500
commitb5a258652de9bf6b8f0c56e13720240e444bd93b (patch)
tree048b71666f51b7638a07a891d8f1edaa4d4f14da
parentd6f05e96cb5b139b1ea0ad7a166205d9e31c2440 (diff)
[add] toplevel threadcat script; [altered] command scripts to fit
-rwxr-xr-xthreadcat24
-rwxr-xr-xthreadcat-list.sh2
-rwxr-xr-xthreadcat-read.sh2
-rwxr-xr-xthreadcat-write.sh2
4 files changed, 27 insertions, 3 deletions
diff --git a/threadcat b/threadcat
new file mode 100755
index 0000000..0a5b7ad
--- /dev/null
+++ b/threadcat
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+THREADCAT_SUBCOMMAND=$1
+
+if [ -z "${THREADCAT_USER}" ]; then
+ echo The THREADCAT_USER environment variable is not set.
+fi
+
+if [ -z "${THREADCAT_SUBCOMMAND}" ]; then
+ echo USAGE: threadcat <COMMAND> [THREAD]
+ echo commands are:
+ echo " list lists threads, most recent first"
+ echo " read [THREAD] reads a thread, catting it to stdout"
+ echo " write [THREAD] posts to THREAD from stdin"
+ exit 0
+fi
+
+case "$THREADCAT_SUBCOMMAND" in
+ "list" ) threadcat-list.sh ;;
+ "read" ) threadcat-read.sh $2 ;;
+ "write" ) threadcat-write.sh $2 ;;
+ * ) echo Unknown subcommand $THREADCAT_SUBCOMMAND
+ echo commands are list, read, write;;
+esac
diff --git a/threadcat-list.sh b/threadcat-list.sh
index 420a9ff..89f490e 100755
--- a/threadcat-list.sh
+++ b/threadcat-list.sh
@@ -1,4 +1,4 @@
#!/bin/bash
-ssh $CICADAS_USER@cicadas.surf "ls -lt /opt/threadcat/" | awk '{ s = ""; for (i = 6; i <= 9; i++) s = s $i " "; print s }'
+ssh $THREADCAT_USER "ls -lt /opt/threadcat/" | awk '{ s = ""; for (i = 6; i <= 9; i++) s = s $i " "; print s }'
diff --git a/threadcat-read.sh b/threadcat-read.sh
index 031ccbe..517f57d 100755
--- a/threadcat-read.sh
+++ b/threadcat-read.sh
@@ -3,7 +3,7 @@
THREAD_NAME=$1
if [ ! -z "${THREAD_NAME}" ]; then
- ssh $CICADAS_USER@cicadas.surf "cat /opt/threadcat/$THREAD_NAME"
+ ssh $THREADCAT_USER "cat /opt/threadcat/$THREAD_NAME"
else
echo You did not provide a thread name.
echo USAGE: "threadcat read THREAD_NAME"
diff --git a/threadcat-write.sh b/threadcat-write.sh
index 78b436f..aff794b 100755
--- a/threadcat-write.sh
+++ b/threadcat-write.sh
@@ -3,7 +3,7 @@
THREAD_NAME=$1
if [ ! -z "${THREAD_NAME}" ]; then
- cat - | ssh $CICADAS_USER@cicadas.surf "umask 002 && echo `whoami` -- `date` >> /opt/threadcat/$THREAD_NAME && cat - >> /opt/threadcat/$THREAD_NAME"
+ cat - | ssh $THREADCAT_USER "umask 002 && echo `whoami` -- `date` >> /opt/threadcat/$THREAD_NAME && cat - >> /opt/threadcat/$THREAD_NAME"
echo Posted to $THREAD_NAME
else
echo You did not provide a thread name.