|
Directory : /scripts2/ |
#!/bin/bash
USER=$1
USERDIR="/home/$USER"
WCOUT="27" #Length of "queued: 0
# status: stopped"
if ! [ "$1" ]; then
echo "MUST provide a username. EXITED."
exit 1
fi
if ! [ -d "$USERDIR" ]; then
echo "User DOES NOT EXIST. EXITED."
exit 2
fi
stop_on_ctrl_c() {
imunify-antivirus malware on-demand stop > /dev/null
echo "HALTED at scanning stage. EXITED."
exit 3
}
trap stop_on_ctrl_c SIGINT
echo "-- Scanning $USER --"
if imunify-antivirus malware on-demand start --path "$USERDIR" > /dev/null; then
echo "Scan started successfully..."
else
echo "^^^"
echo "Scan did not start successfully. See error output."
echo "COULD NOT scan. EXITED."
exit 4
fi
until [ $(imunify-antivirus malware on-demand status 2> /dev/null | wc -c) -eq "$WCOUT" ]
do
true
done
echo "-- Fetching number of infected files of $USER --"
LIMIT=$(imunify-antivirus malware user list | grep "$USER" | awk '{print $4}')
echo "-- Renaming infected files of $USER --"
imunify-antivirus malware malicious list --user "$USER" --limit $LIMIT \
| awk '{print $8}' | grep '^/' | grep -v '\.VIRUS$' \
| xargs -I % mv % %.VIRUS
echo "Success. DONE."