Add skip feature to mailcow admin password reset script
Added option to skip confirmation for resetting the mailcow admin account.
This commit is contained in:
parent
7fce984cac
commit
4732f568fa
@ -7,6 +7,12 @@ if [[ -z ${DBUSER} ]] || [[ -z ${DBPASS} ]] || [[ -z ${DBNAME} ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
SKIP_CONFIRM=false
|
||||||
|
if [[ "${1:-}" == "-y" || "${1:-}" == "--yes" ]]; then
|
||||||
|
SKIP_CONFIRM=true
|
||||||
|
shift # prevent $1 from bleeding into head -c${1:-16} below
|
||||||
|
fi
|
||||||
|
|
||||||
echo -n "Checking MySQL service... "
|
echo -n "Checking MySQL service... "
|
||||||
if [[ -z $(docker ps -qf name=mysql-mailcow) ]]; then
|
if [[ -z $(docker ps -qf name=mysql-mailcow) ]]; then
|
||||||
echo "failed"
|
echo "failed"
|
||||||
@ -15,8 +21,12 @@ if [[ -z $(docker ps -qf name=mysql-mailcow) ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
|
if [[ "$SKIP_CONFIRM" == "true" ]]; then
|
||||||
|
response="yes"
|
||||||
|
else
|
||||||
read -r -p "Are you sure you want to reset the mailcow administrator account? [y/N] " response
|
read -r -p "Are you sure you want to reset the mailcow administrator account? [y/N] " response
|
||||||
response=${response,,} # tolower
|
response=${response,,}
|
||||||
|
fi
|
||||||
if [[ "$response" =~ ^(yes|y)$ ]]; then
|
if [[ "$response" =~ ^(yes|y)$ ]]; then
|
||||||
echo -e "\nWorking, please wait..."
|
echo -e "\nWorking, please wait..."
|
||||||
random=$(</dev/urandom tr -dc _A-Z-a-z-0-9 2> /dev/null | head -c${1:-16})
|
random=$(</dev/urandom tr -dc _A-Z-a-z-0-9 2> /dev/null | head -c${1:-16})
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user