1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/bookstack_ynh.git synced 2024-09-03 18:16:02 +02:00
This commit is contained in:
ericgaspar 2021-01-28 23:21:19 +01:00
parent 593c658194
commit c7707dc1d7
No known key found for this signature in database
GPG key ID: 574F281483054D44
7 changed files with 260 additions and 278 deletions

View file

@ -1,29 +1,72 @@
# BookStack app for YunoHost # BookStack for YunoHost
BookStack Server
**Shipped version:** 0.26.3 [![Integration level](https://dash.yunohost.org/integration/bookstack.svg)](https://dash.yunohost.org/appci/app/bookstack) ![](https://ci-apps.yunohost.org/ci/badges/bookstack.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/bookstack.maintain.svg)
[![Install BookStack with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=bookstack)
- [Yunohost project](https://yunohost.org) *[Lire ce readme en français.](./README_fr.md)*
- [BookStack website](https://github.com/BookStackApp/BookStack/)
![](https://avatars1.githubusercontent.com/u/20912696?s=400&v=4) > *This package allows you to install BookStack quickly and simply on a YunoHost server.
If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
## Overview
Quick description of this app.
[![Install BookStack with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=bookstack) **Shipped version:** 0.31.4
### Installing guide ## Screenshots
App can be installed by YunoHost **admin web-interface** or by **running following command**: ![](https://www.bookstackapp.com/images/screenshots/page-view.png)
$ sudo yunohost app install https://github.com/YunoHost-Apps/bookstack_ynh ## Demo
After install :
1. Login in bookstack
2. your user : admin@admin.com and password : password
* [Official demo](https://www.bookstackapp.com/#demo)
### Upgrade this package:
$ sudo yunohost app upgrade bookstack -u https://github.com/YunoHost-Apps/bookstack_ynh ## Configuration
How to configure this app: From an admin panel, a plain file with SSH, or any other way.
## Documentation
* Official documentation: https://www.bookstackapp.com/docs/
* YunoHost documentation: If specific documentation is needed, feel free to contribute.
## YunoHost specific features
#### Multi-user support
Are LDAP and HTTP auth supported?
Can the app be used by multiple users?
#### Supported architectures
* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/bookstack%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/bookstack/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/bookstack%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/bookstack/)
## Limitations
* Any known limitations.
## Additional information
* Other info you would like to add about this app.
## Links
* Report a bug: https://github.com/YunoHost-Apps/bookstack_ynh/issues
* App website: Link to the official website of this app.
* Upstream app repository: https://github.com/BookStackApp/BookStack
* YunoHost website: https://yunohost.org/
---
## Developer info
**Only if you want to use a testing branch for coding, instead of merging directly into master.**
Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/bookstack_ynh/tree/testing).
To try the testing branch, please proceed like that.
```
sudo yunohost app install https://github.com/YunoHost-Apps/bookstack_ynh/tree/testing --debug
or
sudo yunohost app upgrade bookstack -u https://github.com/YunoHost-Apps/bookstack_ynh/tree/testing --debug
```

View file

@ -8,8 +8,6 @@
domain="domain.tld" (DOMAIN) domain="domain.tld" (DOMAIN)
path="/" (PATH) path="/" (PATH)
is_public=1 (PUBLIC|public=1|private=0) is_public=1 (PUBLIC|public=1|private=0)
# password="pass"
# nextclouddomain="domain.tld"
port="9980" (PORT) port="9980" (PORT)
; Checks ; Checks
pkg_linter=1 pkg_linter=1
@ -21,22 +19,8 @@
upgrade=1 upgrade=1
backup_restore=1 backup_restore=1
multi_instance=1 multi_instance=1
incorrect_path=1
port_already_use=0 port_already_use=0
change_url=0 change_url=0
;;; Levels
Level 1=auto
Level 2=auto
Level 3=auto
# Level 4:
Level 4=1 (This app supports the Nextcloud LDAP auth)
# Level 5:
Level 5=auto
Level 6=auto
Level 7=auto
Level 8=0
Level 9=0
Level 10=0
;;; Options ;;; Options
Email= Email=
Notification=none Notification=none

View file

@ -1,31 +1,44 @@
# This file, when named as ".env" in the root of your BookStack install
# folder, is used for the core configuration of the application.
# By default this file contains the most common required options but
# a full list of options can be found in the '.env.example.complete' file.
# NOTE: If any of your values contain a space or a hash you will need to
# wrap the entire value in quotes. (eg. MAIL_FROM_NAME="BookStack Mailer")
# Application key # Application key
# Used for encryption where needed. # Used for encryption where needed.
# Run `php artisan key:generate` to generate a valid key. # Run `php artisan key:generate` to generate a valid key.
APP_KEY=SomeRandomString APP_KEY=SomeRandomString
# Application URL # Application URL
# Remove the hash below and set a URL if using BookStack behind
# a proxy, if using a third-party authentication option.
# This must be the root URL that you want to host BookStack on. # This must be the root URL that you want to host BookStack on.
# All URL's in BookStack will be generated using this value. # All URLs in BookStack will be generated using this value
#APP_URL=https://example.com # to ensure URLs generated are consistent and secure.
# If you change this in the future you may need to run a command
# to update stored URLs in the database. Command example:
# php artisan bookstack:update-url https://old.example.com https://new.example.com
APP_URL=https:__DOMAIN__
# Database details # Database details
DB_HOST=localhost DB_HOST=localhost
DB_DATABASE=yunobase DB_DATABASE=__DB_NAME__
DB_USERNAME=yunouser DB_USERNAME=__DB_NAME__
DB_PASSWORD=yunopass DB_PASSWORD=__DB_PWD__
# Mail system to use # Mail system to use
# Can be 'smtp', 'mail' or 'sendmail' # Can be 'smtp' or 'sendmail'
MAIL_DRIVER=smtp MAIL_DRIVER=smtp
# Mail sender details
MAIL_FROM_NAME="BookStack"
MAIL_FROM=bookstack@example.com
# SMTP mail options # SMTP mail options
# These settings can be checked using the "Send a Test Email"
# feature found in the "Settings > Maintenance" area of the system.
MAIL_HOST=localhost MAIL_HOST=localhost
MAIL_PORT=1025 MAIL_PORT=1025
MAIL_USERNAME=null MAIL_USERNAME=null
MAIL_PASSWORD=null MAIL_PASSWORD=null
MAIL_ENCRYPTION=null MAIL_ENCRYPTION=null
# A full list of options can be found in the '.env.example.complete' file.

View file

@ -1,19 +1,30 @@
# Force usage of https #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ {
# Path to source
alias __FINALPATH__/public ;
# Force usage of https
if ($scheme = http) { if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent; rewrite ^ https://$server_name$request_uri? permanent;
}
root /var/www/bookstack/public;
index index.php index.html;
location __PATH__/ {
try_files $uri $uri/ /index.php?$query_string;
} }
location ~ \.php$ { try_files $uri $uri/ /index.php?$query_string;
index index.php;
try_files $uri $uri/ index.php;
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
fastcgi_index index.php; fastcgi_index index.php;
try_files $uri =404;
include fastcgi_params; include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param REMOTE_USER $remote_user;
fastcgi_pass unix:/run/php/php7.0-fpm.sock; fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $request_filename;
}
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
} }

View file

@ -3,23 +3,23 @@
"id": "bookstack", "id": "bookstack",
"packaging_format": 1, "packaging_format": 1,
"description": { "description": {
"en": "BookStack package for YunoHost.", "en": "A platform to create documentation/wiki content",
"fr": "BookStack pour YunoHost." "fr": ""
}, },
"version": "0.26.3", "version": "0.31.4~ynh1",
"url": "https://github.com/BookStackApp/BookStack", "url": "https://github.com/BookStackApp/BookStack",
"license": "free", "license": "MIT",
"maintainer": { "maintainer": {
"name": "liberodark", "name": "liberodark",
"email": "liberodark@gmail.com" "email": "liberodark@gmail.com"
}, },
"requirements": { "requirements": {
"yunohost": ">= 2.7.2" "yunohost": ">= 4.0.0"
}, },
"multi_instance": true, "multi_instance": true,
"services": [ "services": [
"nginx", "nginx",
"php5-fpm", "php7.3-fpm",
"mysql" "mysql"
], ],
"arguments": { "arguments": {
@ -32,7 +32,6 @@
}, },
"example": "example.com" "example": "example.com"
}, },
{ {
"name": "path", "name": "path",
"type": "path", "type": "path",
@ -43,15 +42,14 @@
"example": "/", "example": "/",
"default": "/" "default": "/"
}, },
{ {
"name": "is_public", "name": "is_public",
"type": "boolean", "type": "boolean",
"ask": { "ask": {
"en": "Is it a public site ?", "en": "Is it a public site?",
"fr": "Est-ce un site public ?" "fr": "Est-ce un site public ?"
}, },
"default": "true" "default": true
} }
] ]
} }

