The installer no longer opens an editor or starts the service on a fresh install. It writes the files, then prints: sudoedit the env file, systemctl start, journalctl -f. --start starts (or restarts) the service straight away, and an already running service is restarted on upgrade. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
88487d9744
commit
caa46175bc
2 files changed
+31
-36
No files matched your search
@@ -66,13 +66,20 @@ curl -fsSL https://git.veillax.com/Veillax/megalodon/raw/branch/main/deploy/inst
|
||||
```
|
||||
|
||||
This downloads the latest release (checking its SHA-256), installs `/usr/local/bin/megalodon`,
|
||||
creates a `megalodon` user, `/etc/megalodon/` (settings) and `/var/lib/megalodon/` (data), opens
|
||||
`/etc/megalodon/megalodon.env` in your editor, then starts the service and prints the first-run
|
||||
admin password. Run it again to upgrade; your settings are kept.
|
||||
creates a `megalodon` user, `/etc/megalodon/` (settings) and `/var/lib/megalodon/` (data), and writes
|
||||
the systemd service and `/etc/megalodon/megalodon.env`. It then tells you what to do next:
|
||||
|
||||
Options: `--version v0.1.0`, `--listen 0.0.0.0:8480`, `--source` (build from the repository with Go
|
||||
instead), `--no-edit`, `--no-start`, and `--uninstall` (add `--purge` to delete settings and data).
|
||||
Download the script and read it first if you prefer: it is [`deploy/install.sh`](deploy/install.sh).
|
||||
```sh
|
||||
sudoedit /etc/megalodon/megalodon.env
|
||||
sudo systemctl start megalodon
|
||||
journalctl -u megalodon -f # a first install prints the admin password here, once
|
||||
```
|
||||
|
||||
Run it again to upgrade; your settings are kept and a running service is restarted.
|
||||
|
||||
Options: `--start` (start the service straight away), `--version v0.1.0`, `--listen 0.0.0.0:8480`,
|
||||
`--source` (build from the repository with Go instead), and `--uninstall` (add `--purge` to delete
|
||||
settings and data). Download the script and read it first if you prefer: it is [`deploy/install.sh`](deploy/install.sh).
|
||||
|
||||
## Running it by hand
|
||||
|
||||
|
||||
+18
-30
@@ -2,7 +2,7 @@
|
||||
# Installs (or upgrades) Megalodon as a systemd service.
|
||||
#
|
||||
# curl -fsSL https://git.veillax.com/Veillax/megalodon/raw/branch/main/deploy/install.sh | sudo sh
|
||||
# sudo sh install.sh [--version v0.1.0] [--listen 127.0.0.1:8480] [--source] [--no-edit] [--no-start]
|
||||
# sudo sh install.sh [--start] [--version v0.1.0] [--listen 127.0.0.1:8480] [--source]
|
||||
# sudo sh install.sh --uninstall [--purge]
|
||||
#
|
||||
# What it does:
|
||||
@@ -10,10 +10,11 @@
|
||||
# clones the repository and builds it with Go),
|
||||
# 2. installs the binary to /usr/local/bin/megalodon,
|
||||
# 3. creates a "megalodon" user, /etc/megalodon (settings) and /var/lib/megalodon (data),
|
||||
# 4. writes /etc/megalodon/megalodon.env and opens it in your editor,
|
||||
# 5. installs and starts the systemd service, and prints the first-run admin password.
|
||||
# 4. writes /etc/megalodon/megalodon.env and the systemd service,
|
||||
# 5. tells you what to do next: edit the env file, start the service, watch the log.
|
||||
#
|
||||
# Running it again upgrades the binary and keeps your settings.
|
||||
# Running it again upgrades the binary and keeps your settings; a service that is already running
|
||||
# is restarted. Add --start to start it straight away instead of editing the env file first.
|
||||
set -eu
|
||||
|
||||
REPO_URL=${MEGALODON_REPO_URL:-https://git.veillax.com/Veillax/megalodon}
|
||||
@@ -29,8 +30,7 @@ USER_NAME=megalodon
|
||||
VERSION=""
|
||||
LISTEN="127.0.0.1:8480"
|
||||
SOURCE=0
|
||||
EDIT=1
|
||||
START=1
|
||||
START=0
|
||||
UNINSTALL=0
|
||||
PURGE=0
|
||||
|
||||
@@ -42,8 +42,7 @@ while [ $# -gt 0 ]; do
|
||||
--version) VERSION=${2:?--version needs a value}; shift ;;
|
||||
--listen) LISTEN=${2:?--listen needs a value}; shift ;;
|
||||
--source) SOURCE=1 ;;
|
||||
--no-edit) EDIT=0 ;;
|
||||
--no-start) START=0 ;;
|
||||
--start) START=1 ;;
|
||||
--uninstall) UNINSTALL=1 ;;
|
||||
--purge) PURGE=1 ;;
|
||||
-h|--help) sed -n '2,19p' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;;
|
||||
@@ -146,17 +145,8 @@ MEGALODON_CONFIG=$CONF_FILE
|
||||
# America/New_York, UTC. Leave it commented to use the server's own zone.
|
||||
#TZ=Europe/London
|
||||
EOF
|
||||
chmod 0640 "$ENV_FILE"
|
||||
chgrp "$USER_NAME" "$ENV_FILE" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
if [ "$EDIT" -eq 1 ] && [ -r /dev/tty ]; then
|
||||
ED=${VISUAL:-${EDITOR:-}}
|
||||
[ -n "$ED" ] || for c in nano vim vi; do command -v "$c" >/dev/null 2>&1 && { ED=$c; break; }; done
|
||||
if [ -n "$ED" ]; then
|
||||
say "Opening $ENV_FILE in $ED ..."
|
||||
$ED "$ENV_FILE" </dev/tty >/dev/tty || say "(the editor exited with an error; continuing)"
|
||||
fi
|
||||
chmod 0600 "$ENV_FILE" # systemd reads it as root, so the service user does not need access
|
||||
say "Created $ENV_FILE. Edit it before starting."
|
||||
fi
|
||||
|
||||
# ---- 5. service ----
|
||||
@@ -198,7 +188,7 @@ EOF
|
||||
systemctl daemon-reload
|
||||
systemctl enable megalodon >/dev/null 2>&1
|
||||
|
||||
if [ "$START" -eq 1 ]; then
|
||||
if [ "$START" -eq 1 ] || systemctl is-active --quiet megalodon; then
|
||||
systemctl restart megalodon
|
||||
sleep 3
|
||||
if systemctl is-active --quiet megalodon; then
|
||||
@@ -207,17 +197,15 @@ if [ "$START" -eq 1 ]; then
|
||||
say "Megalodon did not start. Look at: journalctl -u megalodon -n 50"
|
||||
exit 1
|
||||
fi
|
||||
pw=$(journalctl -u megalodon --no-pager 2>/dev/null | sed -n 's/.*first run: created user "admin" with password \([^ ]*\).*/\1/p' | tail -n 1)
|
||||
if [ "$UPGRADE" -eq 0 ] && [ -n "$pw" ]; then
|
||||
say ""
|
||||
say " Sign in as: admin"
|
||||
say " Password: $pw (shown once; change it under Settings > Users)"
|
||||
fi
|
||||
|
||||
say "Installed $("$BIN" version)."
|
||||
say "Next:"
|
||||
say " 1. sudoedit $ENV_FILE (the time zone for schedules; the settings file is $CONF_FILE)"
|
||||
say " 2. systemctl start megalodon (or run this again with --start)"
|
||||
say " 3. journalctl -u megalodon -f to watch it; a first install prints the admin password here, once"
|
||||
say ""
|
||||
say "Dashboard: http://$LISTEN"
|
||||
say "Logs: journalctl -u megalodon -f"
|
||||
say "Settings: $CONF_FILE and $ENV_FILE"
|
||||
say "The dashboard is at http://$LISTEN"
|
||||
case $LISTEN in
|
||||
127.*|localhost*|\[::1\]*) say "It only listens on this machine. To reach it elsewhere, put an HTTPS reverse proxy (or Hammerhead) in front of it." ;;
|
||||
127.*|localhost*|[::1]*) say "It only listens on this machine. To reach it elsewhere, put an HTTPS reverse proxy (or Hammerhead) in front of it." ;;
|
||||
esac
|
||||
fi
|
||||
Reference in new issue
Block a user