Skip to content

Commit 1ca9978

Browse files
vhsdreamMickLeskhavardthomMohamedBassem
authored
New Script: Hoarder LXC (#567)
* Add Hoarder script * Point build.func to correct repo * I hate testing these scripts * no comment * Quiesce systemctl enable output; add move DB to hoarder_data * add timeout to hoarder-workers * Restore attribution * fix sourcefix source URLs; quiesce migration post-install * Update hoarder-install.sh to move commands to separate lines Also made similar changes in some other areas. * Delete install/bazarr-install.sh * Delete ct/bazarr.sh * Update msg_info Co-authored-by: Håvard Gjøby Thom <[email protected]> * Update msg_ok Co-authored-by: Håvard Gjøby Thom <[email protected]> * Update msg_info Co-authored-by: Håvard Gjøby Thom <[email protected]> * Update ct/hoarder.sh Co-authored-by: Håvard Gjøby Thom <[email protected]> * Remove bazarr.sh and bazarr-install.sh changes from PR * Add Json for Website * Apply suggestions from code review Co-authored-by: Håvard Gjøby Thom <[email protected]> * Update ct/hoarder.sh Co-authored-by: Håvard Gjøby Thom <[email protected]> * Update hoarder.sh * remove unnecessary dependencies; clean up worker & web install; remove zip after cleanup * Apply suggestions from code review Co-authored-by: Håvard Gjøby Thom <[email protected]> * Update hoarder.sh (&>/dev/null) &>/dev/null * Fix broken DB migration, other small changes * Update resources in hoarder.json * Update install/hoarder-install.sh with commented refs for AI tagging Co-authored-by: Mohamed Bassem <[email protected]> --------- Co-authored-by: CanbiZ <[email protected]> Co-authored-by: Håvard Gjøby Thom <[email protected]> Co-authored-by: Mohamed Bassem <[email protected]>
1 parent 342e145 commit 1ca9978

File tree

3 files changed

+320
-0
lines changed

3 files changed

+320
-0
lines changed

ct/hoarder.sh

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#!/usr/bin/env bash
2+
source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
3+
# Copyright (c) 2021-2024 tteck
4+
# Author: MickLesk (Canbiz) & vhsdream
5+
# License: MIT
6+
# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
7+
8+
function header_info {
9+
clear
10+
cat <<"EOF"
11+
__ __ __
12+
/ / / /___ ____ __________/ /__ _____
13+
/ /_/ / __ \/ __ `/ ___/ __ / _ \/ ___/
14+
/ __ / /_/ / /_/ / / / /_/ / __/ /
15+
/_/ /_/\____/\__,_/_/ \__,_/\___/_/
16+
17+
EOF
18+
}
19+
header_info
20+
echo -e "Loading..."
21+
APP="Hoarder"
22+
var_disk="8"
23+
var_cpu="2"
24+
var_ram="4096"
25+
var_os="debian"
26+
var_version="12"
27+
variables
28+
color
29+
catch_errors
30+
31+
function default_settings() {
32+
CT_TYPE="1"
33+
PW=""
34+
CT_ID=$NEXTID
35+
HN=$NSAPP
36+
DISK_SIZE="$var_disk"
37+
CORE_COUNT="$var_cpu"
38+
RAM_SIZE="$var_ram"
39+
BRG="vmbr0"
40+
NET="dhcp"
41+
GATE=""
42+
APT_CACHER=""
43+
APT_CACHER_IP=""
44+
DISABLEIP6="no"
45+
MTU=""
46+
SD=""
47+
NS=""
48+
MAC=""
49+
VLAN=""
50+
SSH="no"
51+
VERB="no"
52+
echo_default
53+
}
54+
55+
function update_script() {
56+
header_info
57+
check_container_storage
58+
check_container_resources
59+
if [[ ! -d /opt/hoarder ]]; then msg_error "No ${APP} Installation Found!"; exit; fi
60+
RELEASE=$(curl -s https://api.github.com/repos/hoarder-app/hoarder/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
61+
PREV_RELEASE=$(cat /opt/${APP}_version.txt)
62+
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "${PREV_RELEASE}" ]]; then
63+
msg_info "Stopping Services"
64+
systemctl stop hoarder-web hoarder-workers hoarder-browser
65+
msg_ok "Stopped Services"
66+
msg_info "Updating ${APP} to v${RELEASE}"
67+
cd /opt
68+
mv /opt/hoarder/.env /opt/.env
69+
rm -rf /opt/hoarder
70+
wget -q "https://github.com/hoarder-app/hoarder/archive/refs/tags/v${RELEASE}.zip"
71+
unzip -q v${RELEASE}.zip
72+
mv hoarder-${RELEASE} /opt/hoarder
73+
cd /opt/hoarder/apps/web
74+
pnpm install --frozen-lockfile &>/dev/null
75+
pnpm exec next build --experimental-build-mode compile &>/dev/null
76+
cp -r /opt/hoarder/apps/web/.next/standalone/apps/web/server.js /opt/hoarder/apps/web
77+
cd /opt/hoarder/apps/workers
78+
pnpm install --frozen-lockfile &>/dev/null
79+
export DATA_DIR=/opt/hoarder_data
80+
cd /opt/hoarder/packages/db
81+
pnpm migrate &>/dev/null
82+
mv /opt/.env /opt/hoarder/.env
83+
sed -i "s/SERVER_VERSION=${PREV_RELEASE}/SERVER_VERSION=${RELEASE}/" /opt/hoarder/.env
84+
msg_ok "Updated ${APP} to v${RELEASE}"
85+
86+
msg_info "Starting Services"
87+
systemctl start hoarder-browser hoarder-workers hoarder-web
88+
msg_ok "Started Services"
89+
msg_info "Cleaning up"
90+
rm -R /opt/v${RELEASE}.zip
91+
echo "${RELEASE}" >/opt/${APP}_version.txt
92+
msg_ok "Cleaned"
93+
msg_ok "Updated Successfully"
94+
else
95+
msg_ok "No update required. ${APP} is already at ${RELEASE}."
96+
fi
97+
exit
98+
}
99+
100+
start
101+
build_container
102+
description
103+
104+
msg_ok "Completed Successfully!\n"
105+
echo -e "${APP} Setup should be reachable by going to the following URL.
106+
${BL}http://${IP}:3000${CL} \n"

install/hoarder-install.sh

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright (c) 2021-2024 tteck
4+
# Author: MickLesk (Canbiz) & vhsdream
5+
# License: MIT
6+
# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
7+
8+
source /dev/stdin <<< "$FUNCTIONS_FILE_PATH"
9+
color
10+
verb_ip6
11+
catch_errors
12+
setting_up_container
13+
network_check
14+
update_os
15+
16+
msg_info "Installing Dependencies"
17+
$STD apt-get install -y \
18+
g++ \
19+
build-essential \
20+
curl \
21+
git \
22+
sudo \
23+
gnupg \
24+
ca-certificates \
25+
chromium \
26+
mc
27+
msg_ok "Installed Dependencies"
28+
29+
msg_info "Installing Additional Tools"
30+
wget -q https://github.com/Y2Z/monolith/releases/latest/download/monolith-gnu-linux-x86_64 -O /usr/bin/monolith
31+
chmod +x /usr/bin/monolith
32+
wget -q https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux -O /usr/bin/yt-dlp
33+
chmod +x /usr/bin/yt-dlp
34+
msg_ok "Installed Additional Tools"
35+
36+
msg_info "Installing Meilisearch"
37+
cd /tmp
38+
wget -q https://github.com/meilisearch/meilisearch/releases/latest/download/meilisearch.deb
39+
$STD dpkg -i meilisearch.deb
40+
wget -q https://raw.githubusercontent.com/meilisearch/meilisearch/latest/config.toml -O /etc/meilisearch.toml
41+
MASTER_KEY=$(openssl rand -base64 12)
42+
sed -i \
43+
-e 's|^env =.*|env = "production"|' \
44+
-e "s|^# master_key =.*|master_key = \"$MASTER_KEY\"|" \
45+
-e 's|^db_path =.*|db_path = "/var/lib/meilisearch/data"|' \
46+
-e 's|^dump_dir =.*|dump_dir = "/var/lib/meilisearch/dumps"|' \
47+
-e 's|^snapshot_dir =.*|snapshot_dir = "/var/lib/meilisearch/snapshots"|' \
48+
-e 's|^# no_analytics = true|no_analytics = true|' \
49+
/etc/meilisearch.toml
50+
msg_ok "Installed Meilisearch"
51+
52+
msg_info "Installing Node.js"
53+
mkdir -p /etc/apt/keyrings
54+
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
55+
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
56+
$STD apt-get update
57+
$STD apt-get install -y nodejs
58+
msg_ok "Installed Node.js"
59+
60+
msg_info "Installing Hoarder"
61+
cd /opt
62+
RELEASE=$(curl -s https://api.github.com/repos/hoarder-app/hoarder/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
63+
wget -q "https://github.com/hoarder-app/hoarder/archive/refs/tags/v${RELEASE}.zip"
64+
unzip -q v${RELEASE}.zip
65+
mv hoarder-${RELEASE} /opt/hoarder
66+
cd /opt/hoarder
67+
corepack enable
68+
export PUPPETEER_SKIP_DOWNLOAD="true"
69+
export NEXT_TELEMETRY_DISABLED=1
70+
export CI="true"
71+
cd /opt/hoarder/apps/web
72+
$STD pnpm install --frozen-lockfile
73+
$STD pnpm exec next build --experimental-build-mode compile
74+
cp -r /opt/hoarder/apps/web/.next/standalone/apps/web/server.js /opt/hoarder/apps/web
75+
cd /opt/hoarder/apps/workers
76+
$STD pnpm install --frozen-lockfile
77+
78+
export DATA_DIR=/opt/hoarder_data
79+
HOARDER_SECRET=$(openssl rand -base64 36 | cut -c1-24)
80+
cat <<EOF >/opt/hoarder/.env
81+
SERVER_VERSION=$RELEASE
82+
NEXTAUTH_SECRET="$HOARDER_SECRET"
83+
NEXTAUTH_URL="http://localhost:3000"
84+
DATA_DIR="$DATA_DIR"
85+
MEILI_ADDR="http://127.0.0.1:7700"
86+
MEILI_MASTER_KEY="$MASTER_KEY"
87+
BROWSER_WEB_URL="http://127.0.0.1:9222"
88+
89+
# If you're planning to use OpenAI for tagging. Uncomment the following line:
90+
# OPENAI_API_KEY="<API_KEY>"
91+
92+
# If you're planning to use ollama for tagging, uncomment the following lines:
93+
# OLLAMA_BASE_URL="<OLLAMA_ADDR>"
94+
95+
# You can change the models used by uncommenting the following lines, and changing them according to your needs:
96+
# INFERENCE_TEXT_MODEL="gpt-4o-mini"
97+
# INFERENCE_IMAGE_MODEL="gpt-4o-mini"
98+
EOF
99+
echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
100+
msg_ok "Installed Hoarder"
101+
102+
msg_info "Running Database Migration"
103+
mkdir -p ${DATA_DIR}
104+
cd /opt/hoarder/packages/db
105+
$STD pnpm migrate
106+
msg_ok "Database Migration Completed"
107+
108+
msg_info "Creating Services"
109+
cat <<EOF >/etc/systemd/system/meilisearch.service
110+
[Unit]
111+
Description=Meilisearch
112+
After=network.target
113+
114+
[Service]
115+
ExecStart=/usr/bin/meilisearch --config-file-path /etc/meilisearch.toml
116+
Restart=always
117+
118+
[Install]
119+
WantedBy=multi-user.target
120+
EOF
121+
122+
cat <<EOF >/etc/systemd/system/hoarder-web.service
123+
[Unit]
124+
Description=Hoarder Web
125+
Wants=network.target hoarder-workers.service
126+
After=network.target hoarder-workers.service
127+
128+
[Service]
129+
ExecStart=pnpm start
130+
WorkingDirectory=/opt/hoarder/apps/web
131+
EnvironmentFile=/opt/hoarder/.env
132+
Restart=always
133+
134+
[Install]
135+
WantedBy=multi-user.target
136+
EOF
137+
138+
cat <<EOF >/etc/systemd/system/hoarder-browser.service
139+
[Unit]
140+
Description=Hoarder Headless Browser
141+
After=network.target
142+
143+
[Service]
144+
User=root
145+
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
146+
Restart=always
147+
148+
[Install]
149+
WantedBy=multi-user.target
150+
EOF
151+
152+
cat <<EOF >/etc/systemd/system/hoarder-workers.service
153+
[Unit]
154+
Description=Hoarder Workers
155+
Wants=network.target hoarder-browser.service meilisearch.service
156+
After=network.target hoarder-browser.service meilisearch.service
157+
158+
[Service]
159+
ExecStart=pnpm start:prod
160+
WorkingDirectory=/opt/hoarder/apps/workers
161+
EnvironmentFile=/opt/hoarder/.env
162+
Restart=always
163+
TimeoutStopSec=5
164+
165+
[Install]
166+
WantedBy=multi-user.target
167+
EOF
168+
169+
systemctl -q enable --now meilisearch.service hoarder-browser.service hoarder-workers.service hoarder-web.service
170+
msg_ok "Created Services"
171+
172+
motd_ssh
173+
customize
174+
175+
msg_info "Cleaning up"
176+
rm -rf /tmp/meilisearch.deb
177+
rm -f /opt/v${RELEASE}.zip
178+
$STD apt-get autoremove -y
179+
$STD apt-get autoclean -y
180+
msg_ok "Cleaned"

json/hoarder.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "Hoarder",
3+
"slug": "hoarder",
4+
"categories": [
5+
14
6+
],
7+
"date_created": "2024-11-28",
8+
"type": "ct",
9+
"updateable": true,
10+
"privileged": false,
11+
"interface_port": 3000,
12+
"documentation": "https://docs.hoarder.app/",
13+
"website": "https://hoarder.app/",
14+
"logo": "https://raw.githubusercontent.com/hoarder-app/hoarder/refs/heads/main/screenshots/logo.png",
15+
"description": "Hoarder is an AI-powered bookmarking tool that helps you save and organize your digital content. It automatically tags your links, notes, and images, making them easy to find later. With features like auto-fetching, lists, and full-text search, Hoarder is the perfect tool for anyone who wants to keep track of their digital life.",
16+
"install_methods": [
17+
{
18+
"type": "default",
19+
"script": "/ct/hoarder.sh",
20+
"resources": {
21+
"cpu": 2,
22+
"ram": 4096,
23+
"hdd": 8,
24+
"os": "Debian",
25+
"version": "12"
26+
}
27+
}
28+
],
29+
"default_credentials": {
30+
"username": null,
31+
"password": null
32+
},
33+
"notes": []
34+
}

0 commit comments

Comments
 (0)