Compare commits
1 Commits
df0c36922a
...
8e5ffdfa85
| Author | SHA1 | Date | |
|---|---|---|---|
| 8e5ffdfa85 |
83
.github/workflows/test.yml
vendored
83
.github/workflows/test.yml
vendored
@@ -26,6 +26,11 @@ jobs:
|
||||
uses: ./
|
||||
# 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
|
||||
run: |
|
||||
sleep 10 # Give service time to start
|
||||
@@ -92,27 +97,37 @@ jobs:
|
||||
with:
|
||||
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
|
||||
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
|
||||
if ! pgrep -x stalwart >/dev/null; then
|
||||
echo "::error::Stalwart process is not running"
|
||||
echo "Process list:"
|
||||
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
|
||||
fi
|
||||
echo "✓ Stalwart is running"
|
||||
|
||||
- name: Test authentication with new password
|
||||
run: |
|
||||
# Wait for API
|
||||
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
|
||||
|
||||
# Try to authenticate with new password
|
||||
RESPONSE=$(curl -sf -X POST http://localhost:8080/api/authenticate \
|
||||
@@ -123,6 +138,7 @@ jobs:
|
||||
|
||||
if [ -z "$TOKEN" ]; then
|
||||
echo "::error::Failed to authenticate with new password"
|
||||
echo "Response: $RESPONSE"
|
||||
exit 1
|
||||
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
|
||||
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
|
||||
if ! pgrep -x stalwart >/dev/null; then
|
||||
echo "::error::Stalwart process is not running"
|
||||
echo "Process list:"
|
||||
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
|
||||
fi
|
||||
echo "✓ Stalwart is running"
|
||||
|
||||
- name: Verify admin password was changed
|
||||
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 \
|
||||
-H "Content-Type: application/json" \
|
||||
@@ -208,6 +235,7 @@ jobs:
|
||||
|
||||
if [ -z "$TOKEN" ]; then
|
||||
echo "::error::Failed to authenticate with admin password"
|
||||
echo "Response: $RESPONSE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -332,24 +360,37 @@ jobs:
|
||||
with:
|
||||
admin_password: 'TestPassword123'
|
||||
|
||||
- name: Wait for service to fully start
|
||||
run: |
|
||||
echo "Waiting for Stalwart to fully initialize..."
|
||||
sleep 15
|
||||
|
||||
- name: Verify installation
|
||||
run: |
|
||||
sleep 10
|
||||
|
||||
# Check if process is running
|
||||
if pgrep -x stalwart >/dev/null; then
|
||||
echo "✓ Stalwart running on ${{ matrix.os }}"
|
||||
else
|
||||
echo "::error::Stalwart not running on ${{ matrix.os }}"
|
||||
ps aux | grep stalwart || true
|
||||
tail -50 /opt/stalwart/logs/*.log 2>/dev/null || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Test API accessibility
|
||||
run: |
|
||||
sleep 5
|
||||
curl -sf http://localhost:8080/login >/dev/null
|
||||
# Wait for API to be ready
|
||||
echo "Waiting for API 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
|
||||
test-summary:
|
||||
|
||||
@@ -127,11 +127,16 @@ main() {
|
||||
# Create service file
|
||||
say "🚀 Starting service..."
|
||||
if [ "${_os}" = "linux" ]; then
|
||||
local _issystemdlinux=$(command -v systemctl)
|
||||
if [ -n "$_issystemdlinux" ]; then
|
||||
# Check if systemd is actually running (not just installed)
|
||||
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"
|
||||
else
|
||||
elif command -v service >/dev/null 2>&1; then
|
||||
say "Using init.d to manage service..."
|
||||
create_service_linux_initd "$_dir"
|
||||
else
|
||||
say "No service manager detected, starting manually..."
|
||||
start_service_manually "$_dir" "${_account}"
|
||||
fi
|
||||
elif [ "${_os}" = "macos" ]; then
|
||||
create_service_macos "$_dir"
|
||||
@@ -171,9 +176,61 @@ AmbientCapabilities=CAP_NET_BIND_SERVICE
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
systemctl daemon-reload
|
||||
systemctl enable stalwart.service
|
||||
systemctl restart stalwart.service
|
||||
|
||||
if systemctl daemon-reload 2>/dev/null && \
|
||||
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() {
|
||||
|
||||
Reference in New Issue
Block a user