-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathjournalnet
More file actions
34 lines (24 loc) · 959 Bytes
/
journalnet
File metadata and controls
34 lines (24 loc) · 959 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env bash
RESET='\033[0m'
BOLD_WHITE='\033[1;37m'
version="1.0"
printf "journalNet $version\n"
visitors_count=$(grep -o "[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+" /var/log/journalnet.log | sort | uniq | wc -l)
printf "IP Visitor Counter: ${BOLD_WHITE}$visitors_count${RESET}\n"
#Space for an printf or echo create a empty line between the visitors counter and the first line of the journal.
read arg
read mnickname
read mmessage
read mcontact
read guestbook
[ -z "$arg" ] && exit 0
if [ -n "$mmessage" ]; then
echo -e "$(echo Name: $mnickname) $(echo '\n')$(echo Contact: $mcontact) $(echo '\n')$(echo Message: $mmessage) $(echo '\n')$(date +"%d/%m/%Y %T")$(echo '\n')" >> /var/log/journalnet_messages.log
elif [ -n "$guestbook" ]; then
echo -e "$(echo '\n')$(cat /var/log/journalnet_messages.log)"
elif [ -d "/home/$arg" ] && [ -e "/home/$arg/.journal" ]; then
cat /home/$arg/.journal
else
printf "User not found.\n"
exit 1
fi