diff --git a/bunkdeck b/bunkdeck index 6de1c9a..590c05f 100755 --- a/bunkdeck +++ b/bunkdeck @@ -1,17 +1,12 @@ #!/bin/sh -e sessionname=bunkdeck -heedPane="bunkdeck:0.0" -proclaimPane="bunkdeck:0.1" -shellPane="bunkdeck:0.2" +heedPane=bunkdeck:0.0 +proclaimPane=bunkdeck:0.1 +shellPane=bunkdeck:0.2 isExistingDeck () { - # format `-F '#S' # formats the result as just the session name` - # filter `-f "{==:#S,${sessionname}}` # only returns sessions named $sessionname - # capture error and redirect - sessions=$(tmux list-sessions -F '#S' -f "#{==:#S,${sessionname}}" 2>/dev/null) - - if [ "${sessions}" = "${sessionname}" ] ; then + if tmux has -t $sessionname ; then return 0 else return 1 @@ -19,7 +14,8 @@ isExistingDeck () { } attachToDeck () { - tmux attach-session -t bunkdeck + # does not currently protect against nesting sessions (tmux does this for us) + tmux attach-session -d -t bunkdeck } startNewDeck () { diff --git a/heed b/heed deleted file mode 100755 index 9a6d241..0000000 --- a/heed +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh -e - -chatlog=/var/log/bunkchat/chat.log - -clear - -echo "╻ ╻┏━╸┏━╸╺┳┓ ┏┓ ╻ ╻┏┓╻╻┏ ┏━╸╻ ╻┏━┓╺┳╸" -echo "┣━┫┣╸ ┣╸ ┃┃ ╺━╸ ┣┻┓┃ ┃┃┗┫┣┻┓┃ ┣━┫┣━┫ ┃ " -echo "╹ ╹┗━╸┗━╸╺┻┛ ┗━┛┗━┛╹ ╹╹ ╹┗━╸╹ ╹╹ ╹ ╹ " -echo "Take heed, $USER! This is a group chat with everyone on the server!" -echo "You may post in chat with 'proclaim'!" -echo "You may view old chat with 'scry'!" -echo "----------------------------------" -echo - -tail -f $chatlog diff --git a/install.sh b/install.sh index c82315c..046586a 100755 --- a/install.sh +++ b/install.sh @@ -1,50 +1,5 @@ #!/bin/sh -e -installtarget=/usr/local/bin -chatlogdir=/var/log/bunkchat -chatlog=chat.log -chattrfailed() { - set +e - rm -rf $chatlogdir - echo - echo "ERROR: could not set append only attribute in ${chatlogdir}" - echo " does your filesystem support 'chattr +a' ?" - exit 1 -} - -prep() { - mkdir -p $chatlogdir - chmod 755 $chatlogdir - touch ${chatlogdir}/${chatlog} - chmod 666 ${chatlogdir}/${chatlog} - # if chattr +a not supported on this file system, catch error and clean up - chattr +a ${chatlogdir}/${chatlog} || chattrfailed -} - -install() { - cp proclaim heed scry $installtarget - chmod 755 ${installtarget}/proclaim - chmod 755 ${installtarget}/heed - chmod 755 ${installtarget}/scry - chown root:root ${installtarget}/proclaim - chown root:root ${installtarget}/heed - chown root:root ${installtarget}/scry - - echo "SUCCESS! bunkchat installed!" - exit 0 -} - -# check for root perms -if ! [ "$(id -u)" = 0 ]; then - echo "ERROR: please run install with root permission" >&2 - exit 1 -fi - -# if chat.log exists, skip prep -if [ -f ${chatlogdir}/${chatlog} ]; then - install -else - prep - install -fi +# pull in bunkchat +# run bunkchat install script diff --git a/proclaim b/proclaim deleted file mode 100755 index 1fd1777..0000000 --- a/proclaim +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -e - -# make username uppercase -username=$(echo "$USER" | tr '[:lower:]' '[:upper:]') -timezone=UTC -chatlog=/var/log/bunkchat/chat.log -prompt="" - -makeSlug () { - # make time and date - time=$(TZ=${timezone} date +%I:%M%p) - date=$(TZ=${timezone} date +%m/%d) - - # make name/time string - prompt="${username}-${date}-${time}" -} - -# enter bunkchat mode (clear the screen) -clear - -while true -do - echo "┏━┓┏━┓┏━┓┏━╸╻ ┏━┓╻┏┳┓ ┏┓ ╻ ╻┏┓╻╻┏ ┏━╸╻ ╻┏━┓╺┳╸" - echo "┣━┛┣┳┛┃ ┃┃ ┃ ┣━┫┃┃┃┃ ╺━╸ ┣┻┓┃ ┃┃┗┫┣┻┓┃ ┣━┫┣━┫ ┃ " - echo "╹ ╹┗╸┗━┛┗━╸┗━╸╹ ╹╹╹ ╹ ┗━┛┗━┛╹ ╹╹ ╹┗━╸╹ ╹╹ ╹ ╹ " - echo "Proclaim your musings, $USER! This is a group chat with everyone on the server!" - echo "You may view current chat with 'heed'!" - echo "You may view old chat with 'scry'!" - echo "----------------------------------" - printf "speak to the server: " - read -r text - makeSlug - echo "${prompt}: $text" >> $chatlog - clear -done diff --git a/readme.md b/readme.md index 5741545..2543c3a 100644 --- a/readme.md +++ b/readme.md @@ -6,11 +6,8 @@ tmux wraps some hand-rolled local chat scripts, and the`bunkdeck` command starts bunkdeck is comprised of these lil things: * `bunkdeck` - run this command to start the interface -* `proclaim` - post in chat -* `heed` - read the chat -* `scry` - read the old chat +* `bunkchat` - the actual chat functionality [git](https://git.bunk.computer/bunk/bunkchat) on the server, these are all installed in `/usr/local/bin` so everyone can run them -the file they all interact with, `/srv/bunkchat.txt` has permissions such that everyone can read and write to it - +the file they all interact with, `/var/log/bunkchat/chat.log` is append-only diff --git a/scry b/scry deleted file mode 100755 index 1fe2cdf..0000000 --- a/scry +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -e -chatlog=/var/log/bunkchat/chat.log - -less $chatlog