evoadmin-web/scripts/stats.sh
Patrick Marchand 547235ea7e Audited scripts/stats.sh
Shellcheck pass and code cleanup.

Set stricter error handling with sh options.

Removes the for loop and cat(1) in favor of directly calling the
file with cut(1) and piping the output to a while read loop. Read
https://github.com/koalaman/shellcheck/wiki/SC2002 for more info.

Adds proper variable globbing.

Removes the large block of commented code, if this turns out to be
necessary, we can add a condition check to the script instead of
uncommenting on a per case basis.
2018-11-29 17:25:13 +01:00

14 lines
227 B
Bash
Executable file

#!/bin/sh
set -o errexit
set -o nounset
#set -x
cut -d : -f 6 /etc/proftpd/vpasswd | while read -r dir; do
if [ -d "$dir" ]; then
du -s "$dir" | cut -f 1 > "$dir"/.size
chmod 644 "$dir"/.size
fi
done