1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/dokuwiki_ynh.git synced 2024-09-03 18:26:20 +02:00
dokuwiki_ynh/scripts/install
2017-03-07 01:17:59 +01:00

100 lines
3.4 KiB
Bash
Executable file
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/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 # Charge les fonctions génériques habituellement utilisées dans le script
CLEAN_SETUP () {
# Nettoyage des résidus d'installation non pris en charge par le script remove.
# Clean hosts
sudo sed -i '/#DOKUWIKI/d' /etc/hosts
}
TRAP_ON # Active trap pour arrêter le script si une erreur est détectée.
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
# Source app helpers
source /usr/share/yunohost/helpers
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
# 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
SETUP_SOURCE "dokuwiki-c5525093cf2c4f47e2e5d2439fe13964.tgz"
sudo cp ../conf/dokuwiki.php $final_path/conf
sudo cp ../conf/acl.auth.php $final_path/conf
# Files owned by root, www-data can just read
sudo find $final_path -type f -print0 | sudo xargs -0 chmod 0644
sudo find $final_path -type d -print0 | sudo xargs -0 chmod 0755
sudo chown -R www-data: $final_path
# except for conf, data, some data subfolders, and lib/plugin, where www-data must have write permissions
# sudo chown -R www-data: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,data,data/attic,data/cache,data/index,data/locks,data/media*,data/meta,data/pages,data/tmp,lib/plugins,lib/tpl}
# 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
POOL_FPM
# Donne un accès public pour curl
ynh_app_setting_set $app unprotected_uris "/"
# Régénère la configuration de SSOwat
sudo yunohost app ssowatconf
# Reload Nginx and regenerate SSOwat conf
sudo service php5-fpm restart
sudo service nginx reload
if [ "$is_public" = "No" ];
then
# Retire l'accès public
ynh_app_setting_delete $app unprotected_uris
sudo yunohost app ssowatconf
fi
# Nettoyer hosts
sudo sed -i '/#DOKUWIKI/d' /etc/hosts