AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.
HTML ai-agentcloudflarecloudflare-d1cloudflare-r2cloudflare-workersdockerelectronevernoteevernote-alternativeknowledge-basemcpnote-takingobsidian-alternativeoffline-firstpersonal-knowledge-basepwaself-hostedsqlitetiptapweb-clipper
feat(docker): add daily automatic updates
tianma-if48abd907d9d9
diff --git a/README.md b/README.mdindex 2cca0926..55cc9cde 100644--- a/README.md+++ b/README.md@@ -110,8 +110,8 @@ Tencent TCR image for faster, more reliable downloads:curl -fsSL https://edgeever-installer-1256854452.cos.ap-guangzhou.myqcloud.com/install.sh | bash -s -- --mirror tcr```-Both commands pull the latest image, generate an administrator password, and-start EdgeEver with Docker Compose.+Both commands pull the latest image, generate an administrator password, start+EdgeEver with Docker Compose, and schedule daily automatic updates.See the [Docker deployment guide](docs/deploy-docker.md) for manual deployment and configuration.diff --git a/README.zh-CN.md b/README.zh-CN.mdindex 8a73a684..4e01fafd 100644--- a/README.zh-CN.md+++ b/README.zh-CN.md@@ -109,8 +109,8 @@ curl -fsSL https://edgeever.org/install.sh | bashcurl -fsSL https://edgeever-installer-1256854452.cos.ap-guangzhou.myqcloud.com/install.sh | bash -s -- --mirror tcr```-两种方式都会自动拉取最新镜像、生成管理员密码,并使用 Docker Compose 启动-EdgeEver。手动部署与配置说明见 [Docker 部署文档](docs/deploy-docker.zh-CN.md)。+两种方式都会自动拉取最新镜像、生成管理员密码、使用 Docker Compose 启动+EdgeEver,并设置每日自动更新。手动部署与配置说明见 [Docker 部署文档](docs/deploy-docker.zh-CN.md)。---diff --git a/apps/site/public/install.sh b/apps/site/public/install.shindex 1f8bca66..976e28e0 100755--- a/apps/site/public/install.sh+++ b/apps/site/public/install.sh@@ -16,12 +16,16 @@ port="${EDGE_EVER_PORT:-}"username="${EDGE_EVER_AUTH_USERNAME:-}"password="${EDGE_EVER_AUTH_PASSWORD:-}"project_name="${EDGE_EVER_PROJECT_NAME:-edgeever}"+auto_update="${EDGE_EVER_AUTO_UPDATE:-true}"generated_password=falsetemporary_compose=""temporary_env=""+temporary_update=""+temporary_crontab=""current_step="Parse arguments"diagnostics_printed=falsestart_epoch=0+auto_update_status="disabled"declare -a compose=()log() {@@ -50,11 +54,14 @@ Options:--compose-url URL Download Compose configuration from URL--install-dir DIR Store Compose configuration in DIR (default: ~/edgeever)--port PORT Publish EdgeEver on PORT (default: 8787)+ --auto-update Enable daily automatic updates (default)+ --no-auto-update Disable daily automatic updates-h, --help Show this helpThe same options can be provided with EDGE_EVER_IMAGE, EDGE_EVER_VERSION,EDGE_EVER_COMPOSE_URL, EDGE_EVER_INSTALL_DIR, EDGE_EVER_PORT, and-EDGE_EVER_AUTH_PASSWORD.+EDGE_EVER_AUTH_PASSWORD. Set EDGE_EVER_AUTO_UPDATE=false to disable automatic+updates.EOF}@@ -134,6 +141,14 @@ while [[ $# -gt 0 ]]; doport="$2"shift 2;;+ --auto-update)+ auto_update=true+ shift+ ;;+ --no-auto-update)+ auto_update=false+ shift+ ;;-h|--help)usageexit 0@@ -253,15 +268,19 @@ fi[[ "$port" =~ ^[0-9]+$ ]] && ((port >= 1 && port <= 65535)) || fail "port must be between 1 and 65535"[[ "$username" != *$'\n'* && "$username" != *"'"* ]] || fail "invalid administrator username"[[ "$password" != *$'\n'* && "$password" != *"'"* ]] || fail "password must not contain a newline or single quote"+[[ "$auto_update" == "true" || "$auto_update" == "false" ]] || fail "EDGE_EVER_AUTO_UPDATE must be true or false"log INFO "Mode: $install_mode"log INFO "Install directory: $install_dir"log INFO "EdgeEver target: $image:$version"log INFO "Compose source: $compose_url"log INFO "Published port: $port"+log INFO "Daily automatic updates: $auto_update"cleanup() {[[ -z "$temporary_compose" || ! -e "$temporary_compose" ]] || rm -f "$temporary_compose"[[ -z "$temporary_env" || ! -e "$temporary_env" ]] || rm -f "$temporary_env"+ [[ -z "$temporary_update" || ! -e "$temporary_update" ]] || rm -f "$temporary_update"+ [[ -z "$temporary_crontab" || ! -e "$temporary_crontab" ]] || rm -f "$temporary_crontab"return 0}trap cleanup EXIT@@ -297,6 +316,159 @@ compose=(--file "$compose_file")+write_auto_update_script() {+ local update_script="$install_dir/update.sh"+ local docker_command curl_command+ docker_command="$(command -v docker)"+ curl_command="$(command -v curl)"+ temporary_update="$(mktemp "$install_dir/.update.sh.XXXXXX")"++ {+ printf '#!/usr/bin/env bash\n\n'+ printf 'set -Eeuo pipefail\n'+ printf 'umask 077\n\n'+ printf 'readonly docker_command=%q\n' "$docker_command"+ printf 'readonly curl_command=%q\n' "$curl_command"+ printf 'readonly install_dir=%q\n' "$install_dir"+ printf 'readonly compose_url=%q\n' "$compose_url"+ printf 'readonly project_name=%q\n\n' "$project_name"+ cat <<'EOF'+env_file="$install_dir/.env"+compose_file="$install_dir/compose.yaml"+lock_file="$install_dir/.update.lock"+temporary_compose=""++log() {+ printf '[%s] [EdgeEver update] %s\n' "$(date '+%Y-%m-%d %H:%M:%S')" "$*"+}++on_error() {+ local exit_code=$?+ local line_number="${BASH_LINENO[0]}"+ trap - ERR+ log "Update command failed (exit code: $exit_code, line: $line_number)."+ if declare -p compose >/dev/null 2>&1; then+ "${compose[@]}" ps -a || true+ "${compose[@]}" logs --tail 80 edgeever || true+ fi+ exit "$exit_code"+}++cleanup() {+ [[ -z "$temporary_compose" || ! -e "$temporary_compose" ]] || rm -f "$temporary_compose"+}+trap on_error ERR+trap cleanup EXIT++if command -v flock >/dev/null 2>&1; then+ exec 9>"$lock_file"+ if ! flock -n 9; then+ log "Another update is already running; skipping."+ exit 0+ fi+fi++compose=(+ "$docker_command" compose+ --project-name "$project_name"+ --project-directory "$install_dir"+ --env-file "$env_file"+ --file "$compose_file"+)++log "Checking for updates."+temporary_compose="$(mktemp "$install_dir/.compose.yaml.XXXXXX")"+"$curl_command" --fail --silent --show-error --location --output "$temporary_compose" "$compose_url"+grep -q '^services:' "$temporary_compose"+chmod 0644 "$temporary_compose"+mv "$temporary_compose" "$compose_file"+temporary_compose=""++"${compose[@]}" pull+"${compose[@]}" up -d --remove-orphans++container_id=""+health=""+for _ in {1..60}; do+ container_id="$("${compose[@]}" ps -q edgeever 2>/dev/null || true)"+ if [[ -n "$container_id" ]]; then+ health="$("$docker_command" inspect --format '{{if .State.Health}}{{.State.Health.Status}}{{else}}{{.State.Status}}{{end}}' "$container_id" 2>/dev/null || true)"+ [[ "$health" == "healthy" ]] && break+ [[ "$health" == "exited" || "$health" == "dead" ]] && break+ fi+ sleep 2+done++if [[ "$health" != "healthy" ]]; then+ "${compose[@]}" ps -a || true+ "${compose[@]}" logs --tail 80 edgeever || true+ log "Update failed: container health is ${health:-unknown}."+ exit 1+fi++running_image="$("$docker_command" inspect --format '{{.Config.Image}}' "$container_id" 2>/dev/null || true)"+log "Update complete. Running image: ${running_image:-unknown}."+EOF+ } > "$temporary_update"++ chmod 0700 "$temporary_update"+ mv "$temporary_update" "$update_script"+ temporary_update=""+}++remove_auto_update_schedule() {+ local marker="# edgeever-auto-update:$project_name"+ local existing_line+ command -v crontab >/dev/null 2>&1 || return 0+ temporary_crontab="$(mktemp "$install_dir/.crontab.XXXXXX")"+ while IFS= read -r existing_line; do+ [[ "$existing_line" == *"$marker"* ]] || printf '%s\n' "$existing_line" >> "$temporary_crontab"+ done < <(crontab -l 2>/dev/null || true)+ if ! crontab "$temporary_crontab"; then+ log WARN "Could not update the current user's crontab"+ fi+ rm -f "$temporary_crontab"+ temporary_crontab=""+}++configure_auto_updates() {+ local update_script="$install_dir/update.sh"+ local update_log="$install_dir/update.log"+ local marker="# edgeever-auto-update:$project_name"+ local quoted_script quoted_log++ if [[ "$auto_update" == "false" ]]; then+ remove_auto_update_schedule+ rm -f "$update_script"+ auto_update_status="disabled"+ log INFO "Daily automatic updates are disabled"+ return 0+ fi++ write_auto_update_script+ if ! command -v crontab >/dev/null 2>&1; then+ auto_update_status="updater created at $update_script; cron is unavailable"+ log WARN "crontab is unavailable; schedule $update_script with the NAS task scheduler"+ return 0+ fi++ remove_auto_update_schedule+ temporary_crontab="$(mktemp "$install_dir/.crontab.XXXXXX")"+ crontab -l 2>/dev/null > "$temporary_crontab" || true+ printf -v quoted_script '%q' "$update_script"+ printf -v quoted_log '%q' "$update_log"+ printf '17 4 * * * %s >> %s 2>&1 %s\n' "$quoted_script" "$quoted_log" "$marker" >> "$temporary_crontab"+ if crontab "$temporary_crontab"; then+ auto_update_status="daily at 04:17 server time; log: $update_log"+ log INFO "Scheduled daily automatic updates at 04:17 server time"+ else+ auto_update_status="updater created at $update_script; cron installation failed"+ log WARN "Could not install the cron schedule; run $update_script manually"+ fi+ rm -f "$temporary_crontab"+ temporary_crontab=""+}+step 5 "Pull image and start container""${compose[@]}" pull"${compose[@]}" up -d --remove-orphans@@ -321,6 +493,7 @@ if [[ "$health" != "healthy" ]]; thenfail "container did not become healthy (status: ${health:-unknown})"fi+configure_auto_updatesrunning_image="$(docker inspect --format '{{.Config.Image}}' "$container_id" 2>/dev/null || true)"log INFO "Running image: ${running_image:-$image:$version}"log SUCCESS "EdgeEver is ready ($(($(date '+%s') - start_epoch))s)"@@ -333,7 +506,11 @@ elseprintf ' Password: unchanged (stored in %s)\n' "$env_file"fiprintf ' Install directory: %s\n' "$install_dir"+printf ' Automatic updates: %s\n' "$auto_update_status"printf '\nUseful commands\n'printf ' cd %q\n' "$install_dir"printf ' docker compose ps\n'printf ' docker compose logs --tail 200 -f edgeever\n'+if [[ "$auto_update" == "true" ]]; then+ printf ' ./update.sh\n'+fidiff --git a/docs/deploy-docker.md b/docs/deploy-docker.mdindex b5f4bd14..00ab00b3 100644--- a/docs/deploy-docker.md+++ b/docs/deploy-docker.md@@ -33,6 +33,16 @@ command again to upgrade without replacing the password or `/data` volume. Themainland command downloads the installer and Compose configuration from TencentCOS and pulls the image from Tencent TCR.+By default, the installer schedules `~/edgeever/update.sh` with the current+user's crontab at 04:17 server time every day. The updater refreshes the Compose+configuration, pulls the configured image tag, restarts the service when needed,+and verifies container health. Output is appended to `~/edgeever/update.log`.+The default `latest` tag receives new releases automatically; a version supplied+with `--version` remains pinned. Use `--no-auto-update` or+`EDGE_EVER_AUTO_UPDATE=false` to disable the schedule. If `crontab` is unavailable,+the installer keeps `update.sh` and prints instructions for adding it to the NAS+task scheduler.+Use `--version vX.Y.Z`, `--port PORT`, or `--install-dir DIR` when needed. Run`curl -fsSL https://edgeever.org/install.sh | bash -s -- --help` for all options.diff --git a/docs/deploy-docker.zh-CN.md b/docs/deploy-docker.zh-CN.mdindex 43255d87..d618a45c 100644--- a/docs/deploy-docker.zh-CN.md+++ b/docs/deploy-docker.zh-CN.md@@ -23,6 +23,14 @@ curl -fsSL https://edgeever-installer-1256854452.cos.ap-guangzhou.myqcloud.com/i检查通过。中国大陆命令从腾讯云 COS 获取脚本与 Compose 配置,并从腾讯云 TCR拉取镜像。再次执行同一命令即可升级,已有密码和 `/data` 卷保持不变。+默认情况下,脚本会通过当前用户的 crontab 设置每日自动更新,于服务器本地时间+04:17 执行 `~/edgeever/update.sh`。更新程序会刷新 Compose 配置、拉取已配置的+镜像标签、按需重建服务并验证容器健康状态,运行记录追加到+`~/edgeever/update.log`。默认的 `latest` 标签会自动获得新版本;通过 `--version`+指定的版本保持固定。使用 `--no-auto-update` 或+`EDGE_EVER_AUTO_UPDATE=false` 可关闭自动更新。如果系统没有 `crontab`,安装脚本+会保留 `update.sh`,并提示通过 NAS 的任务计划程序执行。+海外服务器可去掉 `--mirror tcr` 使用 GHCR。按需使用 `--version vX.Y.Z`、`--port PORT` 或 `--install-dir DIR`;执行以下命令可查看全部参数:diff --git a/scripts/docker-installer.test.mjs b/scripts/docker-installer.test.mjsindex 634950b5..87444277 100644--- a/scripts/docker-installer.test.mjs+++ b/scripts/docker-installer.test.mjs@@ -10,7 +10,7 @@ const installerPath = resolve(projectRoot, "apps/site/public/install.sh");const composePath = resolve(projectRoot, "compose.yaml");const hostedComposePath = resolve(projectRoot, "apps/site/public/compose.yaml");-function runInstaller(arguments_, environment) {+function runBash(scriptPath, arguments_, environment) {const harnessDirectory = mkdtempSync(resolve(tmpdir(), "edgeever-installer-harness-"));const resultPath = resolve(harnessDirectory, "result.json");try {@@ -39,7 +39,7 @@ function runInstaller(arguments_, environment) {env: {...environment,EDGE_EVER_TEST_ARGUMENTS: JSON.stringify(arguments_),- EDGE_EVER_TEST_INSTALLER: installerPath,+ EDGE_EVER_TEST_INSTALLER: scriptPath,EDGE_EVER_TEST_RESULT: resultPath,},encoding: "utf8",@@ -54,6 +54,10 @@ function runInstaller(arguments_, environment) {}}+function runInstaller(arguments_, environment) {+ return runBash(installerPath, arguments_, environment);+}+describe("Docker installer", () => {test("publishes the repository Compose file unchanged", async () => {expect(await readFile(hostedComposePath, "utf8")).toBe(await readFile(composePath, "utf8"));@@ -67,6 +71,8 @@ describe("Docker installer", () => {const curlLog = resolve(fixture, "curl.log");const fakeDocker = resolve(fakeBin, "docker");const fakeCurl = resolve(fakeBin, "curl");+ const fakeCrontab = resolve(fakeBin, "crontab");+ const crontabStore = resolve(fixture, "crontab");try {await mkdir(fakeBin, { recursive: true });@@ -103,16 +109,33 @@ while [[ $# -gt 0 ]]; dofidonecp "$EDGE_EVER_TEST_COMPOSE_SOURCE" "$output"+`,+ );+ await writeFile(+ fakeCrontab,+ `#!/usr/bin/env bash+set -eu+if [[ "\${1:-}" == "-l" ]]; then+ if [[ -f "$EDGE_EVER_TEST_CRONTAB" ]]; then+ cat "$EDGE_EVER_TEST_CRONTAB"+ else+ exit 1+ fi+else+ cp "$1" "$EDGE_EVER_TEST_CRONTAB"+fi`,);await chmod(fakeDocker, 0o755);await chmod(fakeCurl, 0o755);+ await chmod(fakeCrontab, 0o755);const environment = {...process.env,PATH: `${fakeBin}:${process.env.PATH}`,EDGE_EVER_INSTALL_DIR: installDirectory,EDGE_EVER_TEST_COMPOSE_SOURCE: composePath,+ EDGE_EVER_TEST_CRONTAB: crontabStore,EDGE_EVER_TEST_CURL_LOG: curlLog,EDGE_EVER_TEST_DOCKER_LOG: dockerLog,};@@ -155,6 +178,7 @@ cp "$EDGE_EVER_TEST_COMPOSE_SOURCE" "$output"expect(first.stderr).not.toContain(generatedPassword);expect(first.stdout).toContain(`Password: ${generatedPassword}`);expect(first.stdout).toContain("docker compose logs --tail 200 -f edgeever");+ expect(first.stdout).toContain("Automatic updates: daily at 04:17 server time");const second = runInstaller([], environment);if (second.status !== 0) {@@ -165,17 +189,44 @@ cp "$EDGE_EVER_TEST_COMPOSE_SOURCE" "$output"expect(second.status).toBe(0);expect(await readFile(resolve(installDirectory, ".env"), "utf8")).toBe(firstEnvironment);+ const updaterSource = await readFile(resolve(installDirectory, "update.sh"), "utf8");+ expect(updaterSource).toContain("Checking for updates");+ expect(updaterSource).toContain("Update complete. Running image:");+ expect(updaterSource).not.toContain(generatedPassword);+ const installedCrontab = await readFile(crontabStore, "utf8");+ expect(installedCrontab).toContain("17 4 * * *");+ expect(installedCrontab).toContain("edgeever-auto-update:edgeever");+ expect(installedCrontab.match(/edgeever-auto-update:edgeever/g)).toHaveLength(1);++ const update = runBash(resolve(installDirectory, "update.sh"), [], environment);+ expect(update.status).toBe(0);+ expect(update.stdout).toContain("Checking for updates.");+ expect(update.stdout).toContain(+ "Update complete. Running image: ccr.ccs.tencentyun.com/edgeever/edgeever:latest.",+ );++ const disabled = runInstaller(["--no-auto-update"], environment);+ expect(disabled.status).toBe(0);+ expect(disabled.stdout).toContain("Automatic updates: disabled");+ expect(+ await readFile(resolve(installDirectory, "update.sh"), "utf8").then(+ () => true,+ () => false,+ ),+ ).toBe(false);+ expect(await readFile(crontabStore, "utf8")).not.toContain("edgeever-auto-update:edgeever");+const log = await readFile(dockerLog, "utf8");expect(log).toContain("compose version");- expect(log.match(/ pull$/gm)).toHaveLength(2);- expect(log.match(/ up -d --remove-orphans$/gm)).toHaveLength(2);+ expect(log.match(/ pull$/gm)).toHaveLength(4);+ expect(log.match(/ up -d --remove-orphans$/gm)).toHaveLength(4);expect(log).toContain("inspect --format");const curlRequests = await readFile(curlLog, "utf8");expect(curlRequests.match(/edgeever-installer-1256854452\.cos\.ap-guangzhou\.myqcloud\.com\/compose\.yaml/g,),- ).toHaveLength(2);+ ).toHaveLength(4);} finally {await rm(fixture, { recursive: true, force: true });}