# HG changeset patch # User Christophe Lincoln # Date 1481565210 -3600 # Node ID 16cb64fb7e1771115624eaab6e1e7d59727dd3b3 # Parent 0b0666832cb68aff8e1814facc8585915b9216ed tazu: add functions to check/clean users DB diff -r 0b0666832cb6 -r 16cb64fb7e17 tazu/tazu --- a/tazu/tazu Fri Sep 23 12:46:36 2016 +0300 +++ b/tazu/tazu Mon Dec 12 18:53:30 2016 +0100 @@ -2,7 +2,10 @@ # # TazU - SliTaz Users account utility # -# Copyright 2014 (C) SliTaz GNU/Linux - BSD License +# This tool is used to mange SliTaz users accounts on bugs.slitaz.org +# and scn.slitaz.org. It can also be used to admin TinyCM users DB. +# +# Copyright 2016 (C) SliTaz GNU/Linux - BSD License # Author: Christophe Lincoln # . /lib/libtaz.sh @@ -24,10 +27,12 @@ Commands: count Count all users list List all users + check Check accounts integrity Options: --admin Make user admin --del Delete a user + --clean check: clean users accounts EOT } @@ -52,11 +57,34 @@ separator for user in $(ls $people) do + if ! [ -f "$people/$user/account.conf" ]; then + echo -n "$(colorize 31 "$user")" + echo -e "\\033[16GCORRUPTED" && continue + fi . $people/$user/account.conf echo -n "$(colorize 34 "$user")" echo -e "\\033[16G${NAME}" done separator && newline ;; + check) + # Check accounts and auth file + newline + boldify "SliTaz accounts integrity" + separator + echo "$(colorize 33 "Checking account.conf files...")" + for user in $(ls $people) + do + if ! [ -f "$people/$user/account.conf" ]; then + echo -n "$(colorize 30 "$user")" + echo -e "\\033[16GMissing account.conf" + if [ "$clean" ]; then # --clean + rm -rf "${people}/${user}" + sed -i "/^${user}:/"d $authfile + fi + #else -- check empty VALUES + fi + done + separator && newline ;; *) # Handle general: --options case " $@ " in