#62716 : Corrections et améliorations ftpadmin.sh
This commit is contained in:
parent
5cd6a6f046
commit
d6c39be117
|
@ -59,30 +59,32 @@ log_msg() {
|
||||||
|
|
||||||
get_user_login_by_UID() {
|
get_user_login_by_UID() {
|
||||||
uid=$1
|
uid=$1
|
||||||
grep "$uid" /etc/passwd | awk -F : "{if (\$3==$uid) print \$1}"
|
grep "$uid" /etc/passwd | awk -F : '{if ($3==$uid) print $1}'
|
||||||
}
|
}
|
||||||
|
|
||||||
list_accounts_by_UID() {
|
list_accounts_by_UID() {
|
||||||
uid=$1
|
uid=$1
|
||||||
|
|
||||||
|
# Remove # and empty lines
|
||||||
|
ftp_users=$(grep -v -E '^[[:blank:]]*(#.*)*$' "$VPASSWD_PATH")
|
||||||
|
|
||||||
while IFS=$'\n' read -r line;
|
for line in $ftp_users; do
|
||||||
do
|
line_uid="$(echo "$line" | cut -d":" -f3)"
|
||||||
line_uid="$(echo "$line" | cut -d":" -f3)"
|
|
||||||
|
if [[ ! "$uid" ]] || [[ "$line_uid" == "$uid" ]]; then
|
||||||
if [[ ! "$uid" ]] || [[ "$line_uid" == "$uid" ]]; then
|
username=$(get_user_login_by_UID "$line_uid")
|
||||||
username="$(get_user_login_by_UID "$line_uid")"
|
account=$(echo "$line" | cut -d":" -f1)
|
||||||
account="$(echo "$line" | cut -d":" -f1)"
|
path=$(echo "$line" | cut -d":" -f6)
|
||||||
path="$(echo "$line" | cut -d":" -f6)"
|
size="inconnue"
|
||||||
size="$(du -s "$path" | cut -f 1)"
|
# Check output of daily "du" cron job
|
||||||
#modif="$(cat $path/.lastmodified)"
|
# (set by ansible-roles/packweb-apache/tasks/main.yml)
|
||||||
# Passage en minuscule ?
|
if [ -r "$path/.size" ]; then
|
||||||
#account="$(echo $account | tr '[A-Z]' '[a-z]')"
|
size=$(cat "$path/.size")
|
||||||
#path="$(echo $path | tr '[A-Z]' '[a-z]')"
|
fi
|
||||||
|
#modif="$(cat $path/.lastmodified)"
|
||||||
echo "$username:$account:$path:$size${modif:+:$modif}"
|
echo "$username:$account:$path:$size${modif:+:$modif}"
|
||||||
|
fi
|
||||||
fi
|
done
|
||||||
done < "$VPASSWD_PATH"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
add_account() {
|
add_account() {
|
||||||
|
|
Loading…
Reference in a new issue