Update install-mailcow-ubuntu.sh
This commit is contained in:
parent
ac4986692c
commit
7cfe5d018d
1 changed files with 44 additions and 4 deletions
|
@ -135,27 +135,67 @@ if ! is_step_completed "mailcow_installed"; then
|
|||
mkdir -p "$MAILCOW_DIR"
|
||||
chown dockeruser:dockeruser "$MAILCOW_DIR"
|
||||
|
||||
# Clone repository
|
||||
# Clone repository and set permissions
|
||||
su - dockeruser -c "cd /opt && git clone https://github.com/mailcow/mailcow-dockerized"
|
||||
chown -R dockeruser:dockeruser "$MAILCOW_DIR"
|
||||
fi
|
||||
|
||||
# Generate config if not already generated
|
||||
if [ ! -f "$MAILCOW_DIR/mailcow.conf" ]; then
|
||||
cd "$MAILCOW_DIR"
|
||||
echo "$MAILCOW_HOSTNAME" | ./generate_config.sh
|
||||
|
||||
# Make sure generate_config.sh is executable
|
||||
chmod +x generate_config.sh
|
||||
log_message "Made generate_config.sh executable"
|
||||
|
||||
# Debug: Show current directory and files
|
||||
log_message "Current directory: $(pwd)"
|
||||
log_message "Directory contents: $(ls -la)"
|
||||
|
||||
# Generate config as dockeruser
|
||||
log_message "Generating configuration with hostname: $MAILCOW_HOSTNAME"
|
||||
su - dockeruser -c "cd $MAILCOW_DIR && echo \"$MAILCOW_HOSTNAME\" | ./generate_config.sh"
|
||||
|
||||
# Verify config generation
|
||||
if [ ! -f "$MAILCOW_DIR/mailcow.conf" ]; then
|
||||
log_message "Error: mailcow.conf was not generated!"
|
||||
log_message "Attempting alternative generation method..."
|
||||
|
||||
# Alternative: Copy example config
|
||||
if [ -f "$MAILCOW_DIR/mailcow.conf.example" ]; then
|
||||
cp "$MAILCOW_DIR/mailcow.conf.example" "$MAILCOW_DIR/mailcow.conf"
|
||||
sed -i "s/MAILCOW_HOSTNAME=.*/MAILCOW_HOSTNAME=$MAILCOW_HOSTNAME/" "$MAILCOW_DIR/mailcow.conf"
|
||||
chown dockeruser:dockeruser "$MAILCOW_DIR/mailcow.conf"
|
||||
log_message "Created mailcow.conf from example template"
|
||||
else
|
||||
log_message "Critical: Could not find mailcow.conf.example"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Ask for manual configuration
|
||||
echo "Would you like to edit the mailcow configuration? (y/N)"
|
||||
read -n1 -r
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
nano mailcow.conf
|
||||
EDITOR=${EDITOR:-nano}
|
||||
$EDITOR "$MAILCOW_DIR/mailcow.conf"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Start Mailcow services
|
||||
# Start Mailcow services with proper ownership
|
||||
log_message "Starting Mailcow services..."
|
||||
chown -R dockeruser:dockeruser "$MAILCOW_DIR"
|
||||
su - dockeruser -c "cd $MAILCOW_DIR && docker compose pull && docker compose up -d"
|
||||
|
||||
# Verify services are running
|
||||
sleep 10
|
||||
if ! docker compose --project-directory "$MAILCOW_DIR" ps | grep -q "Up"; then
|
||||
log_message "Warning: Some containers may not be running properly"
|
||||
else
|
||||
log_message "Mailcow services started successfully"
|
||||
fi
|
||||
|
||||
save_checkpoint "mailcow_installed"
|
||||
fi
|
||||
|
||||
|
|
Loading…
Reference in a new issue