Compare commits

...

3 Commits

Author SHA1 Message Date
CanbiZ
4008ec5439 Update linkwarden.sh 2025-05-27 15:54:32 +02:00
CanbiZ
ecc96cb327 update fetch_and_deploy function 2025-05-27 15:54:03 +02:00
CanbiZ
e9da20f40e Refactor: Linkwarden + OS Upgrade 2025-05-27 14:35:37 +02:00
4 changed files with 29 additions and 78 deletions

View File

@ -1,17 +1,17 @@
#!/usr/bin/env bash
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
# Copyright (c) 2021-2025 tteck
# Author: tteck (tteckster)
# Copyright (c) 2021-2025 community-scripts ORG
# Author: MickLesk (CanbiZ)
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://linkwarden.app/
APP="Linkwarden"
var_tags="${var_tags:-bookmark}"
var_cpu="${var_cpu:-2}"
var_ram="${var_ram:-2048}"
var_ram="${var_ram:-4096}"
var_disk="${var_disk:-12}"
var_os="${var_os:-ubuntu}"
var_version="${var_version:-22.04}"
var_version="${var_version:-24.04}"
header_info "$APP"
variables
@ -27,48 +27,36 @@ function update_script() {
exit
fi
RELEASE=$(curl -fsSL https://api.github.com/repos/linkwarden/linkwarden/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then
NODE_VERSION="22"
NODE_MODULE="yarn@latest"
install_node_and_modules
if [[ "${RELEASE}" != "$(cat /opt/linkwarden_version.txt)" ]] || [[ ! -f /opt/linkwarden_version.txt ]]; then
NODE_VERSION="22" NODE_MODULE="yarn@latest" install_node_and_modules
msg_info "Stopping ${APP}"
systemctl stop linkwarden
msg_ok "Stopped ${APP}"
msg_info "Updating Rust"
$STD apt-get install -y build-essential
$STD curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source $HOME/.cargo/env
echo 'export PATH=/usr/local/cargo/bin:$PATH' >>/etc/profile
source /etc/profile
$STD cargo install monolith
msg_ok "Updated Rust"
RUST_CRATES="monolith" install_rust_and_crates
msg_info "Updating ${APP} to ${RELEASE}"
cd /opt
mv /opt/linkwarden/.env /opt/.env
rm -rf /opt/linkwarden
RELEASE=$(curl -fsSL https://api.github.com/repos/linkwarden/linkwarden/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
curl -fsSL "https://github.com/linkwarden/linkwarden/archive/refs/tags/${RELEASE}.zip" -o ${RELEASE}.zip
unzip -q ${RELEASE}.zip
mv linkwarden-${RELEASE:1} /opt/linkwarden
fetch_and_deploy_gh_release "linkwarden/linkwarden"
cd /opt/linkwarden
$STD yarn
$STD npx playwright install-deps
$STD yarn playwright install
cp /opt/.env /opt/linkwarden/.env
mv /opt/.env /opt/linkwarden/.env
$STD yarn prisma:generate
$STD yarn web:build
$STD yarn prisma:deploy
echo "${RELEASE}" >/opt/${APP}_version.txt
msg_ok "Updated ${APP} to ${RELEASE}"
msg_info "Starting ${APP}"
systemctl start linkwarden
msg_ok "Started ${APP}"
msg_info "Cleaning up"
rm -rf /opt/${RELEASE}.zip
rm -rf ~/.cargo/registry ~/.cargo/git ~/.cargo/.package-cache ~/.rustup
rm -rf /root/.cache/yarn
rm -rf /opt/linkwarden/.next/cache
msg_ok "Cleaned"
msg_ok "Updated Successfully"
else

View File

@ -23,7 +23,7 @@
"ram": 2048,
"hdd": 12,
"os": "ubuntu",
"version": "22.04"
"version": "24.04"
}
}
],

View File

