Refactor: WikiJS (#6840)

* Refactor

* Update docs URL
This commit is contained in:
Slaviša Arežina
2025-08-14 18:01:06 +02:00
committed by GitHub
parent 87b7166924
commit c612a4daa8
3 changed files with 41 additions and 50 deletions

View File

@ -27,8 +27,9 @@ function update_script() {
msg_error "No ${APP} Installation Found!" msg_error "No ${APP} Installation Found!"
exit exit
fi fi
RELEASE=$(curl -fsSL https://api.github.com/repos/Requarks/wiki/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') 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." 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") SQLITE_INSTALL=$([ -f /opt/wikijs/db.sqlite ] && echo "true" || echo "false")
if [[ "${SQLITE_INSTALL}" == "true" && "${RELEASE}" =~ ^3.* ]]; then if [[ "${SQLITE_INSTALL}" == "true" && "${RELEASE}" =~ ^3.* ]]; then
@ -47,12 +48,8 @@ function update_script() {
cp -R /opt/wikijs/{config.yml,/data} /opt/wikijs-backup cp -R /opt/wikijs/{config.yml,/data} /opt/wikijs-backup
msg_ok "Backed up Data" msg_ok "Backed up Data"
msg_info "Updating ${APP}"
rm -rf /opt/wikijs/* rm -rf /opt/wikijs/*
cd /opt/wikijs fetch_and_deploy_gh_release "wikijs" "requarks/wiki" "prebuild" "latest" "/opt/wikijs" "wiki-js.tar.gz"
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}"
msg_info "Restoring Data" msg_info "Restoring Data"
cp -R /opt/wikijs-backup/* /opt/wikijs cp -R /opt/wikijs-backup/* /opt/wikijs
@ -64,9 +61,9 @@ function update_script() {
msg_ok "Started ${APP}" msg_ok "Started ${APP}"
msg_info "Cleaning Up" msg_info "Cleaning Up"
rm -rf /opt/wikijs/wiki-js.tar.gz
rm -rf /opt/wikijs-backup rm -rf /opt/wikijs-backup
msg_ok "Cleanup Completed" msg_ok "Cleanup Completed"
msg_ok "Updated Successfully" msg_ok "Updated Successfully"
else else
msg_ok "No update required. ${APP} is already at v${RELEASE}" msg_ok "No update required. ${APP} is already at v${RELEASE}"

View File

@ -1,35 +1,35 @@
{ {
"name": "Wiki.js", "name": "Wiki.js",
"slug": "wikijs", "slug": "wikijs",
"categories": [ "categories": [
12 12
], ],
"date_created": "2024-05-02", "date_created": "2024-05-02",
"type": "ct", "type": "ct",
"updateable": true, "updateable": true,
"privileged": false, "privileged": false,
"interface_port": 3000, "interface_port": 3000,
"documentation": null, "documentation": "https://docs.requarks.io/",
"website": "https://js.wiki/", "website": "https://js.wiki/",
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/wiki-js.webp", "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/wiki-js.webp",
"config_path": "/opt/wikijs/config.yml", "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.", "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": [ "install_methods": [
{ {
"type": "default", "type": "default",
"script": "ct/wikijs.sh", "script": "ct/wikijs.sh",
"resources": { "resources": {
"cpu": 2, "cpu": 2,
"ram": 2048, "ram": 2048,
"hdd": 7, "hdd": 7,
"os": "debian", "os": "debian",
"version": "12" "version": "12"
} }
} }
], ],
"default_credentials": { "default_credentials": {
"username": null, "username": null,
"password": null "password": null
}, },
"notes": [] "notes": []
} }

View File

@ -20,6 +20,7 @@ msg_ok "Installed Dependencies"
NODE_VERSION="20" NODE_MODULE="yarn@latest,node-gyp" setup_nodejs NODE_VERSION="20" NODE_MODULE="yarn@latest,node-gyp" setup_nodejs
PG_VERSION="17" setup_postgresql 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" msg_info "Set up PostgreSQL"
DB_NAME="wiki" DB_NAME="wiki"
@ -39,17 +40,11 @@ $STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET timezone TO 'UTC';"
} >>~/wikijs.creds } >>~/wikijs.creds
msg_ok "Set up PostgreSQL" msg_ok "Set up PostgreSQL"
msg_info "Setup Wiki.js" msg_info "Configuring 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
mv /opt/wikijs/config.sample.yml /opt/wikijs/config.yml 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|^( *user: ).*|\1'"$DB_USER"'|' /opt/wikijs/config.yml
sed -i -E 's|^( *pass: ).*|\1'"$DB_PASS"'|' /opt/wikijs/config.yml sed -i -E 's|^( *pass: ).*|\1'"$DB_PASS"'|' /opt/wikijs/config.yml
echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt" msg_ok "Configured Wiki.js"
msg_ok "Installed Wiki.js"
msg_info "Creating Service" msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/wikijs.service cat <<EOF >/etc/systemd/system/wikijs.service
@ -75,7 +70,6 @@ motd_ssh
customize customize
msg_info "Cleaning up" msg_info "Cleaning up"
rm -f "$temp_file"
$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"