mirror of
				https://github.com/community-scripts/ProxmoxVE.git
				synced 2025-11-04 10:22:50 +00:00 
			
		
		
		
	Refactor: Linkwarden + OS Upgrade (#4756)
* Refactor: Linkwarden + OS Upgrade * update fetch_and_deploy function * Update linkwarden.sh
This commit is contained in:
		@@ -1,17 +1,17 @@
 | 
				
			|||||||
#!/usr/bin/env bash
 | 
					#!/usr/bin/env bash
 | 
				
			||||||
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
 | 
					source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
 | 
				
			||||||
# Copyright (c) 2021-2025 tteck
 | 
					# Copyright (c) 2021-2025 community-scripts ORG
 | 
				
			||||||
# Author: tteck (tteckster)
 | 
					# Author: MickLesk (CanbiZ)
 | 
				
			||||||
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
 | 
					# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
 | 
				
			||||||
# Source: https://linkwarden.app/
 | 
					# Source: https://linkwarden.app/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
APP="Linkwarden"
 | 
					APP="Linkwarden"
 | 
				
			||||||
var_tags="${var_tags:-bookmark}"
 | 
					var_tags="${var_tags:-bookmark}"
 | 
				
			||||||
var_cpu="${var_cpu:-2}"
 | 
					var_cpu="${var_cpu:-2}"
 | 
				
			||||||
var_ram="${var_ram:-2048}"
 | 
					var_ram="${var_ram:-4096}"
 | 
				
			||||||
var_disk="${var_disk:-12}"
 | 
					var_disk="${var_disk:-12}"
 | 
				
			||||||
var_os="${var_os:-ubuntu}"
 | 
					var_os="${var_os:-ubuntu}"
 | 
				
			||||||
var_version="${var_version:-22.04}"
 | 
					var_version="${var_version:-24.04}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
header_info "$APP"
 | 
					header_info "$APP"
 | 
				
			||||||
variables
 | 
					variables
 | 
				
			||||||
@@ -27,48 +27,36 @@ function update_script() {
 | 
				
			|||||||
    exit
 | 
					    exit
 | 
				
			||||||
  fi
 | 
					  fi
 | 
				
			||||||
  RELEASE=$(curl -fsSL https://api.github.com/repos/linkwarden/linkwarden/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
 | 
					  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
 | 
					  if [[ "${RELEASE}" != "$(cat /opt/linkwarden_version.txt)" ]] || [[ ! -f /opt/linkwarden_version.txt ]]; then
 | 
				
			||||||
    NODE_VERSION="22"
 | 
					    NODE_VERSION="22" NODE_MODULE="yarn@latest" install_node_and_modules
 | 
				
			||||||
    NODE_MODULE="yarn@latest"
 | 
					 | 
				
			||||||
    install_node_and_modules
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    msg_info "Stopping ${APP}"
 | 
					    msg_info "Stopping ${APP}"
 | 
				
			||||||
    systemctl stop linkwarden
 | 
					    systemctl stop linkwarden
 | 
				
			||||||
    msg_ok "Stopped ${APP}"
 | 
					    msg_ok "Stopped ${APP}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    msg_info "Updating Rust"
 | 
					    RUST_CRATES="monolith" install_rust_and_crates
 | 
				
			||||||
    $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"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    msg_info "Updating ${APP} to ${RELEASE}"
 | 
					    msg_info "Updating ${APP} to ${RELEASE}"
 | 
				
			||||||
    cd /opt
 | 
					 | 
				
			||||||
    mv /opt/linkwarden/.env /opt/.env
 | 
					    mv /opt/linkwarden/.env /opt/.env
 | 
				
			||||||
    rm -rf /opt/linkwarden
 | 
					    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) }')
 | 
					    fetch_and_deploy_gh_release "linkwarden/linkwarden"
 | 
				
			||||||
    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
 | 
					 | 
				
			||||||
    cd /opt/linkwarden
 | 
					    cd /opt/linkwarden
 | 
				
			||||||
    $STD yarn
 | 
					    $STD yarn
 | 
				
			||||||
    $STD npx playwright install-deps
 | 
					    $STD npx playwright install-deps
 | 
				
			||||||
    $STD yarn playwright install
 | 
					    $STD yarn playwright install
 | 
				
			||||||
    cp /opt/.env /opt/linkwarden/.env
 | 
					    mv /opt/.env /opt/linkwarden/.env
 | 
				
			||||||
    $STD yarn prisma:generate
 | 
					    $STD yarn prisma:generate
 | 
				
			||||||
    $STD yarn web:build
 | 
					    $STD yarn web:build
 | 
				
			||||||
    $STD yarn prisma:deploy
 | 
					    $STD yarn prisma:deploy
 | 
				
			||||||
    echo "${RELEASE}" >/opt/${APP}_version.txt
 | 
					 | 
				
			||||||
    msg_ok "Updated ${APP} to ${RELEASE}"
 | 
					    msg_ok "Updated ${APP} to ${RELEASE}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    msg_info "Starting ${APP}"
 | 
					    msg_info "Starting ${APP}"
 | 
				
			||||||
    systemctl start linkwarden
 | 
					    systemctl start linkwarden
 | 
				
			||||||
    msg_ok "Started ${APP}"
 | 
					    msg_ok "Started ${APP}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    msg_info "Cleaning up"
 | 
					    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 "Cleaned"
 | 
				
			||||||
    msg_ok "Updated Successfully"
 | 
					    msg_ok "Updated Successfully"
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -23,7 +23,7 @@
 | 
				
			|||||||
        "ram": 2048,
 | 
					        "ram": 2048,
 | 
				
			||||||
        "hdd": 12,
 | 
					        "hdd": 12,
 | 
				
			||||||
        "os": "ubuntu",
 | 
					        "os": "ubuntu",
 | 
				
			||||||
        "version": "22.04"
 | 
					        "version": "24.04"
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  ],
 | 
					  ],
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,8 +1,7 @@
 | 
				
			|||||||
