Add a type for wikijs.
This commit is contained in:
parent
f4375dbbb9
commit
0e4bc443e2
9 changed files with 189 additions and 0 deletions
34
type/__wikijs/files/config.yml.sh
Executable file
34
type/__wikijs/files/config.yml.sh
Executable file
|
@ -0,0 +1,34 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
if [ $# -ne 1 ];
|
||||||
|
then
|
||||||
|
echo "You have to give me the database password as an argument:"
|
||||||
|
echo "on some systems, anyone can read env(1)."
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat << EOF
|
||||||
|
port: 80
|
||||||
|
db:
|
||||||
|
type: postgres
|
||||||
|
host: localhost
|
||||||
|
port: 5432
|
||||||
|
user: ${DB_USER:?}
|
||||||
|
pass: $1
|
||||||
|
db: ${DB_NAME:?}
|
||||||
|
ssl: false
|
||||||
|
ssl:
|
||||||
|
enabled: ${SSL}
|
||||||
|
port: 443
|
||||||
|
provider: letsencrypt
|
||||||
|
domain: ${__target_host:?}
|
||||||
|
subscriberEmail: ${LE_EMAIL:?}
|
||||||
|
pool:
|
||||||
|
min: 2
|
||||||
|
max: 10
|
||||||
|
bindIP: 0.0.0.0
|
||||||
|
logLevel: warn
|
||||||
|
offline: false
|
||||||
|
ha: false
|
||||||
|
dataPath: ./data
|
||||||
|
EOF
|
10
type/__wikijs/files/wikijs-openrc
Normal file
10
type/__wikijs/files/wikijs-openrc
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#!/sbin/openrc-run
|
||||||
|
|
||||||
|
command='/usr/bin/node'
|
||||||
|
command_args='server'
|
||||||
|
command_background=true
|
||||||
|
description="Run wiki.js"
|
||||||
|
directory='/var/wiki'
|
||||||
|
error_log=/var/log/"$RC_SVCNAME".err
|
||||||
|
output_log=/var/log/"$RC_SVCNAME".log
|
||||||
|
pidfile="/run/$RC_SVCNAME.pid"
|
25
type/__wikijs/gencode-remote
Normal file
25
type/__wikijs/gencode-remote
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Check for installation
|
||||||
|
cat << EOF
|
||||||
|
if [ -f '/var/wiki/LICENSE' ];
|
||||||
|
then
|
||||||
|
# Assume everything is done already.
|
||||||
|
exit 0;
|
||||||
|
fi
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Download and copy source
|
||||||
|
cat << EOF
|
||||||
|
TMPDIR=\$(mktemp -d)
|
||||||
|
cd \$TMPDIR || exit 1
|
||||||
|
wget https://github.com/Requarks/wiki/releases/download/2.4.107/wiki-js.tar.gz
|
||||||
|
tar xf wiki-js.tar.gz -C /var/wiki
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Install deps and launch
|
||||||
|
cat << EOF
|
||||||
|
cd /var/wiki || exit 1
|
||||||
|
npm install
|
||||||
|
service start wikijs
|
||||||
|
EOF
|
55
type/__wikijs/man.rst
Normal file
55
type/__wikijs/man.rst
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
cdist-type__wikijs(7)
|
||||||
|
========================
|
||||||
|
|
||||||
|
NAME
|
||||||
|
----
|
||||||
|
cdist-type__wikijs - Deploy the wiki.js software.
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
-----------
|
||||||
|
|
||||||
|
See wiki.js.org for more information. This type deploys with a postgresql
|
||||||
|
database, since it is the upstream recommended for production, and they seem to
|
||||||
|
strongly suggest that in thenext releases, they will not support anything else.
|
||||||
|
|
||||||
|
Currently, this type servers wikijs as standalone, listening on ports 80 and
|
||||||
|
443, and with a service file for OpenRC. Feel free to contribute a
|
||||||
|
generalisation if you require one.
|
||||||
|
|
||||||
|
REQUIRED PARAMETERS
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
database-password
|
||||||
|
The password to the PSQL database.
|
||||||
|
|
||||||
|
OPTIONAL PARAMETERS
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
database
|
||||||
|
The name of the PSQL database to connect to. If omitted, then 'wikijs' is
|
||||||
|
used.
|
||||||
|
|
||||||
|
database-user
|
||||||
|
The name of the PSQL database user to connec as. If omitted, then 'wikijs' is
|
||||||
|
used.
|
||||||
|
|
||||||
|
letsencrypt-mail
|
||||||
|
If the SSL parameter is passed, then we setup wikijs to automatically obtain
|
||||||
|
certificates: this is the email used to sign up to a LE account.
|
||||||
|
|
||||||
|
BOOLEAN PARAMETERS
|
||||||
|
------------------
|
||||||
|
|
||||||
|
ssl
|
||||||
|
Whether or not to enable the wikijs automatic obtention of LE certificates.
|
||||||
|
|
||||||
|
AUTHORS
|
||||||
|
-------
|
||||||
|
Joachim Desroches <joachim.desroches@epfl.ch>
|
||||||
|
|
||||||
|
COPYING
|
||||||
|
-------
|
||||||
|
Copyright \(C) 2020 Joachim Desroches. You can redistribute it
|
||||||
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of the
|
||||||
|
License, or (at your option) any later version.
|
60
type/__wikijs/manifest
Normal file
60
type/__wikijs/manifest
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
os="$(cat "${__global:?}"/explorer/os)"
|
||||||
|
|
||||||
|
case "$os" in
|
||||||
|
alpine)
|
||||||
|
:
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "This type has no implementation for $os. Aborting." >&2;
|
||||||
|
exit 1;
|
||||||
|
esac
|
||||||
|
|
||||||
|
DB_USER=wikijs
|
||||||
|
if [ -f "${__object:?}/parameter/database-user" ];
|
||||||
|
then
|
||||||
|
DB_USER="$(cat "${__object:?}/parameter/database-user")"
|
||||||
|
fi
|
||||||
|
export DB_USER
|
||||||
|
|
||||||
|
DB_NAME=wikijs
|
||||||
|
if [ -f "${__object:?}/parameter/database" ];
|
||||||
|
then
|
||||||
|
DB_NAME="$(cat "${__object:?}/parameter/database")"
|
||||||
|
fi
|
||||||
|
export DB_NAME
|
||||||
|
|
||||||
|
SSL=false
|
||||||
|
if [ -f "${__object:?}/parameter/ssl" ];
|
||||||
|
then
|
||||||
|
SSL=true
|
||||||
|
fi
|
||||||
|
export SSL
|
||||||
|
|
||||||
|
if ! [ "$SSL" = "false" ];
|
||||||
|
then
|
||||||
|
if [ -f "${__object:?}/parameter/letsencrypt-mail" ];
|
||||||
|
then
|
||||||
|
LE_EMAIL="$(cat "${__object:?}/parameter/letsencrypt-mail")"
|
||||||
|
export LE_EMAIL
|
||||||
|
else
|
||||||
|
echo "You must specify an email account if you request SSL."
|
||||||
|
echo "Hit me."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
db_pass="$(cat "${__object:?}/parameter/database-password")"
|
||||||
|
|
||||||
|
__package nodejs
|
||||||
|
__package nghttp2-dev # Required for some reason, else a symbol is missing
|
||||||
|
__package npm
|
||||||
|
__directory /var/wiki/
|
||||||
|
__file /etc/init.d/wikijs --source "${__files:?}/files/wikijs-openrc"
|
||||||
|
require='__file/etc/init.d/wikijs' __start_on_boot wikijs
|
||||||
|
|
||||||
|
mkdir -p "${__object:?}/files"
|
||||||
|
"${__type:?}/files/config.yml.sh" "$db_pass" > "${__object:?}/files/config.yml"
|
||||||
|
require='__directory/var/wiki' \
|
||||||
|
__file /var/wiki/config.yml --source "${__object:?}/files/config.yml"
|
1
type/__wikijs/parameter/boolean
Normal file
1
type/__wikijs/parameter/boolean
Normal file
|
@ -0,0 +1 @@
|
||||||
|
ssl
|
3
type/__wikijs/parameter/optional
Normal file
3
type/__wikijs/parameter/optional
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
database
|
||||||
|
database-user
|
||||||
|
letsencrypt-mail
|
1
type/__wikijs/parameter/required
Normal file
1
type/__wikijs/parameter/required
Normal file
|
@ -0,0 +1 @@
|
||||||
|
database-password
|
0
type/__wikijs/singleton
Normal file
0
type/__wikijs/singleton
Normal file
Loading…
Reference in a new issue