mirror of
https://github.com/YunoHost-Apps/dokuwiki_ynh.git
synced 2024-09-03 18:26:20 +02:00
* [fix] Reactivate integrity check #26 * [fix] Use boolean type for is_public #25 * [fix] isolate user with php-fpm * [fix] boolean is_public for check_process * [fix] Create user for upgrade and restore * [fix] delete choices manifest.json * [fix] load generic function * [fix] delete reload php5-fpm * [fix] owner file with user dokuwiki * [fix] correctly ssowat config for install * [fix] Get file fonction if not been to the current directory * [fix] owner file with user dokuwiki - upgrade * [fix] Clean code * Reload php-fpm et after remove user * [fix] upgrade php5-fpm with a good user * [fix] owner root for all files & owner dokuwiki for write access * [fix] owner root for all files & owner dokuwiki for write access (upgrade script) * [fix] owner read & write for plugins directory
94 lines
No EOL
3 KiB
Bash
Executable file
94 lines
No EOL
3 KiB
Bash
Executable file
#!/bin/bash
|
||
|
||
# Exit on command errors and treat unset variables as an error
|
||
set -eu
|
||
|
||
# This is 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 you are interested the most, since this is
|
||
# guaranteed to be unique. This is a good unique identifier to define installation path,
|
||
# db names, ...
|
||
# Retrieve arguments
|
||
|
||
source .fonctions # Loads the generic functions usually used in the script
|
||
# Source app helpers
|
||
source /usr/share/yunohost/helpers
|
||
|
||
TRAP_ON # Active trap for strop script if detect error.
|
||
|
||
domain=$YNH_APP_ARG_DOMAIN
|
||
path=$YNH_APP_ARG_PATH
|
||
admin=$YNH_APP_ARG_ADMIN
|
||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||
|
||
app=$YNH_APP_INSTANCE_NAME
|
||
|
||
CHECK_VAR "$app" "app name not set"
|
||
|
||
CHECK_USER "$admin"
|
||
|
||
CHECK_PATH
|
||
|
||
CHECK_DOMAINPATH
|
||
|
||
CHECK_FINALPATH
|
||
|
||
# Save app settings
|
||
ynh_app_setting_set $app domain $domain
|
||
ynh_app_setting_set $app path $path
|
||
ynh_app_setting_set $app admin $admin
|
||
ynh_app_setting_set $app is_public $is_public
|
||
|
||
# Create system user dedicace for this app
|
||
ynh_system_user_create $app
|
||
|
||
# Modify dokuwiki conf
|
||
sed -i "s@YNH_ADMIN_USER@$admin@g" ../conf/dokuwiki.php
|
||
|
||
# Copy files to the right place
|
||
sudo mkdir "$final_path"
|
||
ynh_app_setting_set $app final_path $final_path
|
||
|
||
# Get source
|
||
SETUP_SOURCE
|
||
|
||
sudo cp ../conf/dokuwiki.php $final_path/conf
|
||
sudo cp ../conf/acl.auth.php $final_path/conf
|
||
|
||
# Files owned by dokuwiki can just read
|
||
sudo chown -R root: $final_path
|
||
|
||
# except for conf, data, some data subfolders, and lib/plugin, where www-data must have write permissions
|
||
sudo chown -R $app:root $final_path/{conf,data,data/attic,data/cache,data/index,data/locks,data/media*,data/meta,data/pages,data/tmp,lib/plugins,lib/tpl}
|
||
sudo chmod -R 700 $final_path/conf
|
||
sudo chmod -R 700 $final_path/data
|
||
sudo chmod -R 755 $final_path/lib/plugins
|
||
sudo chmod 755 $final_path/lib/tpl/{dokuwiki,dokuwiki/images}
|
||
|
||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
||
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
||
sudo sed -i "s@__PATHTOCHANGE__@$path@g" /etc/nginx/conf.d/$domain.d/$app.conf
|
||
sudo sed -i "s@__FINALPATH__@$final_path@g" /etc/nginx/conf.d/$domain.d/$app.conf
|
||
sudo sed -i "s@__NAMETOCHANGE__@$app@g" /etc/nginx/conf.d/$domain.d/$app.conf
|
||
|
||
if [ "$is_public" = "Yes" ];
|
||
then
|
||
sudo sed -i "s@#--PRIVATE--@@g" /etc/nginx/conf.d/$domain.d/$app.conf
|
||
fi
|
||
|
||
# Create the php-fpm pool config
|
||
POOL_FPM
|
||
|
||
# If app is public, add url to SSOWat conf as skipped_uris
|
||
if [[ $is_public -eq 1 ]]; then
|
||
# unprotected_uris allows SSO credentials to be passed anyway.
|
||
ynh_app_setting_set "$app" unprotected_uris "/"
|
||
fi
|
||
|
||
# Reload Nginx
|
||
sudo systemctl reload nginx |