public
nobgit
read
NobMail
Based on mailcow: dockerized
Languages
Repository composition by tracked source files.
PHP
49%
JavaScript
35%
HTML
9%
CSS
4%
Shell
2%
Python
1%
Lua
0%
Perl
0%
Ruby
0%
SCSS
0%
Create file
Wiki Documentation
Clone
https://nobgit.com/orgs/nobgit/nobmail.git
ssh://[email protected]:2222/orgs/nobgit/nobmail.git
Commit
Add skip feature to mailcow admin password reset script
Added option to skip confirmation for resetting the mailcow admin account.
4732f568
helper-scripts/mailcow-reset-admin.sh | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
Diff
diff --git a/helper-scripts/mailcow-reset-admin.sh b/helper-scripts/mailcow-reset-admin.sh
index ea8a4a43..823391f8 100755
--- a/helper-scripts/mailcow-reset-admin.sh
+++ b/helper-scripts/mailcow-reset-admin.sh
@@ -7,6 +7,12 @@ if [[ -z ${DBUSER} ]] || [[ -z ${DBPASS} ]] || [[ -z ${DBNAME} ]]; then
exit 1
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... "
if [[ -z $(docker ps -qf name=mysql-mailcow) ]]; then
echo "failed"
@@ -15,8 +21,12 @@ if [[ -z $(docker ps -qf name=mysql-mailcow) ]]; then
fi
echo "OK"
-read -r -p "Are you sure you want to reset the mailcow administrator account? [y/N] " response
-response=${response,,} # tolower
+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
+ response=${response,,}
+fi
if [[ "$response" =~ ^(yes|y)$ ]]; then
echo -e "\nWorking, please wait..."
random=$(</dev/urandom tr -dc _A-Z-a-z-0-9 2> /dev/null | head -c${1:-16})