View file

@ -1,112 +1,85 @@
#!/bin/bash #!/bin/bash
# ============================================================================= #=================================================
# YUNOHOST 2.7 FORTHCOMING HELPERS # COMMON VARIABLES
# ============================================================================= #=================================================
# Create a dedicated nginx config YNH_PHP_VERSION="7.3"
extra_php_dependencies="php${YNH_PHP_VERSION}-cli php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-tidy php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-mysql
"
# dependencies used by the app
#pkg_dependencies="deb1 deb2 php$YNH_DEFAULT_PHP_VERSION-deb1 php$YNH_DEFAULT_PHP_VERSION-deb2"
#=================================================
# PERSONAL HELPERS
#=================================================
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================
readonly YNH_DEFAULT_COMPOSER_VERSION=2.0.8
# Declare the actual composer version to use.
# A packager willing to use another version of composer can override the variable into its _common.sh.
YNH_COMPOSER_VERSION=${YNH_COMPOSER_VERSION:-$YNH_DEFAULT_COMPOSER_VERSION}
# Execute a command with Composer
# #
# usage: ynh_add_nginx_config # usage: ynh_composer_exec [--phpversion=phpversion] [--workdir=$final_path] --commands="commands"
ynh_add_nginx_config () { # | arg: -v, --phpversion - PHP version to use with composer
finalnginxconf="/etc/nginx/conf.d/$domain.d/$app.conf" # | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path.
ynh_backup_if_checksum_is_different "$finalnginxconf" # | arg: -c, --commands - Commands to execute.
sudo cp ../conf/nginx.conf "$finalnginxconf" ynh_composer_exec () {
# Declare an array to define the options of this helper.
local legacy_args=vwc
declare -Ar args_array=( [v]=phpversion= [w]=workdir= [c]=commands= )
local phpversion
local workdir
local commands
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
workdir="${workdir:-$final_path}"
phpversion="${phpversion:-$YNH_PHP_VERSION}"
# To avoid a break by set -u, use a void substitution ${var:-}. If the variable is not set, it's simply set with an empty variable. COMPOSER_HOME="$workdir/.composer" \
# Substitute in a nginx config file only if the variable is not empty php${phpversion} "$workdir/composer.phar" $commands \
if test -n "${path_url:-}"; then -d "$workdir" --quiet --no-interaction
ynh_replace_string "__PATH__" "$path_url" "$finalnginxconf"
fi
if test -n "${domain:-}"; then
ynh_replace_string "__DOMAIN__" "$domain" "$finalnginxconf"
fi
if test -n "${port:-}"; then
ynh_replace_string "__PORT__" "$port" "$finalnginxconf"
fi
if test -n "${app:-}"; then
ynh_replace_string "__NAME__" "$app" "$finalnginxconf"
fi
if test -n "${final_path:-}"; then
ynh_replace_string "__FINALPATH__" "$final_path" "$finalnginxconf"
fi
ynh_store_file_checksum "$finalnginxconf"
sudo systemctl reload nginx
} }
# Remove the dedicated nginx config # Install and initialize Composer in the given directory
# #
# usage: ynh_remove_nginx_config # usage: ynh_install_composer [--phpversion=phpversion] [--workdir=$final_path] [--install_args="--optimize-autoloader"] [--composerversion=composerversion]
ynh_remove_nginx_config () { # | arg: -v, --phpversion - PHP version to use with composer
ynh_secure_remove "/etc/nginx/conf.d/$domain.d/$app.conf" # | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path.
sudo systemctl reload nginx # | arg: -a, --install_args - Additional arguments provided to the composer install. Argument --no-dev already include
} # | arg: -c, --composerversion - Composer version to install
ynh_install_composer () {
# Create a dedicated php-fpm config # Declare an array to define the options of this helper.
# local legacy_args=vwa
# usage: ynh_add_fpm_config declare -Ar args_array=( [v]=phpversion= [w]=workdir= [a]=install_args= [c]=composerversion=)
ynh_add_fpm_config () { local phpversion
finalphpconf="/etc/php5/fpm/pool.d/$app.conf" local workdir
ynh_backup_if_checksum_is_different "$finalphpconf" local install_args
sudo cp ../conf/php-fpm.conf "$finalphpconf" local composerversion
ynh_replace_string "__NAMETOCHANGE__" "$app" "$finalphpconf" # Manage arguments with getopts
ynh_replace_string "__FINALPATH__" "$final_path" "$finalphpconf" ynh_handle_getopts_args "$@"
ynh_replace_string "__USER__" "$app" "$finalphpconf" workdir="${workdir:-$final_path}"
sudo chown root: "$finalphpconf" phpversion="${phpversion:-$YNH_PHP_VERSION}"
ynh_store_file_checksum "$finalphpconf" install_args="${install_args:-}"
composerversion="${composerversion:-$YNH_COMPOSER_VERSION}"
if [ -e "../conf/php-fpm.ini" ]
then curl -sS https://getcomposer.org/installer 2>&1 \
finalphpini="/etc/php5/fpm/conf.d/20-$app.ini" | COMPOSER_HOME="$workdir/.composer" \
ynh_backup_if_checksum_is_different "$finalphpini" php${phpversion} -- --quiet --install-dir="$workdir" --version=$composerversion \
sudo cp ../conf/php-fpm.ini "$finalphpini" || ynh_die "Unable to install Composer." 2>&1
sudo chown root: "$finalphpini"
ynh_store_file_checksum "$finalphpini" # update dependencies to create composer.lock
fi ynh_composer_exec --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev $install_args" \
|| ynh_die "Unable to update core dependencies with Composer."
sudo systemctl reload php5-fpm
}
# Remove the dedicated php-fpm config
#
# usage: ynh_remove_fpm_config
ynh_remove_fpm_config () {
ynh_secure_remove "/etc/php5/fpm/pool.d/$app.conf"
ynh_secure_remove "/etc/php5/fpm/conf.d/20-$app.ini" 2>&1
sudo systemctl reload php5-fpm
}
# Create a dedicated systemd config
#
# usage: ynh_add_systemd_config
ynh_add_systemd_config () {
finalsystemdconf="/etc/systemd/system/$app.service"
ynh_backup_if_checksum_is_different "$finalsystemdconf"
sudo cp ../conf/systemd.service "$finalsystemdconf"
# To avoid a break by set -u, use a void substitution ${var:-}. If the variable is not set, it's simply set with an empty variable.
# Substitute in a nginx config file only if the variable is not empty
if test -n "${final_path:-}"; then
ynh_replace_string "__FINALPATH__" "$final_path" "$finalsystemdconf"
fi
if test -n "${app:-}"; then
ynh_replace_string "__APP__" "$app" "$finalsystemdconf"
fi
ynh_store_file_checksum "$finalsystemdconf"
sudo chown root: "$finalsystemdconf"
sudo systemctl enable $app
sudo systemctl daemon-reload
}
# Remove the dedicated systemd config
#
# usage: ynh_remove_systemd_config
ynh_remove_systemd_config () {
finalsystemdconf="/etc/systemd/system/$app.service"
if [ -e "$finalsystemdconf" ]; then
sudo systemctl stop $app
sudo systemctl disable $app
ynh_secure_remove "$finalsystemdconf"
fi
} }

