Compare commits

..

1 Commits

Author SHA1 Message Date
8e5ffdfa85 feat: initial version
Some checks failed
Test Stalwart Installation Action / Installation with Admin Password (pull_request) Failing after 21s
Test Stalwart Installation Action / Error Handling Tests (pull_request) Successful in 21s
Test Stalwart Installation Action / Full Configuration (Domains + Users) (pull_request) Failing after 24s
Test Stalwart Installation Action / Basic Installation (No Config) (pull_request) Successful in 49s
Test Stalwart Installation Action / Test on Ubuntu ubuntu-20.04 (pull_request) Has been cancelled
Test Stalwart Installation Action / Test on Ubuntu ubuntu-22.04 (pull_request) Has been cancelled
Test Stalwart Installation Action / Test on Ubuntu ubuntu-24.04 (pull_request) Has been cancelled
Test Stalwart Installation Action / Test Summary (pull_request) Has been cancelled
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
2026-02-14 23:41:56 -05:00
2 changed files with 126 additions and 28 deletions

View File

@@ -26,6 +26,11 @@ jobs:
uses: ./ uses: ./
# No inputs - should install with defaults # No inputs - should install with defaults
- name: Wait for service to fully start
run: |
echo "Waiting for Stalwart to fully initialize..."
sleep 15
- name: Verify Stalwart service is running - name: Verify Stalwart service is running
run: | run: |
sleep 10 # Give service time to start sleep 10 # Give service time to start
@@ -92,27 +97,37 @@ jobs:
with: with:
admin_password: 'TestPassword123!@#' admin_password: 'TestPassword123!@#'
- name: Wait for service to fully start
run: |
echo "Waiting for Stalwart to fully initialize..."
sleep 15
- name: Verify service is running - name: Verify service is running
run: | run: |
sleep 10
# Check if systemd is available
if command -v systemctl >/dev/null 2>&1 && systemctl --version >/dev/null 2>&1; then
sudo systemctl status stalwart --no-pager || true
fi
# Check process # Check process
if ! pgrep -x stalwart >/dev/null; then if ! pgrep -x stalwart >/dev/null; then
echo "::error::Stalwart process is not running" echo "::error::Stalwart process is not running"
echo "Process list:"
ps aux | grep stalwart || true ps aux | grep stalwart || true
echo "PID file:"
cat /var/run/stalwart.pid 2>/dev/null || echo "No PID file"
echo "Logs:"
tail -50 /opt/stalwart/logs/*.log 2>/dev/null || echo "No logs"
exit 1 exit 1
fi fi
echo "✓ Stalwart is running" echo "✓ Stalwart is running"
- name: Test authentication with new password - name: Test authentication with new password
run: | run: |
# Wait for API # Wait for API to be ready
sleep 5 echo "Waiting for Stalwart API..."
for i in {1..30}; do
if curl -sf http://localhost:8080/login >/dev/null 2>&1; then
echo "✓ API is ready"
break
fi
sleep 2
done
# Try to authenticate with new password # Try to authenticate with new password
RESPONSE=$(curl -sf -X POST http://localhost:8080/api/authenticate \ RESPONSE=$(curl -sf -X POST http://localhost:8080/api/authenticate \
@@ -123,6 +138,7 @@ jobs:
if [ -z "$TOKEN" ]; then if [ -z "$TOKEN" ]; then
echo "::error::Failed to authenticate with new password" echo "::error::Failed to authenticate with new password"
echo "Response: $RESPONSE"
exit 1 exit 1
fi fi
@@ -179,26 +195,37 @@ jobs:
} }
] ]
- name: Wait for service to fully start
run: |
echo "Waiting for Stalwart to fully initialize..."
sleep 15
- name: Verify service is running - name: Verify service is running
run: | run: |
sleep 10
# Check if systemd is available
if command -v systemctl >/dev/null 2>&1 && systemctl --version >/dev/null 2>&1; then
sudo systemctl status stalwart --no-pager || true
fi
# Check process # Check process
if ! pgrep -x stalwart >/dev/null; then if ! pgrep -x stalwart >/dev/null; then
echo "::error::Stalwart process is not running" echo "::error::Stalwart process is not running"
echo "Process list:"
ps aux | grep stalwart || true ps aux | grep stalwart || true
echo "PID file:"
cat /var/run/stalwart.pid 2>/dev/null || echo "No PID file"
echo "Logs:"
tail -50 /opt/stalwart/logs/*.log 2>/dev/null || true
exit 1 exit 1
fi fi
echo "✓ Stalwart is running" echo "✓ Stalwart is running"
- name: Verify admin password was changed - name: Verify admin password was changed
run: | run: |
sleep 5 # Wait for API to be ready
echo "Waiting for Stalwart API..."
for i in {1..30}; do
if curl -sf http://localhost:8080/login >/dev/null 2>&1; then
echo "✓ API is ready"
break
fi
sleep 2
done
RESPONSE=$(curl -sf -X POST http://localhost:8080/api/authenticate \ RESPONSE=$(curl -sf -X POST http://localhost:8080/api/authenticate \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
@@ -208,6 +235,7 @@ jobs:
if [ -z "$TOKEN" ]; then if [ -z "$TOKEN" ]; then
echo "::error::Failed to authenticate with admin password" echo "::error::Failed to authenticate with admin password"
echo "Response: $RESPONSE"
exit 1 exit 1
fi fi
@@ -332,24 +360,37 @@ jobs:
with: with:
admin_password: 'TestPassword123' admin_password: 'TestPassword123'
- name: Wait for service to fully start
run: |
echo "Waiting for Stalwart to fully initialize..."
sleep 15
- name: Verify installation - name: Verify installation
run: | run: |
sleep 10
# Check if process is running # Check if process is running
if pgrep -x stalwart >/dev/null; then if pgrep -x stalwart >/dev/null; then
echo "✓ Stalwart running on ${{ matrix.os }}" echo "✓ Stalwart running on ${{ matrix.os }}"
else else
echo "::error::Stalwart not running on ${{ matrix.os }}" echo "::error::Stalwart not running on ${{ matrix.os }}"
ps aux | grep stalwart || true ps aux | grep stalwart || true
tail -50 /opt/stalwart/logs/*.log 2>/dev/null || true
exit 1 exit 1
fi fi
- name: Test API accessibility - name: Test API accessibility
run: | run: |
sleep 5 # Wait for API to be ready
curl -sf http://localhost:8080/login >/dev/null echo "Waiting for API on ${{ matrix.os }}..."
echo "✓ API accessible on ${{ matrix.os }}" for i in {1..30}; do
if curl -sf http://localhost:8080/login >/dev/null 2>&1; then
echo "✓ API accessible on ${{ matrix.os }}"
exit 0
fi
sleep 2
done
echo "::error::API not accessible on ${{ matrix.os }}"
tail -50 /opt/stalwart/logs/*.log 2>/dev/null || true
exit 1
# Summary job # Summary job
test-summary: test-summary:

View File

@@ -127,11 +127,16 @@ main() {
# Create service file # Create service file
say "🚀 Starting service..." say "🚀 Starting service..."
if [ "${_os}" = "linux" ]; then if [ "${_os}" = "linux" ]; then
local _issystemdlinux=$(command -v systemctl) # Check if systemd is actually running (not just installed)
if [ -n "$_issystemdlinux" ]; then if command -v systemctl >/dev/null 2>&1 && systemctl --version >/dev/null 2>&1 && [ -d /run/systemd/system ]; then
say "Using systemd to manage service..."
create_service_linux_systemd "$_dir" create_service_linux_systemd "$_dir"
else elif command -v service >/dev/null 2>&1; then
say "Using init.d to manage service..."
create_service_linux_initd "$_dir" create_service_linux_initd "$_dir"
else
say "No service manager detected, starting manually..."
start_service_manually "$_dir" "${_account}"
fi fi
elif [ "${_os}" = "macos" ]; then elif [ "${_os}" = "macos" ]; then
create_service_macos "$_dir" create_service_macos "$_dir"
@@ -171,9 +176,61 @@ AmbientCapabilities=CAP_NET_BIND_SERVICE
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
EOF EOF
systemctl daemon-reload
systemctl enable stalwart.service if systemctl daemon-reload 2>/dev/null && \
systemctl restart stalwart.service systemctl enable stalwart.service 2>/dev/null && \
systemctl restart stalwart.service 2>/dev/null; then
say "✓ Service started with systemd"
else
say "⚠ systemd commands failed, falling back to manual start"
start_service_manually "$_dir" "stalwart"
fi
}
# Function to start service manually when systemd is not available
start_service_manually() {
local _dir="$1"
local _account="$2"
say "Starting Stalwart manually in background..."
# Create a simple wrapper script
cat > /usr/local/bin/stalwart-service <<EOF
#!/bin/bash
set -e
# Increase file descriptor limit
ulimit -n 65536
# Change to service user and run stalwart
if command -v runuser >/dev/null 2>&1; then
exec runuser -u ${_account} -- ${_dir}/bin/stalwart --config=${_dir}/etc/config.toml
elif command -v su >/dev/null 2>&1; then
exec su -s /bin/bash ${_account} -c "${_dir}/bin/stalwart --config=${_dir}/etc/config.toml"
else
# Fallback: run as current user
exec ${_dir}/bin/stalwart --config=${_dir}/etc/config.toml
fi
EOF
chmod +x /usr/local/bin/stalwart-service
# Start in background and redirect output
nohup /usr/local/bin/stalwart-service > ${_dir}/logs/stalwart.out 2>&1 &
local _pid=$!
# Save PID for later management
echo $_pid > /var/run/stalwart.pid
# Give it a moment to start
sleep 2
# Verify it's running
if kill -0 $_pid 2>/dev/null; then
say "✓ Stalwart started successfully (PID: $_pid)"
else
say "⚠ Warning: Stalwart may not have started successfully"
fi
} }
create_service_linux_initd() { create_service_linux_initd() {