WIP rearchitecture code
This commit is contained in:
parent
e78d76e4a4
commit
43618effba
24
chat/chat
24
chat/chat
|
@ -1,11 +1,17 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
path="/var/log/users"
|
send()
|
||||||
|
{
|
||||||
if [ "$1" = "root" ] || [ "$1" = "" ]; then
|
user=$(echo $1 | awk -F@ '{print $1}')
|
||||||
file=$(cat $HOME/.log/last.txt)
|
vm=$(echo $1 | awk -F@ '{print $2}')
|
||||||
else
|
echo "Send to ${user}@${vm}"
|
||||||
file=$(cat /home/$1/.log/last.txt)
|
p2vm $vm exec 'echo -e "\\n'$c_white_bg$c_black$USER'@'$HOSTNAME$c_ $(date +%D\ %T)' '$c_cyan${@:2}$c_'" >> /home/'$user'/.chat' -sy
|
||||||
fi
|
}
|
||||||
|
repl()
|
||||||
tail -f $file
|
{
|
||||||
|
read -re -p "chat> " mess
|
||||||
|
echo -e "$c_white_bg$c_black$USER@$HOSTNAME$c_ $(date +%D\ %T) $c_cyan$mess$c_"
|
||||||
|
send $1 $mess
|
||||||
|
repl $1
|
||||||
|
}
|
||||||
|
[[ -z $2 ]] && repl $1 || send $@
|
||||||
|
|
Loading…
Reference in New Issue