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!"
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,12 +48,8 @@ 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
@ -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}"

View File

@ -9,7 +9,7 @@
"updateable": true,
"privileged": false,
"interface_port": 3000,
"documentation": null,
"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",

View File

@ -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 <<EOF >/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"