Check if user input empty username

This commit is contained in:
2025-01-30 19:37:40 +09:00
parent b4d525926a
commit 8c46cfebe5
3 changed files with 15 additions and 1 deletions
+5
View File
@@ -176,7 +176,12 @@ install_site() {
fi fi
done done
while true; do
read -p "Enter admin username: " ADMIN_USER read -p "Enter admin username: " ADMIN_USER
if validate_username "$ADMIN_USER"; then
break
fi
done
read -s -p "Enter password (press Enter for random password): " ADMIN_PASSWORD read -s -p "Enter password (press Enter for random password): " ADMIN_PASSWORD
echo echo
+8
View File
@@ -14,4 +14,12 @@ validate_email() {
return 1 return 1
fi fi
return 0 return 0
}
validate_username() {
if [[ -z "$1" ]] || [[ "$1" =~ ^[[:space:]]*$ ]]; then
echo -e "${RED}Username cannot be empty${NC}"
return 1
fi
return 0
} }
+2 -1
View File
@@ -7,7 +7,8 @@ wpcli() {
echo "Waiting for MariaDB to be ready..." echo "Waiting for MariaDB to be ready..."
while [ "$(docker inspect --format='{{.State.Health.Status}}' db_${DOMAIN})" != "healthy" ]; do while [ "$(docker inspect --format='{{.State.Health.Status}}' db_${DOMAIN})" != "healthy" ]; do
echo "MariaDB is not healthy yet. Retrying..." #echo "MariaDB is not healthy yet. Retrying..."
echo "Loading..."
sleep 5 sleep 5
done done