View file

@ -14,7 +14,6 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
ynh_clean_setup () { ynh_clean_setup () {
### Remove this function if there's nothing to clean before calling the remove script.
true true
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
@ -29,145 +28,99 @@ domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH path_url=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC is_public=$YNH_APP_ARG_IS_PUBLIC
### If it's a multi-instance app, meaning it can be installed several times independently
### The id of the app as stated in the manifest is available as $YNH_APP_ID
### The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
### The app instance name is available as $YNH_APP_INSTANCE_NAME
### - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
### - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
### - ynhexample__{N} for the subsequent installations, with N=3,4, ...
### The app instance name is probably what interests you most, since this is
### guaranteed to be unique. This is a good unique identifier to define installation path,
### db names, ...
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#================================================= #=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=1
### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app".
### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app"
final_path=/var/www/$app final_path=/var/www/$app
test ! -e "$final_path" || ynh_die "This path already contains a folder" test ! -e "$final_path" || ynh_die "This path already contains a folder"
# Normalize the url path syntax
path_url=$(ynh_normalize_url_path $path_url)
# Check web path availability
ynh_webpath_available $domain $path_url
# Register (book) web path # Register (book) web path
ynh_webpath_register $app $domain $path_url ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
#================================================= #=================================================
ynh_script_progression --message="Storing installation settings..." --weight=1
ynh_app_setting_set $app domain $domain ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set $app path $path_url ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set $app is_public $is_public
#==============================================
# INSTALL DEPS
#==============================================
ynh_print_info "Installing dependencies..."
ynh_install_app_dependencies php7.0-fpm php7.0-cli php7.0-curl php7.0-mysql php7.0-ldap php7.0-mbstring php7.0-tidy php7.0-xml php7.0-zip php7.0-gd php7.0-mysql
## Start php7
systemctl enable php7.0-fpm
systemctl start php7.0-fpm
#================================================= #=================================================
# CREATE A MYSQL DATABASE # CREATE A MYSQL DATABASE
#================================================= #=================================================
ynh_print_info "Creating a MySQL database..." ynh_script_progression --message="Creating a MySQL database..." --time --weight=1
### Use these lines if you need a database for the application. db_name=$(ynh_sanitize_dbid --db_name=$app)
### `ynh_mysql_setup_db` will create a database, an associated user and a ramdom password. db_user=$db_name
### The password will be stored as 'mysqlpwd' into the app settings, ynh_app_setting_set --app=$app --key=db_name --value=$db_name
### and will be available as $db_pwd ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
### If you're not using these lines:
### - Remove the section "BACKUP THE MYSQL DATABASE" in the backup script
### - Remove also the section "REMOVE THE MYSQL DATABASE" in the remove script
### - As well as the section "RESTORE THE MYSQL DATABASE" in the restore script
db_name=$(ynh_sanitize_dbid $app)
ynh_app_setting_set $app db_name $db_name
ynh_mysql_setup_db $db_name $db_name
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." --weight=7
ynh_print_info "Download BookStack" ynh_app_setting_set --app=$app --key=final_path --value=$final_path
ynh_app_setting_set $app final_path $final_path
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source "$final_path" ynh_setup_source --dest_dir="$final_path"
#=================================================
# INSTALL BOOKSTACK DEPS
#=================================================
ynh_print_info "Install BookStack composer dependancies"
pushd $final_path || exit
php -r "readfile('https://getcomposer.org/installer');" | php
php composer.phar install
popd || exit
#=================================================
# SPECIFIC SETUP
#=================================================
# setup application config
cp -a ../conf/.env.example $final_path/.env
#=================================================
# MODIFY A CONFIG FILE
#=================================================
ynh_replace_string "yunouser" "$db_name" "$final_path/.env"
ynh_replace_string "yunopass" "$db_pwd" "$final_path/.env"
ynh_replace_string "yunobase" "$db_name" "$final_path/.env"
#=================================================
# FINAL BOOKSTACK INSTALL
#=================================================
ynh_print_info "Install BookStack"
pushd $final_path || exit
php artisan key:generate --no-interaction --force
php artisan migrate --no-interaction --force
chown www-data:www-data -R bootstrap/cache public/uploads storage && chmod -R 755 bootstrap/cache public/uploads storage
popd || exit
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=2
# Create a dedicated nginx config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Configuring system user..." --weight=2
# Create a system user # Create a system user
ynh_system_user_create $app ynh_system_user_create --username=$app
#================================================= #=================================================
# STORE THE CONFIG FILE CHECKSUM # PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Configuring PHP-FPM..." --weight=2
### `ynh_store_file_checksum` is used to store the checksum of a file. # Create a dedicated PHP-FPM config
### That way, during the upgrade script, by using `ynh_backup_if_checksum_is_different`, ynh_add_fpm_config --package="$extra_php_dependencies"
### you can make a backup of this file before modifying it again if the admin had modified it. phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
# Calculate and store the config file checksum into the app settings #=================================================
#ynh_store_file_checksum "$final_path/config.json" # INSTALL LYCHEE WITH COMPOSER
#=================================================
ynh_script_progression --message="Installing BookStack with Composer..." --weight=15
# Install composer
ynh_install_composer --phpversion=$phpversion --workdir=$final_path --install_args="--prefer-source --no-dev"
#=================================================
# MODIFY A CONFIG FILE
#=================================================
cp -a ../conf/.env.example $final_path/.env
ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/.env"
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$final_path/.env"
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/.env"
ynh_store_file_checksum "$final_path/.env"
#=================================================
# FINAL BOOKSTACK INSTALL
#=================================================
ynh_script_progression --message="Install BookStack" --time --weight=1
pushd $final_path
php$phpversion artisan key:generate --no-interaction --force
php$phpversion artisan migrate --no-interaction --force
popd
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
@ -175,23 +128,30 @@ ynh_system_user_create $app
# SECURE FILES AND DIRECTORIES # SECURE FILES AND DIRECTORIES
#================================================= #=================================================
### For security reason, any app should set the permissions to root: before anything else.
### Then, if write authorization is needed, any access should be given only to directories
### that really need such authorization.
# Set permissions to app files # Set permissions to app files
chown -R www-data:www-data $final_path chown -R www-data:www-data $final_path
chmod -R 755 $final_path/bootstrap/cache $final_path/public/uploads $final_path/storage
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
ynh_script_progression --message="Configuring permissions..." --time --weight=1
# If app is public, add url to SSOWat conf as skipped_uris # Make app public if necessary
if [ $is_public -eq 1 ]; then if [ $is_public -eq 1 ]
# unprotected_uris allows SSO credentials to be passed anyway. then
ynh_app_setting_set "$app" unprotected_uris "/" ynh_permission_update --permission="main" --add="visitors"
fi fi
# Reload services #=================================================
systemctl reload nginx # RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --time --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --time --last