mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-10-07 10:02:14 -04:00
- Add scripts/install-ubuntu.sh: installs Apache/MariaDB/PHP, downloads the latest stable release, configures the DB + Apache, and optionally sets up Let's Encrypt SSL (interactive or via env vars). - Add .github/workflows/install-script-test.yml: runs the installer in a fresh Ubuntu container and sanity-checks the result. - Document the installer in INSTALL.md. - Harden the script: identifier-safe DB_NAME, quote/pipe rejection in passwords, correct 'Candidate: (none)' PPA detection, keep unix_socket root auth when no root password is set, select the .zip release asset, and use the SSL domain as the public hostname for allowedHostnames. Based on the latest master CI (build-release.yml / deploy-pr.yml left as-is).
136 lines
4.7 KiB
YAML
136 lines
4.7 KiB
YAML
name: Install Script Test
|
|
|
|
on:
|
|
push:
|
|
paths:
|
|
- 'scripts/install-ubuntu.sh'
|
|
- '.github/workflows/install-script-test.yml'
|
|
pull_request:
|
|
paths:
|
|
- 'scripts/install-ubuntu.sh'
|
|
- '.github/workflows/install-script-test.yml'
|
|
workflow_dispatch:
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
|
cancel-in-progress: true
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
install-test:
|
|
name: Test Install Script (${{ matrix.scenario }})
|
|
runs-on: ubuntu-22.04
|
|
timeout-minutes: 30
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- scenario: default
|
|
db_pass: ''
|
|
- scenario: custom-password
|
|
db_pass: 'TestPass123!'
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Make install script executable
|
|
run: chmod +x scripts/install-ubuntu.sh
|
|
|
|
- name: Run install script
|
|
env:
|
|
DB_PASS: ${{ matrix.db_pass }}
|
|
run: |
|
|
set -o pipefail
|
|
echo "Running install script with scenario: ${{ matrix.scenario }}"
|
|
sudo -E bash scripts/install-ubuntu.sh 2>&1 | tee install-output.log
|
|
echo "Install completed successfully"
|
|
|
|
- name: Wait for services to stabilize
|
|
run: sleep 10
|
|
|
|
- name: Verify Apache is running
|
|
run: |
|
|
echo "Checking Apache status..."
|
|
sudo systemctl status apache2 --no-pager
|
|
sudo systemctl is-active apache2
|
|
|
|
- name: Verify MariaDB is running
|
|
run: |
|
|
echo "Checking MariaDB status..."
|
|
sudo systemctl status mariadb --no-pager
|
|
sudo systemctl is-active mariadb
|
|
|
|
- name: Verify Apache HTTP response
|
|
run: |
|
|
echo "Testing HTTP response on port 80..."
|
|
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost/)
|
|
echo "HTTP Response Code: $HTTP_CODE"
|
|
if [ "$HTTP_CODE" = "200" ] || [ "$HTTP_CODE" = "302" ]; then
|
|
echo "Apache is responding correctly"
|
|
elif [ "$HTTP_CODE" = "500" ]; then
|
|
echo "HTTP 500 - Application error. Checking .env configuration..."
|
|
# Never print secret values (password, encryption key) to the log;
|
|
# show only non-secret keys and confirm the sensitive ones are present.
|
|
sudo cat /var/www/ospos/.env 2>/dev/null | grep -E "database\.default\.(hostname|database|username)|CI_ENVIRONMENT" | head -10
|
|
sudo grep -q '^encryption\.key=.' /var/www/ospos/.env 2>/dev/null && echo "encryption.key is set" || echo "WARNING: encryption.key is NOT set"
|
|
sudo cat /var/www/ospos/writable/logs/*.log 2>/dev/null | tail -20 || true
|
|
curl -s -L http://localhost/ | head -50
|
|
exit 1
|
|
else
|
|
echo "Unexpected HTTP code: $HTTP_CODE"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Verify OSPOS login page
|
|
run: |
|
|
echo "Checking OSPOS login page..."
|
|
# Follow redirects (-L): the root path may 302 to the login route, so
|
|
# fetch the final page to actually see the login form.
|
|
curl -s -L http://localhost/ | grep -qi "login\|password\|username" && echo "Login page content found" || {
|
|
echo "Login page verification failed"
|
|
curl -s -L http://localhost/ | head -50
|
|
exit 1
|
|
}
|
|
|
|
- name: Verify database exists
|
|
env:
|
|
DB_PASS: ${{ matrix.db_pass != '' && matrix.db_pass || '' }}
|
|
run: |
|
|
echo "Verifying database..."
|
|
|
|
# Extract the generated password from install output if using default
|
|
if [ -z "${{ matrix.db_pass }}" ]; then
|
|
GENERATED_PASS=$(grep -oP 'Database Password: \K[^\s]+' install-output.log || true)
|
|
if [ -n "$GENERATED_PASS" ]; then
|
|
DB_PASS="$GENERATED_PASS"
|
|
fi
|
|
fi
|
|
|
|
# Check database exists
|
|
sudo mysql -u root -e "SHOW DATABASES LIKE 'ospos';" | grep -q ospos && echo "Database 'ospos' exists" || {
|
|
echo "Database 'ospos' not found"
|
|
sudo mysql -u root -e "SHOW DATABASES;"
|
|
exit 1
|
|
}
|
|
|
|
# Check tables exist
|
|
TABLE_COUNT=$(sudo mysql -u root ospos -e "SHOW TABLES;" | wc -l)
|
|
echo "Found $TABLE_COUNT tables in database"
|
|
if [ "$TABLE_COUNT" -gt 5 ]; then
|
|
echo "Database tables verified"
|
|
else
|
|
echo "Not enough tables found"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Upload install log
|
|
uses: actions/upload-artifact@v4
|
|
if: always()
|
|
with:
|
|
name: install-log-${{ matrix.scenario }}
|
|
path: install-output.log
|
|
retention-days: 7 |