Compare commits
1 Commits
8e5ffdfa85
...
057cafab61
| Author | SHA1 | Date | |
|---|---|---|---|
| 057cafab61 |
@@ -13,10 +13,18 @@ source "${SCRIPT_DIR}/utils.sh"
|
|||||||
# Configuration
|
# Configuration
|
||||||
readonly STALWART_PATH="${STALWART_INSTALL_PATH:-/opt/stalwart}"
|
readonly STALWART_PATH="${STALWART_INSTALL_PATH:-/opt/stalwart}"
|
||||||
readonly API_URL="http://localhost:8080/api"
|
readonly API_URL="http://localhost:8080/api"
|
||||||
readonly DEFAULT_ADMIN_PASSWORD="changeme"
|
|
||||||
readonly MAX_RETRIES=60
|
readonly MAX_RETRIES=60
|
||||||
readonly RETRY_DELAY=2
|
readonly RETRY_DELAY=2
|
||||||
|
|
||||||
|
# Read the generated password from installation
|
||||||
|
DEFAULT_ADMIN_PASSWORD="changeme"
|
||||||
|
if [ -f "${STALWART_PATH}/.init_password" ]; then
|
||||||
|
DEFAULT_ADMIN_PASSWORD=$(cat "${STALWART_PATH}/.init_password")
|
||||||
|
# Clean up the password file for security
|
||||||
|
rm -f "${STALWART_PATH}/.init_password"
|
||||||
|
fi
|
||||||
|
readonly DEFAULT_ADMIN_PASSWORD
|
||||||
|
|
||||||
# Environment variables (passed from action.yml)
|
# Environment variables (passed from action.yml)
|
||||||
ADMIN_PASSWORD="${STALWART_ADMIN_PASSWORD:-}"
|
ADMIN_PASSWORD="${STALWART_ADMIN_PASSWORD:-}"
|
||||||
DOMAINS_JSON="${STALWART_DOMAINS:-}"
|
DOMAINS_JSON="${STALWART_DOMAINS:-}"
|
||||||
|
|||||||
@@ -114,9 +114,22 @@ main() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Run init
|
# Run init and capture the generated password
|
||||||
say "⚙️ Initializing Stalwart configuration..."
|
say "⚙️ Initializing Stalwart configuration..."
|
||||||
ignore $_dir/bin/stalwart --init "$_dir"
|
local _init_output
|
||||||
|
_init_output=$($_dir/bin/stalwart --init "$_dir" 2>&1)
|
||||||
|
echo "$_init_output"
|
||||||
|
|
||||||
|
# Extract the generated password from output
|
||||||
|
# Output format: "🔑 Your administrator account is 'admin' with password 'XXXXX'."
|
||||||
|
local _generated_password
|
||||||
|
_generated_password=$(echo "$_init_output" | grep -oP "with password '\K[^']+" || echo "")
|
||||||
|
|
||||||
|
# Save the generated password for configure.sh to use
|
||||||
|
if [ -n "$_generated_password" ]; then
|
||||||
|
echo "$_generated_password" > "$_dir/.init_password"
|
||||||
|
chmod 600 "$_dir/.init_password"
|
||||||
|
fi
|
||||||
|
|
||||||
# Set permissions
|
# Set permissions
|
||||||
say "🔐 Setting permissions..."
|
say "🔐 Setting permissions..."
|
||||||
|
|||||||
Reference in New Issue
Block a user