remove bunkchat scripts #2
6 changed files with 10 additions and 117 deletions
16
bunkdeck
16
bunkdeck
|
@ -1,17 +1,12 @@
|
||||||
#!/bin/sh -e
|
#!/bin/sh -e
|
||||||
|
|
||||||
sessionname=bunkdeck
|
sessionname=bunkdeck
|
||||||
heedPane="bunkdeck:0.0"
|
heedPane=bunkdeck:0.0
|
||||||
proclaimPane="bunkdeck:0.1"
|
proclaimPane=bunkdeck:0.1
|
||||||
shellPane="bunkdeck:0.2"
|
shellPane=bunkdeck:0.2
|
||||||
|
|
||||||
isExistingDeck () {
|
isExistingDeck () {
|
||||||
# format `-F '#S' # formats the result as just the session name`
|
if tmux has -t $sessionname ; then
|
||||||
# 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
|
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
return 1
|
return 1
|
||||||
|
@ -19,7 +14,8 @@ isExistingDeck () {
|
||||||
}
|
}
|
||||||
|
|
||||||
attachToDeck () {
|
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 () {
|
startNewDeck () {
|
||||||
|
|
16
heed
16
heed
|
@ -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
|
|
49
install.sh
49
install.sh
|
@ -1,50 +1,5 @@
|
||||||
#!/bin/sh -e
|
#!/bin/sh -e
|
||||||
|
|
||||||
installtarget=/usr/local/bin
|
|
||||||
chatlogdir=/var/log/bunkchat
|
|
||||||
chatlog=chat.log
|
|
||||||
|
|
||||||
chattrfailed() {
|
# pull in bunkchat
|
||||||
set +e
|
# run bunkchat install script
|
||||||
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
|
|
||||||
|
|
35
proclaim
35
proclaim
|
@ -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
|
|
|
@ -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 is comprised of these lil things:
|
||||||
* `bunkdeck` - run this command to start the interface
|
* `bunkdeck` - run this command to start the interface
|
||||||
* `proclaim` - post in chat
|
* `bunkchat` - the actual chat functionality [git](https://git.bunk.computer/bunk/bunkchat)
|
||||||
* `heed` - read the chat
|
|
||||||
* `scry` - read the old chat
|
|
||||||
|
|
||||||
on the server, these are all installed in `/usr/local/bin` so everyone can run them
|
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
|
||||||
|
|
||||||
|
|
4
scry
4
scry
|
@ -1,4 +0,0 @@
|
||||||
#!/bin/sh -e
|
|
||||||
chatlog=/var/log/bunkchat/chat.log
|
|
||||||
|
|
||||||
less $chatlog
|
|
Loading…
Reference in a new issue