mirror of
https://github.com/myvesta/vesta
synced 2025-08-20 05:14:10 -07:00
v-change-wordpress-admin-passwords: enhance admin reassignment logic to handle default user selection
This commit is contained in:
parent
bf54a85a51
commit
cdf10aede1
1 changed files with 9 additions and 1 deletions
|
@ -59,9 +59,14 @@ ADMIN_LIST_CSV=$(eval "$RUN")
|
||||||
|
|
||||||
[ -z "$ADMIN_LIST_CSV" ] && { echo "No administrator accounts found."; exit 0; }
|
[ -z "$ADMIN_LIST_CSV" ] && { echo "No administrator accounts found."; exit 0; }
|
||||||
|
|
||||||
|
DEFAULT_USER=""
|
||||||
|
|
||||||
printf "%-6s %-20s %s\n" "ID" "Username" "Email"
|
printf "%-6s %-20s %s\n" "ID" "Username" "Email"
|
||||||
echo "$ADMIN_LIST_CSV" | while IFS=',' read -r PID PLOGIN PEMAIL; do
|
echo "$ADMIN_LIST_CSV" | while IFS=',' read -r PID PLOGIN PEMAIL; do
|
||||||
printf "%-6s %-20s %s\n" "$PID" "$PLOGIN" "$PEMAIL"
|
printf "%-6s %-20s %s\n" "$PID" "$PLOGIN" "$PEMAIL"
|
||||||
|
if [ "$PID" = "1" ]; then
|
||||||
|
DEFAULT_USER="$PLOGIN"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
echo
|
echo
|
||||||
|
@ -84,11 +89,14 @@ while IFS=',' read -r ID LOGIN EMAIL; do
|
||||||
echo "Cannot delete the only administrator account."
|
echo "Cannot delete the only administrator account."
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
DEFAULT_USER="${OTHER_USERS[0]}"
|
if [ "$DEFAULT_USER" = "" ]; then
|
||||||
|
DEFAULT_USER="${OTHER_USERS[0]}"
|
||||||
|
fi
|
||||||
echo "Available admin usernames for reassignment: ${OTHER_USERS[*]}"
|
echo "Available admin usernames for reassignment: ${OTHER_USERS[*]}"
|
||||||
while true; do
|
while true; do
|
||||||
read -r -p "Reassign content to which username? [default: $DEFAULT_USER] " REASSIGN < /dev/tty
|
read -r -p "Reassign content to which username? [default: $DEFAULT_USER] " REASSIGN < /dev/tty
|
||||||
REASSIGN=${REASSIGN:-$DEFAULT_USER}
|
REASSIGN=${REASSIGN:-$DEFAULT_USER}
|
||||||
|
DEFAULT_USER=$REASSIGN
|
||||||
if printf '%s\n' "${OTHER_USERS[@]}" | grep -qx "$REASSIGN"; then
|
if printf '%s\n' "${OTHER_USERS[@]}" | grep -qx "$REASSIGN"; then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue