From c612a4daa8e7ca56c9c42a9d557e02ee96ef14f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Slavi=C5=A1a=20Are=C5=BEina?= <58952836+tremor021@users.noreply.github.com> Date: Thu, 14 Aug 2025 18:01:06 +0200 Subject: [PATCH] Refactor: WikiJS (#6840) * Refactor * Update docs URL --- ct/wikijs.sh | 13 +++---- frontend/public/json/wikijs.json | 66 ++++++++++++++++---------------- install/wikijs-install.sh | 12 ++---- 3 files changed, 41 insertions(+), 50 deletions(-) diff --git a/ct/wikijs.sh b/ct/wikijs.sh index cff7932621..a3464446e8 100644 --- a/ct/wikijs.sh +++ b/ct/wikijs.sh @@ -27,8 +27,9 @@ function update_script() { msg_error "No ${APP} Installation Found!" exit fi + RELEASE=$(curl -fsSL https://api.github.com/repos/Requarks/wiki/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') - if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then + if [[ "${RELEASE}" != "$(cat ~/.wikijs)" ]] || [[ ! -f ~/.wikijs ]]; then msg_info "Verifying whether ${APP}' new release is v3.x+ and current install uses SQLite." SQLITE_INSTALL=$([ -f /opt/wikijs/db.sqlite ] && echo "true" || echo "false") if [[ "${SQLITE_INSTALL}" == "true" && "${RELEASE}" =~ ^3.* ]]; then @@ -47,13 +48,9 @@ function update_script() { cp -R /opt/wikijs/{config.yml,/data} /opt/wikijs-backup msg_ok "Backed up Data" - msg_info "Updating ${APP}" rm -rf /opt/wikijs/* - cd /opt/wikijs - curl -fsSL "https://github.com/requarks/wiki/releases/download/v${RELEASE}/wiki-js.tar.gz" -o $(basename "https://github.com/requarks/wiki/releases/download/v${RELEASE}/wiki-js.tar.gz") - tar -xzf wiki-js.tar.gz - msg_ok "Updated ${APP}" - + fetch_and_deploy_gh_release "wikijs" "requarks/wiki" "prebuild" "latest" "/opt/wikijs" "wiki-js.tar.gz" + msg_info "Restoring Data" cp -R /opt/wikijs-backup/* /opt/wikijs $SQLITE_INSTALL && $STD npm rebuild sqlite3 @@ -64,9 +61,9 @@ function update_script() { msg_ok "Started ${APP}" msg_info "Cleaning Up" - rm -rf /opt/wikijs/wiki-js.tar.gz rm -rf /opt/wikijs-backup msg_ok "Cleanup Completed" + msg_ok "Updated Successfully" else msg_ok "No update required. ${APP} is already at v${RELEASE}" diff --git a/frontend/public/json/wikijs.json b/frontend/public/json/wikijs.json index f7ccceeece..3f623074ab 100644 --- a/frontend/public/json/wikijs.json +++ b/frontend/public/json/wikijs.json @@ -1,35 +1,35 @@ { - "name": "Wiki.js", - "slug": "wikijs", - "categories": [ - 12 - ], - "date_created": "2024-05-02", - "type": "ct", - "updateable": true, - "privileged": false, - "interface_port": 3000, - "documentation": null, - "website": "https://js.wiki/", - "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/wiki-js.webp", - "config_path": "/opt/wikijs/config.yml", - "description": "Wiki.js is a free, open-source, and modern wiki application built using Node.js. It is designed to be fast, easy to use, and flexible, with a range of features for collaboration, knowledge management, and content creation. Wiki.js supports Markdown syntax for editing pages, and includes features such as version control, page history, and access control, making it easy to manage content and collaborate with others. The software is fully customizable, with a range of themes and extensions available, and can be deployed on a local server or in the cloud, making it an ideal choice for small teams and organizations looking to create and manage a wiki. Wiki.js provides a modern, user-friendly interface, and supports a range of data sources, including local file systems, databases, and cloud storage services.", - "install_methods": [ - { - "type": "default", - "script": "ct/wikijs.sh", - "resources": { - "cpu": 2, - "ram": 2048, - "hdd": 7, - "os": "debian", - "version": "12" - } - } - ], - "default_credentials": { - "username": null, - "password": null - }, - "notes": [] + "name": "Wiki.js", + "slug": "wikijs", + "categories": [ + 12 + ], + "date_created": "2024-05-02", + "type": "ct", + "updateable": true, + "privileged": false, + "interface_port": 3000, + "documentation": "https://docs.requarks.io/", + "website": "https://js.wiki/", + "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/wiki-js.webp", + "config_path": "/opt/wikijs/config.yml", + "description": "Wiki.js is a free, open-source, and modern wiki application built using Node.js. It is designed to be fast, easy to use, and flexible, with a range of features for collaboration, knowledge management, and content creation. Wiki.js supports Markdown syntax for editing pages, and includes features such as version control, page history, and access control, making it easy to manage content and collaborate with others. The software is fully customizable, with a range of themes and extensions available, and can be deployed on a local server or in the cloud, making it an ideal choice for small teams and organizations looking to create and manage a wiki. Wiki.js provides a modern, user-friendly interface, and supports a range of data sources, including local file systems, databases, and cloud storage services.", + "install_methods": [ + { + "type": "default", + "script": "ct/wikijs.sh", + "resources": { + "cpu": 2, + "ram": 2048, + "hdd": 7, + "os": "debian", + "version": "12" + } + } + ], + "default_credentials": { + "username": null, + "password": null + }, + "notes": [] } diff --git a/install/wikijs-install.sh b/install/wikijs-install.sh index 5bbfae4923..5c078ab4ed 100644 --- a/install/wikijs-install.sh +++ b/install/wikijs-install.sh @@ -20,6 +20,7 @@ msg_ok "Installed Dependencies" NODE_VERSION="20" NODE_MODULE="yarn@latest,node-gyp" setup_nodejs PG_VERSION="17" setup_postgresql +fetch_and_deploy_gh_release "wikijs" "requarks/wiki" "prebuild" "latest" "/opt/wikijs" "wiki-js.tar.gz" msg_info "Set up PostgreSQL" DB_NAME="wiki" @@ -39,17 +40,11 @@ $STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET timezone TO 'UTC';" } >>~/wikijs.creds msg_ok "Set up PostgreSQL" -msg_info "Setup Wiki.js" -temp_file=$(mktemp) -RELEASE=$(curl -fsSL https://api.github.com/repos/Requarks/wiki/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') -curl -fsSL "https://github.com/requarks/wiki/releases/download/v${RELEASE}/wiki-js.tar.gz" -o ""$temp_file"" -mkdir /opt/wikijs -tar -xzf "$temp_file" -C /opt/wikijs +msg_info "Configuring Wiki.js" mv /opt/wikijs/config.sample.yml /opt/wikijs/config.yml sed -i -E 's|^( *user: ).*|\1'"$DB_USER"'|' /opt/wikijs/config.yml sed -i -E 's|^( *pass: ).*|\1'"$DB_PASS"'|' /opt/wikijs/config.yml -echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt" -msg_ok "Installed Wiki.js" +msg_ok "Configured Wiki.js" msg_info "Creating Service" cat </etc/systemd/system/wikijs.service @@ -75,7 +70,6 @@ motd_ssh customize msg_info "Cleaning up" -rm -f "$temp_file" $STD apt-get -y autoremove $STD apt-get -y autoclean msg_ok "Cleaned"