WIP rearchitecture code
This commit is contained in:
parent
e78d76e4a4
commit
43618effba
24
chat/chat
24
chat/chat
|
@ -1,11 +1,17 @@
|
|||
#!/bin/bash
|
||||
|
||||
path="/var/log/users"
|
||||
|
||||
if [ "$1" = "root" ] || [ "$1" = "" ]; then
|
||||
file=$(cat $HOME/.log/last.txt)
|
||||
else
|
||||
file=$(cat /home/$1/.log/last.txt)
|
||||
fi
|
||||
|
||||
tail -f $file
|
||||
send()
|
||||
{
|
||||
user=$(echo $1 | awk -F@ '{print $1}')
|
||||
vm=$(echo $1 | awk -F@ '{print $2}')
|
||||
echo "Send to ${user}@${vm}"
|
||||
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
|
||||
}
|
||||
repl()
|
||||
{
|
||||
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