forked from ungleich-public/cdist-contrib
Merge branch 'wikijs' into 'master'
Add a type for wikijs. See merge request ungleich-public/cdist-contrib!15
This commit is contained in:
commit
4918ef464f
11 changed files with 220 additions and 0 deletions
46
type/__wikijs/files/config.yml.sh
Executable file
46
type/__wikijs/files/config.yml.sh
Executable file
|
@ -0,0 +1,46 @@
|
||||||
|
#!/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
|
||||||
|
|
||||||
|
generate_ssl_section () {
|
||||||
|
|
||||||
|
cat << EOF
|
||||||
|
ssl:
|
||||||
|
enabled: ${SSL}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
if [ "$SSL" = "true" ]; then
|
||||||
|
cat << EOF
|
||||||
|
port: $HTTPS_PORT
|
||||||
|
provider: letsencrypt
|
||||||
|
domain: ${__target_host:?}
|
||||||
|
subscriberEmail: ${LE_EMAIL:?}
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
cat << EOF
|
||||||
|
port: $HTTP_PORT
|
||||||
|
db:
|
||||||
|
type: postgres
|
||||||
|
host: localhost
|
||||||
|
port: 5432
|
||||||
|
user: ${DB_USER:?}
|
||||||
|
pass: $1
|
||||||
|
db: ${DB_NAME:?}
|
||||||
|
ssl: false
|
||||||
|
$(generate_ssl_section)
|
||||||
|
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"
|
26
type/__wikijs/gencode-remote
Executable file
26
type/__wikijs/gencode-remote
Executable file
|
@ -0,0 +1,26 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
VERSION_FILE=/var/wiki/version
|
||||||
|
version=$(cat "${__object:?}/parameter/version")
|
||||||
|
|
||||||
|
# Check for installation
|
||||||
|
cat << EOF
|
||||||
|
if [ -f $VERSION_FILE ] && [ "\$(cat $VERSION_FILE)" = "$version" ];
|
||||||
|
then
|
||||||
|
# Assume everything is done already.
|
||||||
|
exit 0;
|
||||||
|
else
|
||||||
|
echo "$version" > $VERSION_FILE
|
||||||
|
fi
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Download and copy source
|
||||||
|
cat << EOF
|
||||||
|
wget -O - https://github.com/Requarks/wiki/releases/download/$version/wiki-js.tar.gz | tar xz -C /var/wiki
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Install deps and launch
|
||||||
|
cat << EOF
|
||||||
|
cd /var/wiki || exit 1
|
||||||
|
service wikijs restart
|
||||||
|
EOF
|
64
type/__wikijs/man.rst
Normal file
64
type/__wikijs/man.rst
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
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 the next 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.
|
||||||
|
|
||||||
|
version
|
||||||
|
'wikijs' version to be deployed.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
http-port
|
||||||
|
Specify HTTP port, defaults to 80.
|
||||||
|
|
||||||
|
http-port
|
||||||
|
Specify HTTPS port, defaults to 443. Only relevant if the SSL flag is enabled.
|
||||||
|
|
||||||
|
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.
|
64
type/__wikijs/manifest
Normal file
64
type/__wikijs/manifest
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
#!/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" = "true" ];
|
||||||
|
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
|
||||||
|
|
||||||
|
HTTP_PORT=$(cat "${__object:?}/parameter/http-port")
|
||||||
|
HTTPS_PORT=$(cat "${__object:?}/parameter/https-port")
|
||||||
|
export HTTP_PORT HTTPS_PORT
|
||||||
|
|
||||||
|
db_pass="$(cat "${__object:?}/parameter/database-password")"
|
||||||
|
|
||||||
|
__package nodejs
|
||||||
|
__directory /var/wiki/
|
||||||
|
|
||||||
|
# These things are Alpine-dependant.
|
||||||
|
__file /etc/init.d/wikijs --source "${__type:?}/files/wikijs-openrc"
|
||||||
|
__package nghttp2-dev # Required for some reason, else a symbol is missing
|
||||||
|
|
||||||
|
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
|
1
type/__wikijs/parameter/default/http-port
Normal file
1
type/__wikijs/parameter/default/http-port
Normal file
|
@ -0,0 +1 @@
|
||||||
|
80
|
1
type/__wikijs/parameter/default/https-port
Normal file
1
type/__wikijs/parameter/default/https-port
Normal file
|
@ -0,0 +1 @@
|
||||||
|
443
|
5
type/__wikijs/parameter/optional
Normal file
5
type/__wikijs/parameter/optional
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
database
|
||||||
|
database-user
|
||||||
|
letsencrypt-mail
|
||||||
|
http-port
|
||||||
|
https-port
|
2
type/__wikijs/parameter/required
Normal file
2
type/__wikijs/parameter/required
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
database-password
|
||||||
|
version
|
0
type/__wikijs/singleton
Normal file
0
type/__wikijs/singleton
Normal file
Loading…
Reference in a new issue