#!/usr/bin/env bash
 | 
					#!/usr/bin/env bash
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Copyright (c) 2021-2025 tteck
 | 
					# Copyright (c) 2021-2025 community-scripts ORG
 | 
				
			||||||
# Author: tteck (tteckster)
 | 
					# Author: MickLesk (Canbiz)
 | 
				
			||||||
# Co-Author: MickLesk (Canbiz)
 | 
					 | 
				
			||||||
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
 | 
					# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
 | 
				
			||||||
# Source: https://linkwarden.app/
 | 
					# Source: https://linkwarden.app/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -17,25 +16,12 @@ update_os
 | 
				
			|||||||
msg_info "Installing Dependencies"
 | 
					msg_info "Installing Dependencies"
 | 
				
			||||||
$STD apt-get install -y \
 | 
					$STD apt-get install -y \
 | 
				
			||||||
  make \
 | 
					  make \
 | 
				
			||||||
  git \
 | 
					  build-essential
 | 
				
			||||||
  build-essential \
 | 
					 | 
				
			||||||
  cargo
 | 
					 | 
				
			||||||
msg_ok "Installed Dependencies"
 | 
					msg_ok "Installed Dependencies"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
NODE_VERSION="22"
 | 
					NODE_VERSION="22" NODE_MODULE="yarn@latest" install_node_and_modules
 | 
				
			||||||
NODE_MODULE="yarn@latest"
 | 
					PG_VERSION="16" install_postgresql
 | 
				
			||||||
install_node_and_modules
 | 
					RUST_CRATES="monolith" install_rust_and_crates
 | 
				
			||||||
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"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
msg_info "Setting up PostgreSQL DB"
 | 
					msg_info "Setting up PostgreSQL DB"
 | 
				
			||||||
DB_NAME=linkwardendb
 | 
					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
 | 
					read -r -p "${TAB3}Would you like to add Adminer? <y/N> " prompt
 | 
				
			||||||
if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then
 | 
					if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then
 | 
				
			||||||
  msg_info "Installing Adminer"
 | 
					  install_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"
 | 
					 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
msg_info "Installing Linkwarden (Patience)"
 | 
					msg_info "Installing Linkwarden (Patience)"
 | 
				
			||||||
cd /opt
 | 
					fetch_and_deploy_gh_release "linkwarden/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
 | 
					 | 
				
			||||||
cd /opt/linkwarden
 | 
					cd /opt/linkwarden
 | 
				
			||||||
$STD yarn
 | 
					$STD yarn
 | 
				
			||||||
$STD npx playwright install-deps
 | 
					$STD npx playwright install-deps
 | 
				
			||||||
$STD yarn playwright install
 | 
					$STD yarn playwright install
 | 
				
			||||||
IP=$(hostname -I | awk '{print $1}')
 | 
					IP=$(hostname -I | awk '{print $1}')
 | 
				
			||||||
env_path="/opt/linkwarden/.env"
 | 
					cat <<EOF >/opt/linkwarden/.env
 | 
				
			||||||
echo " 
 | 
					 | 
				
			||||||
NEXTAUTH_SECRET=${SECRET_KEY}
 | 
					NEXTAUTH_SECRET=${SECRET_KEY}
 | 
				
			||||||
NEXTAUTH_URL=http://${IP}:3000
 | 
					NEXTAUTH_URL=http://${IP}:3000
 | 
				
			||||||
DATABASE_URL=postgresql://${DB_USER}:${DB_PASS}@localhost:5432/${DB_NAME}
 | 
					DATABASE_URL=postgresql://${DB_USER}:${DB_PASS}@localhost:5432/${DB_NAME}
 | 
				
			||||||
" >$env_path
 | 
					EOF
 | 
				
			||||||
$STD yarn prisma:generate
 | 
					$STD yarn prisma:generate
 | 
				
			||||||
$STD yarn web:build
 | 
					$STD yarn web:build
 | 
				
			||||||
$STD yarn prisma:deploy
 | 
					$STD yarn prisma:deploy
 | 
				
			||||||
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
 | 
					 | 
				
			||||||
msg_ok "Installed Linkwarden"
 | 
					msg_ok "Installed Linkwarden"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
msg_info "Creating Service"
 | 
					msg_info "Creating Service"
 | 
				
			||||||
@@ -126,7 +86,9 @@ motd_ssh
 | 
				
			|||||||
customize
 | 
					customize
 | 
				
			||||||
 | 
					
 | 
				
			||||||
msg_info "Cleaning up"
 | 
					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 autoremove
 | 
				
			||||||
$STD apt-get -y autoclean
 | 
					$STD apt-get -y autoclean
 | 
				
			||||||
msg_ok "Cleaned"
 | 
					msg_ok "Cleaned"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -684,7 +684,8 @@ install_mongodb() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
fetch_and_deploy_gh_release() {
 | 
					fetch_and_deploy_gh_release() {
 | 
				
			||||||
  local repo="$1"
 | 
					  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 api_url="https://api.github.com/repos/$repo/releases/latest"
 | 
				
			||||||
  local header=()
 | 
					  local header=()
 | 
				
			||||||
  local attempt=0
 | 
					  local attempt=0
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user