__wikijs: add version management and HTTP(S) port configuration
This commit is contained in:
parent
647833580d
commit
7122fe1bee
8 changed files with 51 additions and 11 deletions
|
@ -7,8 +7,25 @@ then
|
|||
exit 1;
|
||||
fi
|
||||
|
||||
generate_ssl_section () {
|
||||
|
||||
cat << EOF
|
||||
port: 80
|
||||
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
|
||||
|
@ -17,12 +34,7 @@ db:
|
|||
pass: $1
|
||||
db: ${DB_NAME:?}
|
||||
ssl: false
|
||||
ssl:
|
||||
enabled: ${SSL}
|
||||
port: 443
|
||||
provider: letsencrypt
|
||||
domain: ${__target_host:?}
|
||||
subscriberEmail: ${LE_EMAIL:?}
|
||||
$(generate_ssl_section)
|
||||
pool:
|
||||
min: 2
|
||||
max: 10
|
||||
|
|
14
type/__wikijs/gencode-remote
Normal file → Executable file
14
type/__wikijs/gencode-remote
Normal file → Executable file
|
@ -1,17 +1,22 @@
|
|||
#!/bin/sh
|
||||
|
||||
VERSION_FILE=/var/wiki/version
|
||||
version=$(cat "${__object:?}/parameter/version")
|
||||
|
||||
# Check for installation
|
||||
cat << EOF
|
||||
if [ -f '/var/wiki/LICENSE' ];
|
||||
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/2.4.107/wiki-js.tar.gz | tar xz -C /var/wiki
|
||||
wget -O - https://github.com/Requarks/wiki/releases/download/$version/wiki-js.tar.gz | tar xz -C /var/wiki
|
||||
EOF
|
||||
|
||||
# Install deps and launch
|
||||
|
@ -19,3 +24,8 @@ cat << EOF
|
|||
cd /var/wiki || exit 1
|
||||
npm install
|
||||
EOF
|
||||
|
||||
# Restart service.
|
||||
cat << EOF
|
||||
service wikijs restart
|
||||
EOF
|
||||
|
|
|
@ -22,6 +22,9 @@ REQUIRED PARAMETERS
|
|||
database-password
|
||||
The password to the PSQL database.
|
||||
|
||||
version
|
||||
'wikijs' version to be deployed.
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
|
||||
|
@ -37,6 +40,12 @@ 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
|
||||
------------------
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ then
|
|||
fi
|
||||
export SSL
|
||||
|
||||
if ! [ "$SSL" = "false" ];
|
||||
if [ "$SSL" = "true" ];
|
||||
then
|
||||
if [ -f "${__object:?}/parameter/letsencrypt-mail" ];
|
||||
then
|
||||
|
@ -45,6 +45,10 @@ then
|
|||
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
|
||||
|
@ -52,7 +56,7 @@ __package npm
|
|||
__directory /var/wiki/
|
||||
|
||||
# These things are Alpine-dependant.
|
||||
__file /etc/init.d/wikijs --source "${__files:?}/files/wikijs-openrc"
|
||||
__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"
|
||||
|
|
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
|
|
@ -1,3 +1,5 @@
|
|||
database
|
||||
database-user
|
||||
letsencrypt-mail
|
||||
http-port
|
||||
https-port
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
database-password
|
||||
version
|
||||
|
|
Loading…
Reference in a new issue