@ -1,8 +1,7 @@
#!/usr/bin/env bash
# Copyright (c) 2021-2025 tteck
# Author: tteck (tteckster)
# Co-Author: MickLesk (Canbiz)
# Copyright (c) 2021-2025 community-scripts ORG
# Author: MickLesk (Canbiz)
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://linkwarden.app/
@ -17,25 +16,12 @@ update_os
msg_info "Installing Dependencies"
$STD apt-get install -y \
make \
git \
build-essential \
cargo
build-essential
msg_ok "Installed Dependencies"
NODE_VERSION="22"
NODE_MODULE="yarn@latest"
install_node_and_modules
PG_VERSION="15"
install_postgresql
msg_info "Installing Rust"
curl -fsSL https://sh.rustup.rs -o rustup-init.sh
$STD bash rustup-init.sh -y --profile minimal
echo 'export PATH="$HOME/.cargo/bin:$PATH"' >>~/.bashrc
export PATH="$HOME/.cargo/bin:$PATH"
rm rustup-init.sh
$STD cargo install monolith
msg_ok "Installed Rust"
NODE_VERSION="22" NODE_MODULE="yarn@latest" install_node_and_modules
PG_VERSION="16" install_postgresql
RUST_CRATES="monolith" install_rust_and_crates
msg_info "Setting up PostgreSQL DB"
DB_NAME=linkwardendb
@ -58,50 +44,24 @@ msg_ok "Set up PostgreSQL DB"
read -r -p "${TAB3}Would you like to add Adminer? <y/N> " prompt
if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then
msg_info "Installing Adminer"
$STD apt install -y adminer
$STD a2enconf adminer
systemctl reload apache2
IP=$(hostname -I | awk '{print $1}')
echo "" >>~/linkwarden.creds
echo -e "Adminer Interface: \e[32m$IP/adminer/\e[0m" >>~/linkwarden.creds
echo -e "Adminer System: \e[32mPostgreSQL\e[0m" >>~/linkwarden.creds
echo -e "Adminer Server: \e[32mlocalhost:5432\e[0m" >>~/linkwarden.creds
echo -e "Adminer Username: \e[32m$DB_USER\e[0m" >>~/linkwarden.creds
echo -e "Adminer Password: \e[32m$DB_PASS\e[0m" >>~/linkwarden.creds
echo -e "Adminer Database: \e[32m$DB_NAME\e[0m" >>~/linkwarden.creds
{
echo ""
echo "Adminer-Credentials"
echo "Adminer WebUI: $IP/adminer/"
echo "Adminer Database User: $DB_USER"
echo "Adminer Database Password: $DB_PASS"
echo "Adminer Database Name: $DB_NAME"
} >>~/linkwarden.creds
msg_ok "Installed Adminer"
install_adminer
fi
msg_info "Installing Linkwarden (Patience)"
cd /opt
RELEASE=$(curl -fsSL https://api.github.com/repos/linkwarden/linkwarden/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
curl -fsSL "https://github.com/linkwarden/linkwarden/archive/refs/tags/${RELEASE}.zip" -o ${RELEASE}.zip
unzip -q ${RELEASE}.zip
mv linkwarden-${RELEASE:1} /opt/linkwarden
fetch_and_deploy_gh_release "linkwarden/linkwarden"
cd /opt/linkwarden
$STD yarn
$STD npx playwright install-deps
$STD yarn playwright install
IP=$(hostname -I | awk '{print $1}')
env_path="/opt/linkwarden/.env"
echo "
cat <<EOF >/opt/linkwarden/.env
NEXTAUTH_SECRET=${SECRET_KEY}
NEXTAUTH_URL=http://${IP}:3000
DATABASE_URL=postgresql://${DB_USER}:${DB_PASS}@localhost:5432/${DB_NAME}
" >$env_path
EOF
$STD yarn prisma:generate
$STD yarn web:build
$STD yarn prisma:deploy
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
msg_ok "Installed Linkwarden"
msg_info "Creating Service"
@ -126,7 +86,9 @@ motd_ssh
customize
msg_info "Cleaning up"
rm -rf /opt/${RELEASE}.zip
rm -rf ~/.cargo/registry ~/.cargo/git ~/.cargo/.package-cache ~/.rustup
rm -rf /root/.cache/yarn
rm -rf /opt/linkwarden/.next/cache
$STD apt-get -y autoremove
$STD apt-get -y autoclean
msg_ok "Cleaned"

View File

@ -650,7 +650,8 @@ install_mongodb() {
fetch_and_deploy_gh_release() {
local repo="$1"
local app=${APP:-$(echo "${APPLICATION,,}" | tr -d ' ')}
local raw_app="${APP:-$APPLICATION}"
local app=$(echo "${raw_app,,}" | tr -d ' ')
local api_url="https://api.github.com/repos/$repo/releases/latest"
local header=()
local attempt=0