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 #!/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 $@