-
-
Notifications
You must be signed in to change notification settings - Fork 365
Ubuntu 24 Installer rewrite #1201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
`setup.sh` and `start.sh` combined into a single script netalertx now starts and runs via systemd unit, can be started, stopped and restarted `systemctl start netalertx` `systemctl stop netalertx` `systemctl status netalertx` etc Logs to `journalctl` and output can be followed with `journalctl -f` Amalgamated chmods tuned chmods based on earlier feedback and discussion install script accepts command line parameter: - 'install' to continue and DELETE ALL! - 'update' to just update from GIT (keeps your db and settings) - 'start' to do nothing, leave install as-is (just run the start script, set up services etc) Please have a look, comments welcome :-)
WalkthroughIntroduces a new Ubuntu 24 installer at install/ubuntu24/install.sh, adds a systemd unit and Python requirements file, and removes legacy install/start scripts. The new script handles install/update/start flows, dependency setup, web server configuration, filesystem prep, environment persistence, and service management. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant InstallScript as install/ubuntu24/install.sh
participant APT as apt/apt-get
participant Py as Python venv/pip
participant Nginx as NGINX
participant PHP as PHP-FPM
participant Sysd as systemd (netalertx.service)
participant Server as NetAlertX server
User->>InstallScript: Run with mode (install | update | start)
InstallScript->>APT: Install system deps (nginx, php-*, etc.)
InstallScript->>Py: Create venv + pip install -r requirements.txt
InstallScript->>Nginx: Configure site, port, listen addr
InstallScript->>PHP: Ensure enabled/started
InstallScript->>InstallScript: Prepare dirs, tmpfs, permissions, configs
InstallScript->>Sysd: Write /etc/default/netalertx + enable/start unit
Sysd->>Server: ExecStart python3 ${INSTALL_DIR}/server
Server-->>Nginx: Serves UI/API via configured port
Note over InstallScript,Sysd: Modes control whether repo is cloned, updated, or just started
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
install/ubuntu24/requirements.txt (1)
25-25: Pin the aiofreepybox VCS dependency to a stable revision.Installing straight from the HEAD of
foreign-sub/aiofreepyboxmakes every installer run non‑deterministic and can suddenly break builds if that repo changes or disappears. Please lock it to a tag or commit SHA so that updates happen on your schedule.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
install/ubuntu24/install.sh(1 hunks)install/ubuntu24/install.ubuntu24.sh(0 hunks)install/ubuntu24/netalertx.service(1 hunks)install/ubuntu24/requirements.txt(1 hunks)install/ubuntu24/start.ubuntu24.sh(0 hunks)
💤 Files with no reviewable changes (2)
- install/ubuntu24/install.ubuntu24.sh
- install/ubuntu24/start.ubuntu24.sh
🧰 Additional context used
🪛 Shellcheck (0.11.0)
install/ubuntu24/install.sh
[warning] 24-24: SCRIPT_DIR appears unused. Verify use (or export if used externally).
(SC2034)
[warning] 120-120: Use "${var:?}" to ensure this never expands to /* .
(SC2115)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: docker_dev
| if [ -n "${PORT}" ]; then | ||
| echo "[INSTALL] Setting webserver to user-supplied port (${PORT})" | ||
| sed -i 's/listen 20211/listen '"${PORT}"'/g' "${NGINX_CONFIG_FILE}" | ||
| else | ||
| PORT=20211 | ||
| fi | ||
|
|
||
| # Change web interface address if set | ||
| if [ -n "${LISTEN_ADDR}" ]; then | ||
| echo "[INSTALL] Setting webserver to user-supplied address (${LISTEN_ADDR})" | ||
| sed -i -e 's/listen /listen '"${LISTEN_ADDR}":'/g' "${NGINX_CONFIG_FILE}" | ||
| else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the custom listen address/port rewriting to handle IPv6 safely.
install/ubuntu24/netalertx.conf ships with both listen 20211; and listen [::]:20211;. The current sed commands only touch the IPv4 directive, so a custom PORT leaves the IPv6 listener on 20211. Worse, when LISTEN_ADDR is set, the second sed rewrites the IPv6 line into listen <addr>:[::]:<port>, making nginx -t fail and aborting the installer. Please rewrite the substitutions so they update the IPv4 and IPv6 ports separately and only inject the custom address into the IPv4 listener.
Apply this diff:
# Use user-supplied port if set
if [ -n "${PORT}" ]; then
echo "[INSTALL] Setting webserver to user-supplied port (${PORT})"
- sed -i 's/listen 20211/listen '"${PORT}"'/g' "${NGINX_CONFIG_FILE}"
+ sed -i -E 's/^(\s*listen\s+)20211(.*)$/\1'"${PORT}"'\2/' "${NGINX_CONFIG_FILE}"
+ sed -i -E 's/^(\s*listen\s+)\[::\]:20211(.*)$/\1[::]:'"${PORT}"'\2/' "${NGINX_CONFIG_FILE}"
else
PORT=20211
fi
# Change web interface address if set
if [ -n "${LISTEN_ADDR}" ]; then
echo "[INSTALL] Setting webserver to user-supplied address (${LISTEN_ADDR})"
- sed -i -e 's/listen /listen '"${LISTEN_ADDR}":'/g' "${NGINX_CONFIG_FILE}"
+ sed -i -E 's/^(\s*listen\s+)[0-9]+(.*)$/\1'"${LISTEN_ADDR}:${PORT}"'\2/' "${NGINX_CONFIG_FILE}"
else
LISTEN_ADDR="0.0.0.0"
fi🤖 Prompt for AI Agents
In install/ubuntu24/install.sh around lines 217 to 228, the current sed
replacements modify listen directives too broadly causing the IPv6 line to be
left on the old port or to be mangled when LISTEN_ADDR is set; update the script
so: when PORT is provided, replace the exact "listen 20211;" and the exact
"listen [::]:20211;" separately so both IPv4 and IPv6 ports are updated; when
LISTEN_ADDR is provided, only replace the IPv4 directive "listen 20211;" with
"listen <LISTEN_ADDR>:<PORT>;" (do not prepend the address to the IPv6 "[::]"
line), and ensure sed patterns match the semicolon and brackets exactly and
properly quote/escape variables to avoid injecting into the IPv6 listener.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, only ships with listen 20211 so I'd say this is irrelevant.
|
No further comments :-) |
|
Really appreciate the help here @ingoratsdorf 🙏 going thru some private stuff still so energy is limited - can't say how happy it makes me seeing you and others help out 🙇 |
No problem at all. We all benefit from your work so it's just fair to contribute and give back. On a more personal note, having gone through a few dark phases in my life myself, please do reach out to someone where appropriate. There's no shame in it, most if not everyone carries their bag of sorrows and issues. You cannot pile it up too much, it will get too heavy eventually. |
|
Thank you very much for your message. I do talk to a professional. 🙏 |
setup.shandstart.shcombined into a single script netalertx now starts and runs via systemd unit, can be started, stopped and restartedsystemctl start netalertxsystemctl stop netalertxsystemctl status netalertxetc
Logs to
journalctland output can be followed withjournalctl -fAmalgamated chmods
tuned chmods based on earlier feedback and discussion
install script accepts command line parameter:
Please have a look, comments welcome :-)
Summary by CodeRabbit