WIP rearchitecture code

This commit is contained in:
dig 2021-09-26 15:50:12 +02:00
parent e78d76e4a4
commit 43618effba
1 changed files with 15 additions and 9 deletions

View File

@ -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 $@