diff options
| -rw-r--r-- | docs/docs/02-Installation/06-debuntu.md | 38 | ||||
| -rw-r--r-- | docs/docs/14-Guides/04-hoarder-to-karakeep-migration.md | 10 | ||||
| -rw-r--r-- | docs/versioned_docs/version-v0.23.1/02-Installation/06-debuntu.md | 38 | ||||
| -rw-r--r-- | docs/versioned_docs/version-v0.23.1/14-Guides/04-hoarder-to-karakeep-migration.md | 10 | ||||
| -rw-r--r-- | karakeep-linux.sh (renamed from hoarder-linux.sh) | 225 |
5 files changed, 197 insertions, 124 deletions
diff --git a/docs/docs/02-Installation/06-debuntu.md b/docs/docs/02-Installation/06-debuntu.md index 2c9c1901..2f3d1113 100644 --- a/docs/docs/02-Installation/06-debuntu.md +++ b/docs/docs/02-Installation/06-debuntu.md @@ -9,14 +9,14 @@ This script is a stripped-down version of those found in the [Proxmox Community - **Debian 12** (Buster) or - **Ubuntu 24.04** (Noble Numbat) -The script will download and install all dependencies (except for Ollama), install Hoarder, do a basic configuration of Hoarder and Meilisearch (the search app used by Hoarder), and create and enable the systemd service files needed to run Hoarder on startup. Hoarder and Meilisearch are run in the context of their low-privilege user environments for more security. +The script will download and install all dependencies (except for Ollama), install Karakeep, do a basic configuration of Karakeep and Meilisearch (the search app used by Karakeep), and create and enable the systemd service files needed to run Karakeep on startup. Karakeep and Meilisearch are run in the context of their low-privilege user environments for more security. The script functions as an update script in addition to an installer. See **[Updating](#updating)**. -### 1. Download the script from the [Hoarder repository](https://github.com/hoarder-app/hoarder/blob/main/hoarder-linux.sh). +### 1. Download the script from the [Karakeep repository](https://github.com/karakeep-app/karakeep/blob/main/karakeep-linux.sh) ``` -wget https://raw.githubusercontent.com/hoarder-app/hoarder/main/hoarder-linux.sh +wget https://raw.githubusercontent.com/karakeep-app/karakeep/main/karakeep-linux.sh ``` ### 2. Run the script @@ -26,10 +26,10 @@ wget https://raw.githubusercontent.com/hoarder-app/hoarder/main/hoarder-linux.sh If this is a fresh install, then run the installer by using the following command: ```shell - bash hoarder-linux.sh install + bash karakeep-linux.sh install ``` -### 3. Create an account/sign in! +### 3. Create an account/sign in Then visit `http://localhost:3000` and you should be greated with the Sign In page. @@ -37,34 +37,38 @@ wget https://raw.githubusercontent.com/hoarder-app/hoarder/main/hoarder-linux.sh > This script must be run as `root`, or as a user with `sudo` privileges. - If Hoarder has previously been installed using this script, then run the updater like so: + If Karakeep has previously been installed using this script, then run the updater like so: ```shell - bash hoarder-linux.sh update + bash karakeep-linux.sh update ``` ## Services and Ports -`hoarder.target` includes 4 services: `meilisearch.service`, `hoarder-web.service`, `hoarder-workers.service`, `hoarder-browser.service`. +`karakeep.target` includes 4 services: `meilisearch.service`, `karakeep-web.service`, `karakeep-workers.service`, `karakeep-browser.service`. -- `meilisearch.service`: Provides full-text search, Hoarder Workers service connects to it, uses port `7700` by default. +- `meilisearch.service`: Provides full-text search, Karakeep Workers service connects to it, uses port `7700` by default. -- `hoarder-web.service`: Provides the hoarder web service, uses `3000` port by default. +- `karakeep-web.service`: Provides the karakeep web service, uses `3000` port by default. -- `hoarder-workers.service`: Provides the hoarder workers service, no port. +- `karakeep-workers.service`: Provides the karakeep workers service, no port. -- `hoarder-browser.service`: Provides the headless browser service, uses `9222` port by default. +- `karakeep-browser.service`: Provides the headless browser service, uses `9222` port by default. ## Configuration, ENV file, database locations -During installation, the script created a configuration file for `meilisearch`, an `ENV` file for Hoarder, and located config paths and database paths separate from the installation path of Hoarder, so as to allow for easier updating. Their names/locations are as follows: +During installation, the script created a configuration file for `meilisearch`, an `ENV` file for Karakeep, and located config paths and database paths separate from the installation path of Karakeep, so as to allow for easier updating. Their names/locations are as follows: - `/etc/meilisearch.toml` - a basic configuration for meilisearch, that contains configs for the database location, disabling analytics, and using a master key, which prevents unauthorized connections. - `/var/lib/meilisearch` - Meilisearch DB location. -- `/etc/hoarder/hoarder.env` - The Hoarder `ENV` file. Edit this file to configure Hoarder beyond the default. The web service and the workers service need to be restarted after editing this file: - +- `/etc/karakeep/karakeep.env` - The Karakeep `ENV` file. Edit this file to configure Karakeep beyond the default. The web service and the workers service need to be restarted after editing this file: + ```shell - sudo systemctl restart hoarder-workers hoarder-web + sudo systemctl restart karakeep-workers karakeep-web ``` -- `/var/lib/hoarder` - The Hoarder database location. If you delete the contents of this folder you will lose all your data. +- `/var/lib/karakeep` - The Karakeep database location. If you delete the contents of this folder you will lose all your data. + +## Still Running Hoarder? + +There is a way to upgrade. Please see [Guides > Hoarder to Karakeep Migration](https://docs.karakeep.app/Guides/hoarder-to-karakeep-migration) diff --git a/docs/docs/14-Guides/04-hoarder-to-karakeep-migration.md b/docs/docs/14-Guides/04-hoarder-to-karakeep-migration.md index 1ac50c7c..289a091c 100644 --- a/docs/docs/14-Guides/04-hoarder-to-karakeep-migration.md +++ b/docs/docs/14-Guides/04-hoarder-to-karakeep-migration.md @@ -16,3 +16,13 @@ index cdfc908..6297563 100644 ``` You can also change the `HOARDER_VERSION` environment variable but if you do so remember to change it in the `.env` file as well. + +## Migrating a Baremetal Installation + +If you previously used the [Debian/Ubuntu install script](https://docs.karakeep.app/Installation/debuntu) to install Hoarder, there is an option to migrate your installation to Karakeep. + +```bash +bash karakeep-linux.sh migrate +``` + +This will migrate your installation with no user input required. After the migration, the script will also check for an update. diff --git a/docs/versioned_docs/version-v0.23.1/02-Installation/06-debuntu.md b/docs/versioned_docs/version-v0.23.1/02-Installation/06-debuntu.md index 2c9c1901..2f3d1113 100644 --- a/docs/versioned_docs/version-v0.23.1/02-Installation/06-debuntu.md +++ b/docs/versioned_docs/version-v0.23.1/02-Installation/06-debuntu.md @@ -9,14 +9,14 @@ This script is a stripped-down version of those found in the [Proxmox Community - **Debian 12** (Buster) or - **Ubuntu 24.04** (Noble Numbat) -The script will download and install all dependencies (except for Ollama), install Hoarder, do a basic configuration of Hoarder and Meilisearch (the search app used by Hoarder), and create and enable the systemd service files needed to run Hoarder on startup. Hoarder and Meilisearch are run in the context of their low-privilege user environments for more security. +The script will download and install all dependencies (except for Ollama), install Karakeep, do a basic configuration of Karakeep and Meilisearch (the search app used by Karakeep), and create and enable the systemd service files needed to run Karakeep on startup. Karakeep and Meilisearch are run in the context of their low-privilege user environments for more security. The script functions as an update script in addition to an installer. See **[Updating](#updating)**. -### 1. Download the script from the [Hoarder repository](https://github.com/hoarder-app/hoarder/blob/main/hoarder-linux.sh). +### 1. Download the script from the [Karakeep repository](https://github.com/karakeep-app/karakeep/blob/main/karakeep-linux.sh) ``` -wget https://raw.githubusercontent.com/hoarder-app/hoarder/main/hoarder-linux.sh +wget https://raw.githubusercontent.com/karakeep-app/karakeep/main/karakeep-linux.sh ``` ### 2. Run the script @@ -26,10 +26,10 @@ wget https://raw.githubusercontent.com/hoarder-app/hoarder/main/hoarder-linux.sh If this is a fresh install, then run the installer by using the following command: ```shell - bash hoarder-linux.sh install + bash karakeep-linux.sh install ``` -### 3. Create an account/sign in! +### 3. Create an account/sign in Then visit `http://localhost:3000` and you should be greated with the Sign In page. @@ -37,34 +37,38 @@ wget https://raw.githubusercontent.com/hoarder-app/hoarder/main/hoarder-linux.sh > This script must be run as `root`, or as a user with `sudo` privileges. - If Hoarder has previously been installed using this script, then run the updater like so: + If Karakeep has previously been installed using this script, then run the updater like so: ```shell - bash hoarder-linux.sh update + bash karakeep-linux.sh update ``` ## Services and Ports -`hoarder.target` includes 4 services: `meilisearch.service`, `hoarder-web.service`, `hoarder-workers.service`, `hoarder-browser.service`. +`karakeep.target` includes 4 services: `meilisearch.service`, `karakeep-web.service`, `karakeep-workers.service`, `karakeep-browser.service`. -- `meilisearch.service`: Provides full-text search, Hoarder Workers service connects to it, uses port `7700` by default. +- `meilisearch.service`: Provides full-text search, Karakeep Workers service connects to it, uses port `7700` by default. -- `hoarder-web.service`: Provides the hoarder web service, uses `3000` port by default. +- `karakeep-web.service`: Provides the karakeep web service, uses `3000` port by default. -- `hoarder-workers.service`: Provides the hoarder workers service, no port. +- `karakeep-workers.service`: Provides the karakeep workers service, no port. -- `hoarder-browser.service`: Provides the headless browser service, uses `9222` port by default. +- `karakeep-browser.service`: Provides the headless browser service, uses `9222` port by default. ## Configuration, ENV file, database locations -During installation, the script created a configuration file for `meilisearch`, an `ENV` file for Hoarder, and located config paths and database paths separate from the installation path of Hoarder, so as to allow for easier updating. Their names/locations are as follows: +During installation, the script created a configuration file for `meilisearch`, an `ENV` file for Karakeep, and located config paths and database paths separate from the installation path of Karakeep, so as to allow for easier updating. Their names/locations are as follows: - `/etc/meilisearch.toml` - a basic configuration for meilisearch, that contains configs for the database location, disabling analytics, and using a master key, which prevents unauthorized connections. - `/var/lib/meilisearch` - Meilisearch DB location. -- `/etc/hoarder/hoarder.env` - The Hoarder `ENV` file. Edit this file to configure Hoarder beyond the default. The web service and the workers service need to be restarted after editing this file: - +- `/etc/karakeep/karakeep.env` - The Karakeep `ENV` file. Edit this file to configure Karakeep beyond the default. The web service and the workers service need to be restarted after editing this file: + ```shell - sudo systemctl restart hoarder-workers hoarder-web + sudo systemctl restart karakeep-workers karakeep-web ``` -- `/var/lib/hoarder` - The Hoarder database location. If you delete the contents of this folder you will lose all your data. +- `/var/lib/karakeep` - The Karakeep database location. If you delete the contents of this folder you will lose all your data. + +## Still Running Hoarder? + +There is a way to upgrade. Please see [Guides > Hoarder to Karakeep Migration](https://docs.karakeep.app/Guides/hoarder-to-karakeep-migration) diff --git a/docs/versioned_docs/version-v0.23.1/14-Guides/04-hoarder-to-karakeep-migration.md b/docs/versioned_docs/version-v0.23.1/14-Guides/04-hoarder-to-karakeep-migration.md index 1ac50c7c..289a091c 100644 --- a/docs/versioned_docs/version-v0.23.1/14-Guides/04-hoarder-to-karakeep-migration.md +++ b/docs/versioned_docs/version-v0.23.1/14-Guides/04-hoarder-to-karakeep-migration.md @@ -16,3 +16,13 @@ index cdfc908..6297563 100644 ``` You can also change the `HOARDER_VERSION` environment variable but if you do so remember to change it in the `.env` file as well. + +## Migrating a Baremetal Installation + +If you previously used the [Debian/Ubuntu install script](https://docs.karakeep.app/Installation/debuntu) to install Hoarder, there is an option to migrate your installation to Karakeep. + +```bash +bash karakeep-linux.sh migrate +``` + +This will migrate your installation with no user input required. After the migration, the script will also check for an update. diff --git a/hoarder-linux.sh b/karakeep-linux.sh index 8a857091..4e7123df 100644 --- a/hoarder-linux.sh +++ b/karakeep-linux.sh @@ -2,7 +2,7 @@ set -Eeuo pipefail -# v2.0 +# v2.1 # Copyright 2024-2025 # Author: vhsdream # Adapted from: The Karakeep installation script from https://github.com/community-scripts/ProxmoxVE @@ -12,18 +12,18 @@ set -Eeuo pipefail trap 'catch $? $LINENO' ERR catch() { - if [ "$1" == 0 ]; then - return - fi - echo "Caught error $1 on line $2" + if [ "$1" == 0 ]; then + return + fi + echo "Caught error $1 on line $2" } -OS="$( awk -F'=' '/^VERSION_CODENAME=/{ print $NF }' /etc/os-release )" -INSTALL_DIR=/opt/hoarder -export DATA_DIR=/var/lib/hoarder -CONFIG_DIR=/etc/hoarder -LOG_DIR=/var/log/hoarder -ENV_FILE=${CONFIG_DIR}/hoarder.env +OS="$(awk -F'=' '/^VERSION_CODENAME=/{ print $NF }' /etc/os-release)" +INSTALL_DIR=/opt/karakeep +export DATA_DIR=/var/lib/karakeep +CONFIG_DIR=/etc/karakeep +LOG_DIR=/var/log/karakeep +ENV_FILE=${CONFIG_DIR}/karakeep.env install() { echo "Karakeep installation for Debian 12/Ubuntu 24.04" && sleep 4 @@ -32,7 +32,6 @@ install() { g++ \ curl \ build-essential \ - curl \ sudo \ unzip \ gnupg \ @@ -50,8 +49,8 @@ install() { fi wget -q https://github.com/Y2Z/monolith/releases/latest/download/monolith-gnu-linux-x86_64 -O /usr/bin/monolith && chmod +x /usr/bin/monolith - wget -q https://github.com/meilisearch/meilisearch/releases/latest/download/meilisearch.deb && \ - DEBIAN_FRONTEND=noninteractive dpkg -i meilisearch.deb && rm meilisearch.deb + wget -q https://github.com/meilisearch/meilisearch/releases/latest/download/meilisearch.deb && + DEBIAN_FRONTEND=noninteractive dpkg -i meilisearch.deb && rm meilisearch.deb echo "Installed Dependencies" && sleep 1 echo "Installing Node.js..." @@ -60,38 +59,38 @@ install() { echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_22.x nodistro main" >/etc/apt/sources.list.d/nodesource.list apt-get update apt-get install -y nodejs - # https://github.com/hoarder-app/hoarder/issues/967 + # https://github.com/karakeep-app/karakeep/issues/967 npm install -g corepack@0.31.0 echo "Installed Node.js" && sleep 1 echo "Installing Karakeep..." - mkdir -p $DATA_DIR - mkdir -p $CONFIG_DIR - mkdir -p $LOG_DIR + mkdir -p "$DATA_DIR" + mkdir -p "$CONFIG_DIR" + mkdir -p "$LOG_DIR" M_DATA_DIR=/var/lib/meilisearch M_CONFIG_FILE=/etc/meilisearch.toml RELEASE=$(curl -s https://api.github.com/repos/karakeep-app/karakeep/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') cd /tmp wget -q "https://github.com/karakeep-app/karakeep/archive/refs/tags/v${RELEASE}.zip" - unzip -q v${RELEASE}.zip - mv karakeep-${RELEASE} ${INSTALL_DIR} && cd ${INSTALL_DIR}/apps/web + unzip -q v"$RELEASE".zip + mv karakeep-"$RELEASE" "$INSTALL_DIR" && cd "$INSTALL_DIR"/apps/web corepack enable export NEXT_TELEMETRY_DISABLED=1 export PUPPETEER_SKIP_DOWNLOAD="true" export CI="true" pnpm i --frozen-lockfile pnpm exec next build --experimental-build-mode compile - cd ${INSTALL_DIR}/apps/workers + cd "$INSTALL_DIR"/apps/workers pnpm i --frozen-lockfile - cd ${INSTALL_DIR}/apps/cli + cd "$INSTALL_DIR"/apps/cli pnpm i --frozen-lockfile pnpm build - cd ${INSTALL_DIR}/packages/db + cd "$INSTALL_DIR"/packages/db pnpm migrate echo "Installed Karakeep" && sleep 1 echo "Creating configuration files..." - cd $INSTALL_DIR + cd "$INSTALL_DIR" MASTER_KEY="$(openssl rand -base64 12)" cat <<EOF >${M_CONFIG_FILE} env = "production" @@ -101,13 +100,13 @@ dump_dir = "${M_DATA_DIR}/dumps" snapshot_dir = "${M_DATA_DIR}/snapshots" no_analytics = true EOF - chmod 600 $M_CONFIG_FILE + chmod 600 "$M_CONFIG_FILE" - KARAKEEP_SECRET="$(openssl rand -base64 36 | cut -c1-24)" + karakeep_SECRET="$(openssl rand -base64 36 | cut -c1-24)" cat <<EOF >${ENV_FILE} NODE_ENV=production SERVER_VERSION=${RELEASE} -NEXTAUTH_SECRET="${KARAKEEP_SECRET}" +NEXTAUTH_SECRET="${karakeep_SECRET}" NEXTAUTH_URL="http://localhost:3000" DATA_DIR=${DATA_DIR} MEILI_ADDR="http://127.0.0.1:7700" @@ -120,15 +119,15 @@ BROWSER_WEB_URL="http://127.0.0.1:9222" # INFERENCE_TEXT_MODEL= # INFERENCE_IMAGE_MODEL= EOF - chmod 600 $ENV_FILE - echo ${RELEASE} > ${INSTALL_DIR}/version.txt + chmod 600 "$ENV_FILE" + echo "$RELEASE" >"$INSTALL_DIR"/version.txt echo "Configuration complete" && sleep 1 echo "Creating users and modifying permissions..." - useradd -U -s /usr/sbin/nologin -r -m -d "${M_DATA_DIR}" meilisearch - useradd -U -s /usr/sbin/nologin -r -M -d "${INSTALL_DIR}" hoarder - chown meilisearch:meilisearch "${M_CONFIG_FILE}" - chown -R hoarder:hoarder "${INSTALL_DIR}" "${CONFIG_DIR}" "${DATA_DIR}" "${LOG_DIR}" + useradd -U -s /usr/sbin/nologin -r -m -d "$M_DATA_DIR" meilisearch + useradd -U -s /usr/sbin/nologin -r -M -d "$INSTALL_DIR" karakeep + chown meilisearch:meilisearch "$M_CONFIG_FILE" + chown -R karakeep:karakeep "$INSTALL_DIR" "$CONFIG_DIR" "$DATA_DIR" "$LOG_DIR" echo "Users created, permissions modified" && sleep 1 echo "Creating service files..." @@ -167,9 +166,9 @@ RemoveIPC=true WantedBy=multi-user.target EOF - cat <<EOF >/etc/systemd/system/hoarder-browser.service + cat <<EOF >/etc/systemd/system/karakeep-browser.service [Unit] -Description=Hoarder headless browser +Description=Karakeep headless browser After=network.target [Service] @@ -177,61 +176,61 @@ User=root Restart=on-failure ExecStart=/usr/bin/chromium --headless --no-sandbox --disable-gpu --disable-dev-shm-usage --remote-debugging-address=127.0.0.1 --remote-debugging-port=9222 --hide-scrollbars TimeoutStopSec=5 -SyslogIdentifier=hoarder-browser +SyslogIdentifier=karakeep-browser [Install] WantedBy=multi-user.target EOF - cat <<EOF >/etc/systemd/system/hoarder-workers.service + cat <<EOF >/etc/systemd/system/karakeep-workers.service [Unit] -Description=Hoarder workers -Wants=network.target hoarder-browser.service meilisearch.service -After=network.target hoarder-browser.service meilisearch.service +Description=Karakeep workers +Wants=network.target karakeep-browser.service meilisearch.service +After=network.target karakeep-browser.service meilisearch.service [Service] -User=hoarder -Group=hoarder +User=karakeep +Group=karakeep Restart=always EnvironmentFile=${ENV_FILE} WorkingDirectory=${INSTALL_DIR}/apps/workers ExecStart=/usr/bin/pnpm run start:prod -StandardOutput=file:${LOG_DIR}/hoarder-workers.log -StandardError=file:${LOG_DIR}/hoarder-workers.log +StandardOutput=file:${LOG_DIR}/karakeep-workers.log +StandardError=file:${LOG_DIR}/karakeep-workers.log TimeoutStopSec=5 -SyslogIdentifier=hoarder-workers +SyslogIdentifier=karakeep-workers [Install] WantedBy=multi-user.target EOF - cat <<EOF >/etc/systemd/system/hoarder-web.service + cat <<EOF >/etc/systemd/system/karakeep-web.service [Unit] -Description=Hoarder web -Wants=network.target hoarder-workers.service -After=network.target hoarder-workers.service +Description=Karakeep web +Wants=network.target karakeep-workers.service +After=network.target karakeep-workers.service [Service] -User=hoarder -Group=hoarder +User=karakeep +Group=karakeep Restart=on-failure EnvironmentFile=${ENV_FILE} WorkingDirectory=${INSTALL_DIR}/apps/web ExecStart=/usr/bin/pnpm start -StandardOutput=file:${LOG_DIR}/hoarder-web.log -StandardError=file:${LOG_DIR}/hoarder-web.log +StandardOutput=file:${LOG_DIR}/karakeep-web.log +StandardError=file:${LOG_DIR}/karakeep-web.log TimeoutStopSec=5 -SyslogIdentifier=hoarder-web +SyslogIdentifier=karakeep-web [Install] WantedBy=multi-user.target EOF - cat <<EOF >/etc/systemd/system/hoarder.target + cat <<EOF >/etc/systemd/system/karakeep.target [Unit] -Description=Hoarder Services +Description=Karakeep Services After=network-online.target -Wants=meilisearch.service hoarder-browser.service hoarder-workers.service hoarder-web.service +Wants=meilisearch.service karakeep-browser.service karakeep-workers.service karakeep-web.service [Install] WantedBy=multi-user.target @@ -239,11 +238,11 @@ EOF echo "Service files created" && sleep 1 echo "Enabling and starting services, please wait..." && sleep 3 - systemctl enable -q --now meilisearch.service hoarder.target + systemctl enable -q --now meilisearch.service karakeep.target echo "Done" && sleep 1 echo "Cleaning up" && sleep 1 - rm /tmp/v${RELEASE}.zip + rm /tmp/v"$RELEASE".zip apt -y autoremove apt -y autoclean echo "Cleaned" && sleep 1 @@ -254,37 +253,45 @@ EOF update() { echo "Checking for an update..." && sleep 1 - if [[ ! -d ${INSTALL_DIR} ]]; then echo "Is Karakeep even installed?"; exit 1; fi + if [[ ! -d ${INSTALL_DIR} ]]; then + echo "Is Karakeep even installed?" + exit 1 + fi RELEASE=$(curl -s https://api.github.com/repos/karakeep-app/karakeep/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') - PREV_RELEASE=$(cat ${INSTALL_DIR}/version.txt) - if [[ "${RELEASE}" != "${PREV_RELEASE}" ]]; then - echo "Stopping affected services..." && sleep 1 - systemctl stop hoarder-web hoarder-workers - echo "Stopped services" && sleep 1 - + PREV_RELEASE=$(cat "$INSTALL_DIR"/version.txt) + if [[ "$RELEASE" != "$PREV_RELEASE" ]]; then + if [[ "$(systemctl is-active karakeep-web)" == "active" ]]; then + echo "Stopping affected services..." && sleep 1 + systemctl stop karakeep-web karakeep-workers + echo "Stopped services" && sleep 1 + fi echo "Updating Karakeep to v${RELEASE}..." && sleep 1 - sed -i "s|SERVER_VERSION=${PREV_RELEASE}|SERVER_VERSION=${RELEASE}|" ${ENV_FILE} - rm -R ${INSTALL_DIR} + sed -i "s|SERVER_VERSION=${PREV_RELEASE}|SERVER_VERSION=${RELEASE}|" "$ENV_FILE" + rm -R "$INSTALL_DIR" cd /tmp wget -q "https://github.com/karakeep-app/karakeep/archive/refs/tags/v${RELEASE}.zip" - unzip -q v${RELEASE}.zip - mv karakeep-${RELEASE} ${INSTALL_DIR} - # https://github.com/hoarder-app/hoarder/issues/967 + unzip -q v"$RELEASE".zip + mv karakeep-"$RELEASE" "$INSTALL_DIR" + # https://github.com/karakeep-app/karakeep/issues/967 if [[ $(corepack -v) < "0.31.0" ]]; then - npm install -g corepack@0.31.0 + npm install -g corepack@0.31.0 fi - cd ${INSTALL_DIR}/apps/web && pnpm i --frozen-lockfile + corepack enable + export NEXT_TELEMETRY_DISABLED=1 + export PUPPETEER_SKIP_DOWNLOAD="true" + export CI="true" + cd "$INSTALL_DIR"/apps/web && pnpm i --frozen-lockfile pnpm exec next build --experimental-build-mode compile - cd ${INSTALL_DIR}/apps/workers && pnpm i --frozen-lockfile - cd ${INSTALL_DIR}/apps/cli && pnpm i --frozen-lockfile + cd "$INSTALL_DIR"/apps/workers && pnpm i --frozen-lockfile + cd "$INSTALL_DIR"/apps/cli && pnpm i --frozen-lockfile pnpm build - cd ${INSTALL_DIR}/packages/db && pnpm migrate - echo "${RELEASE}" >${INSTALL_DIR}/version.txt - chown -R hoarder:hoarder ${INSTALL_DIR} ${DATA_DIR} + cd "$INSTALL_DIR"/packages/db && pnpm migrate + echo "$RELEASE" >"$INSTALL_DIR"/version.txt + chown -R karakeep:karakeep "$INSTALL_DIR" "$DATA_DIR" echo "Updated Karakeep to v${RELEASE}" && sleep 1 echo "Restarting services and cleaning up..." && sleep 1 - systemctl start hoarder-workers hoarder-web - rm /tmp/v${RELEASE}.zip + systemctl start karakeep-workers karakeep-web + rm /tmp/v"$RELEASE".zip echo "Ready!" else echo "No update required." @@ -292,19 +299,57 @@ update() { exit 0 } +migrate() { + if [[ ! -d /opt/karakeep ]]; then + echo "Migrating your Hoarder installation to Karakeep, then checking for an update..." && sleep 3 + systemctl stop hoarder-browser hoarder-workers hoarder-web + sed -i -e "s|hoarder|karakeep|g" /etc/hoarder/hoarder.env /etc/systemd/system/hoarder-{browser,web,workers}.service /etc/systemd/system/hoarder.target \ + -e "s|Hoarder|Karakeep|g" /etc/systemd/system/hoarder-{browser,web,workers}.service /etc/systemd/system/hoarder.target + for path in /etc/systemd/system/hoarder*.service; do + new_path="${path//hoarder/karakeep}" + mv "$path" "$new_path" + done + mv /etc/systemd/system/hoarder.target /etc/systemd/system/karakeep.target + mv /opt/hoarder "$INSTALL_DIR" + mv /var/lib/hoarder "$DATA_DIR" + mv /etc/hoarder "$CONFIG_DIR" + mv /var/log/hoarder "$LOG_DIR" + mv "$CONFIG_DIR"/hoarder.env "$ENV_FILE" + mv "$LOG_DIR"/hoarder-web.log "$LOG_DIR"/karakeep-web.log + mv "$LOG_DIR"/hoarder-workers.log "$LOG_DIR"/karakeep-workers.log + usermod -l karakeep hoarder -d "$INSTALL_DIR" + groupmod -n karakeep hoarder + chown -R karakeep:karakeep "$INSTALL_DIR" "$CONFIG_DIR" "$DATA_DIR" "$LOG_DIR" + systemctl daemon-reload + systemctl -q enable --now karakeep.target + echo "Migration complete!" && sleep 2 + else + echo "There is no need for a migration: Karakeep is already installed." + exit 1 + fi +} + [ "$(id -u)" -ne 0 ] && echo "This script requires root privileges. Please run with sudo or as the root user." && exit 1 command="${1:-}" -if [ -z "$command" ]; then - echo -e "Run script with 'install' to install Karakeep and 'update' to update Karakeep" && exit 1 +if [ "$command" = "" ]; then + echo -e "\nRun script with:\r +parameter 'install' to install Karakeep\r +parameter 'update' to update Karakeep\r +parameter 'migrate' to migrate your Hoarder install to Karakeep\n +Note: 'migrate' will also update to the latest version if necessary" && exit 1 fi case "$command" in - install) - install - ;; - update) - update - ;; - *) - echo -e "Unknown command. Choose 'install' or 'update'" && exit 1 +install) + install + ;; +update) + update + ;; +migrate) + migrate && update + ;; +*) + echo -e "Unknown command. Choose 'install', 'update' or 'migrate'." && exit 1 + ;; esac |
