Skip to content

WikiJs LXC Installation, Upgrade and LDAP authentication

Introduction

Wiki.js is an open-source, modern, and feature-rich wiki software. It allows users to create and collaborate on knowledge bases, documentation, and other types of content in a wiki-style format. Wiki.js is designed to be user-friendly and flexible, offering a range of customization options and powerful features for managing and organizing information.

Installation

How to install on a LXC container can be found on this WikiJs manual page.

Upgrade

When installed on an Ubuntu LXC-container the default user is ubuntu.

Stop the wiki service.

service wiki stop

Download the latest version with the next command as the ubuntu user.

sudo -u ubuntu wget "https://github.com/Requarks/wiki/releases/latest/download/wiki-js.tar.gz" -O "/tmp/wiki-js.tar.gz"

Extract tarball to the correct wiki version directory.

mkdir "${HOME}/wiki-x.x.xxx"
tar xzf "${HOME}/download/wiki-js.tar.gz" -C "${HOME}/wiki-x.x.xxx"
"${HOME}/wiki-x.x.xxx"

Reset set the wiki symlink to the latest version for the wiki service.

cd
ln -s wiki-x.x.xxx wiki

Configure the file config.yml or just copy the one from the previous version.

cd "${HOME}/wiki"
cp -i "${HOME}/wiki-y.y.yyy" .

Rebuild the sqlite3 node module to fix an error.

cd "${HOME}/wiki"
npm rebuild sqlite3

Test if all is running well by running the application from the command line and not as a service.

cd "${HOME}/wiki"
node server

When all is okay. Start the wikiservice again as root.

service wiki start

Check if an error occurred.

service wiki status

Update Bash Script

This bash script downloads and retrieves the version from the downloaded tar-file (package.json) and all described earlier. The only thing is that the configuration file (config.yml) between the previous and new version should be compatible.

#!/bin/bash

# Bailout on the first error.
set -e

# Check if the needed commands are installed.
COMMANDS=("wget" "jq" "tar")
for COMMAND in "${COMMANDS[@]}"; do
    if ! command -v "${COMMAND}" >/dev/null; then
        echo "Missing command '${COMMAND}' for this script"
        exit 1
    fi
done

# The user the wiki is running as.
wiki_user="ubuntu"
# Get the wiki user directory.
wiki_user_dir="$(eval echo ~"${wiki_user}")"
# Temporary TAR file.
tar_file="/tmp/wiki-js.tar.gz"
# Wiki application versioned directory prefix.
wiki_dir_prefix="${wiki_user_dir}/wiki-"

echo "Getting ready for WikiJs upgrade..."

# Download the compressed application file.
wget "https://github.com/Requarks/wiki/releases/latest/download/wiki-js.tar.gz" --output-document="${tar_file}"

# Get the version from the json file stored in the compressed file.
wiki_ver="$(tar --extract --file="${tar_file}" package.json -O | jq -r .version)"

# Check if a version was retrieved.
if [[ ! "${wiki_ver}" =~ ^([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
    echo "Could not rettrieve a version from file: ${tar_file}"
else    
    echo "Found a valid version: ${wiki_ver}"
    echo "Existing local versions:"
    echo "$(ls --directory "${wiki_dir_prefix}"*)"
    if [[ -d "${wiki_dir_prefix}${wiki_ver}" ]]; then
        echo "Downloaded version (${wiki_dir_prefix}${wiki_ver}) already exists and bailing out"
#       exit 0
    else
        echo "Downloaded version (${wiki_dir_prefix}${wiki_ver}) does not exist yet..."
    fi 
fi

# Ask for actual upgrade.
read -p "Continue to upgrade [y/n]?" && if [[ $REPLY != [yY] ]] ; then
    echo "Stopped the upgrade."
    exit 0
fi

echo "Decompressing tar file: ${tar_file}"

# Create the destination path.
sudo -u ubuntu mkdir -p "${wiki_dir_prefix}${wiki_ver}"
# Extract the application in its versioned directory as the ubuntu user.
sudo -u ubuntu tar --extract --file="${tar_file}" -C "${wiki_dir_prefix}${wiki_ver}"
# Createt the symbolic link to the config file.
sudo -u ubuntu ln -sr "${wiki_user_dir}/config/config.yml" "${wiki_dir_prefix}${wiki_ver}/"

echo "Fixing Sqlite3 NPM module..."

# Needed rebuild of Sqlite3 NPM module according manual page "https://docs.requarks.io/install/linux".
cd "${wiki_dir_prefix}${wiki_ver}" && sudo -u ubuntu npm rebuild sqlite3

echo "Installing new version directory: ${wiki_dir_prefix}${wiki_ver}"

# Stop the WikiJs service.
systemctl stop wiki

# Update the wiki directory to the new version direcory.
sudo -u ubuntu ln -snrf "${wiki_dir_prefix}${wiki_ver}" "${wiki_user_dir}/wiki"

# Start the WikiJs service.
systemctl start wiki

LDAP Authentication

openssl x509 -issuer_hash -in test.nl.pem strace openssl verify test.nl.pem 2>&1 | grep ENOENT

Field Value
LDAP URL ldaps://app.scanframe.com
Admin Bind DN cn=pam,ou=services,dc=scanframe,dc=com
Admin Bind Credentials
Search Base ou=users,dc=scanframe,dc=com
Search Filter (&(uid={{username}})(objectClass=inetOrgPerson)(memberOf=cn=wiki,ou=systems,dc=scanframe,dc=com)(employeeType=active))
Use TLS Enabled
Verify TLS Certificate Enabled
TLS Certificate Path /etc/ssl/certs/ca-certificates.crt (Empty is also allowed)
Unique ID Field Mapping uid
Display Name Field Mapping displayName
Email Field Mapping mail
Avatar Picture Field Mapping jpegPhoto
Map Groups Enabled
Group Search Base ou=roles,dc=scanframe,dc=com
Group Search Filter (&(objectClass=groupOfNames)(member={{dn}})
Group Search Scope sub
Group DN Property dn
Group Name Field cn
Allow self-registration Enabled