1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/opensondage_ynh.git synced 2024-09-03 19:46:28 +02:00

Add helpers and style

This commit is contained in:
Jean-Baptiste Holcroft 2017-10-25 17:27:32 +02:00
parent 133a66296f
commit 29ccb4642c
7 changed files with 347 additions and 197 deletions

View file

@ -1,5 +1,5 @@
location PATHTOCHANGE { location __PATH__ {
alias ALIASTOCHANGE; alias __FINALPATH__/;
if ($scheme = http) { if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent; rewrite ^ https://$server_name$request_uri? permanent;
} }
@ -7,7 +7,7 @@ location PATHTOCHANGE {
try_files $uri $uri/ /index.php; try_files $uri $uri/ /index.php;
location ~ [^/]\.php(/|$) { location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php5-fpm-YNH_APP_INSTANCE_NAME.sock; fastcgi_pass unix:/var/run/php5-fpm-__NAME__.sock;
include fastcgi_params; include fastcgi_params;
fastcgi_param REMOTE_USER $remote_user; fastcgi_param REMOTE_USER $remote_user;
fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_INFO $fastcgi_path_info;
@ -18,6 +18,6 @@ location PATHTOCHANGE {
include conf.d/yunohost_panel.conf.inc; include conf.d/yunohost_panel.conf.inc;
} }
location ~ ^PATHTOCHANGE/(data|config|\.ht|db_structure\.xml|README) { location ~ ^__PATH__/(data|config|\.ht|db_structure\.xml|README) {
deny all; deny all;
} }

View file

@ -1,7 +1,7 @@
; Start a new pool named 'www'. ; Start a new pool named 'www'.
; the variable $pool can we used in any directive and will be replaced by the ; the variable $pool can we used in any directive and will be replaced by the
; pool name ('www' here) ; pool name ('www' here)
[NAMETOCHANGE] [__NAMETOCHANGE__]
; Per pool prefix ; Per pool prefix
; It only applies on the following directives: ; It only applies on the following directives:
@ -24,7 +24,7 @@
; specific port; ; specific port;
; '/path/to/unix/socket' - to listen on a unix socket. ; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory. ; Note: This value is mandatory.
listen = /var/run/php5-fpm-NAMETOCHANGE.sock listen = /var/run/php5-fpm-__NAMETOCHANGE__.sock
; Set listen(2) backlog. A value of '-1' means unlimited. ; Set listen(2) backlog. A value of '-1' means unlimited.
; Default Value: 128 (-1 on FreeBSD and OpenBSD) ; Default Value: 128 (-1 on FreeBSD and OpenBSD)
@ -170,7 +170,7 @@ request_slowlog_timeout = 5s
; The log file for slow requests ; The log file for slow requests
; Default Value: not set ; Default Value: not set
; Note: slowlog is mandatory if request_slowlog_timeout is set ; Note: slowlog is mandatory if request_slowlog_timeout is set
slowlog = /var/log/nginx/NAMETOCHANGE.slow.log slowlog = /var/log/nginx/__NAMETOCHANGE__.slow.log
; Set open file descriptor rlimit. ; Set open file descriptor rlimit.
; Default Value: system defined value ; Default Value: system defined value
@ -195,7 +195,7 @@ rlimit_core = 0
; Chdir to this directory at the start. ; Chdir to this directory at the start.
; Note: relative path can be used. ; Note: relative path can be used.
; Default Value: current directory or / when chroot ; Default Value: current directory or / when chroot
chdir = /var/www/NAMETOCHANGE chdir = __FINALPATH__
; Redirect worker stdout and stderr into main error log. If not set, stdout and ; Redirect worker stdout and stderr into main error log. If not set, stdout and
; stderr will be redirected to /dev/null according to FastCGI specs. ; stderr will be redirected to /dev/null according to FastCGI specs.

View file

@ -27,20 +27,35 @@ ynh_abort_if_errors
# See comments in install script # See comments in install script
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
db_name=$(ynh_app_setting_get "$app" db_name)
dbuser=$app
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
domain=$(ynh_app_setting_get "$app" domain)
#=================================================
# STANDARD BACKUP STEPS
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
# Backup sources & data # Backup sources & data
ynh_backup "/var/www/$app" ynh_backup "/var/www/$app"
# Dump the database #=================================================
dbname=$app # BACKUP THE NGINX CONFIGURATION
dbuser=$app #=================================================
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
mysqldump -u "$dbuser" -p"$dbpass" --no-create-db "$dbname" > ./dump.sql
# Copy NGINX configuration ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
domain=$(ynh_app_setting_get "$app" domain)
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf"
# Copy PHP-FPM pool configuration #=================================================
ynh_backup "/etc/php5/fpm/pool.d/${app}.conf" "php-fpm.conf" # BACKUP THE PHP-FPM CONFIGURATION
ynh_backup "/etc/php5/fpm/conf.d/20-${app}.ini" "php-fpm.ini" #=================================================
ynh_backup "/etc/php5/fpm/pool.d/$app.conf"
ynh_backup "/etc/php5/fpm/conf.d/20-$app.ini"
#=================================================
# BACKUP THE MYSQL DATABASE
#=================================================
ynh_mysql_dump_db "$db_name" > db.sql

View file

@ -24,30 +24,56 @@ app=$YNH_APP_INSTANCE_NAME
# Retrieve arguments # Retrieve arguments
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
path=$YNH_APP_ARG_PATH path_url=$YNH_APP_ARG_PATH
admin=$YNH_APP_ARG_ADMIN admin=$YNH_APP_ARG_ADMIN
language=$YNH_APP_ARG_LANGUAGE language=$YNH_APP_ARG_LANGUAGE
is_public=$YNH_APP_ARG_IS_PUBLIC is_public=$YNH_APP_ARG_IS_PUBLIC
legal='no'
# Check if admin exists #=================================================
ynh_user_exists $admin \ # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|| ynh_die "Wrong admin" #=================================================
final_path=/var/www/$app
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
ynh_webpath_register $app $domain $path_url
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_app_setting_set "$app" domain "$domain"
ynh_app_setting_set "$app" path_url "$path_url"
ynh_app_setting_set "$app" admin "$admin" ynh_app_setting_set "$app" admin "$admin"
ynh_app_setting_set "$app" language "$language" ynh_app_setting_set "$app" language "$language"
ynh_app_setting_set "$app" legal "$legal"
ynh_app_setting_set "$app" is_public "$is_public" ynh_app_setting_set "$app" is_public "$is_public"
# Deprecated
ynh_app_setting_set "$app" public_site "$is_public" ynh_app_setting_set "$app" public_site "$is_public"
# Check domain/path availability #=================================================
yunohost app checkurl "${domain}${path}" -a "$app" \ # STANDARD MODIFICATIONS
|| ynh_die "Path not available: ${domain}${path}" #=================================================
# INSTALL DEPENDENCIES
#=================================================
# Copy files to the right place ynh_install_app_dependencies php-fpdf
final_path=/var/www/$app
mkdir -p $final_path #=================================================
# CREATE A MYSQL DATABASE
#=================================================
# Generate MySQL password and create database
dbuser=$app
db_name=$app
dbpass=$(ynh_string_random 12)
ynh_app_setting_set "$app" mysqlpwd "$dbpass"
ynh_app_setting_set "$app" db_name "$db_name"
ynh_mysql_create_db "$db_name" "$dbuser" "$dbpass"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
@ -57,12 +83,25 @@ 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 "$final_path"
# Generate MySQL password and create database #=================================================
dbuser=$app # NGINX CONFIGURATION
dbname=$app #=================================================
dbpass=$(ynh_string_random 12)
ynh_app_setting_set "$app" mysqlpwd "$dbpass" # Create a dedicated nginx config
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass" ynh_add_nginx_config
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
# Create a dedicated php-fpm config
ynh_add_fpm_config
#=================================================
# SPECIFIC SETUP
#=================================================
# Create config.php
#=================================================
config="$final_path/app/inc/config.php" config="$final_path/app/inc/config.php"
cp ../conf/config.php $config cp ../conf/config.php $config
@ -70,54 +109,67 @@ cp ../conf/config.php $config
# Change variables in configuration # Change variables in configuration
ynh_replace_string "__DBUSER__" "$dbuser" $config ynh_replace_string "__DBUSER__" "$dbuser" $config
ynh_replace_string "__DBPWD__" "$dbpass" $config ynh_replace_string "__DBPWD__" "$dbpass" $config
ynh_replace_string "__DBNAME__" "$dbname" $config ynh_replace_string "__DBNAME__" "$db_name" $config
ynh_replace_string "__ADMINMAIL__" "$admin" $config ynh_replace_string "__ADMINMAIL__" "$admin" $config
ynh_replace_string "__LANGUAGE__" "$language" $config ynh_replace_string "__LANGUAGE__" "$language" $config
ynh_replace_string "__DOMAIN__" "$domain" $config ynh_replace_string "__DOMAIN__" "$domain" $config
ynh_replace_string "__PATH__" "$path" $config ynh_replace_string "__PATH__" "$path_url" $config
#=================================================
# Replace logo image (default is FramaDate)
#=================================================
cp ../img/logo.png $final_path/images cp ../img/logo.png $final_path/images
#=================================================
# STORE THE CHECKSUM OF THE CONFIG FILE
#=================================================
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "$config"
#=================================================
# Create log file
#=================================================
# Create log file # Create log file
touch $final_path/admin/stdout.log touch $final_path/admin/stdout.log
chmod 700 $final_path/admin/stdout.log
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set permissions # Set permissions
chown -R www-data: $final_path chown -R www-data: $final_path
#=================================================
# Run database initilization
#=================================================
init_composer "www-data" "$final_path" init_composer "www-data" "$final_path"
-u "www-data" php "$final_path/admin/migration.php" sudo -u "www-data" php "$final_path/admin/migration.php"
# Modify PHP-FPM pool configuration and copy it to the pool directory #=================================================
ynh_replace_string "NAMETOCHANGE" "$app" ../conf/php-fpm.conf # SETUP SSOWAT
finalphpconf=/etc/php5/fpm/pool.d/$app.conf #=================================================
cp ../conf/php-fpm.conf $finalphpconf
chown root: $finalphpconf
chmod 644 $finalphpconf
finalphpini=/etc/php5/fpm/conf.d/20-$app.ini
cp ../conf/php-fpm.ini $finalphpini
chown root: $finalphpini
chmod 644 $finalphpini
# Reload Nginx and regenerate SSOwat conf
service php5-fpm restart
ynh_package_install php-fpdf
yunohost app addaccess $app -u $admin
# Modify Nginx configuration file and copy it to Nginx conf directory
ynh_replace_string "PATHTOCHANGE" "$path" ../conf/nginx.conf
ynh_replace_string "ALIASTOCHANGE" "$final_path" ../conf/nginx.conf
ynh_replace_string "YNH_APP_INSTANCE_NAME" "$app" ../conf/nginx.conf
cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
# Reload Nginx and regenerate SSOwat conf
service nginx reload
ynh_app_setting_set "$app" skipped_uris "/" ynh_app_setting_set "$app" skipped_uris "/"
if [[ $is_public -eq 0 ]]; if [[ $is_public -eq 0 ]];
then then
ynh_app_setting_set "$app" protected_uris "/admin,/index.php,/choix_date.php,/choix_autre.php,/infos_sondage.php,/scripts" ynh_app_setting_set "$app" protected_uris "/admin,/index.php,/choix_date.php,/choix_autre.php,/infos_sondage.php,/scripts"
else else
ynh_app_setting_set "$app" protected_uris "/admin/index.php,/admin/logs_studs.txt,/scripts" ynh_app_setting_set "$app" protected_uris "/admin/index.php,/admin/stdout.log,/scripts"
ynh_replace_string " include conf.d/" " #include conf.d/" "$finalnginxconf"
ynh_store_file_checksum "$finalnginxconf"
fi fi
yunohost app ssowatconf
#=================================================
# RELOAD NGINX
#=================================================
systemctl reload nginx

View file

@ -18,20 +18,40 @@ app=$YNH_APP_INSTANCE_NAME
# Retrieve app settings # Retrieve app settings
domain=$(ynh_app_setting_get "$app" domain) domain=$(ynh_app_setting_get "$app" domain)
# Remove sources #=================================================
# STANDARD REMOVE
#=================================================
# REMOVE DEPENDENCIES
#=================================================
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# REMOVE THE MYSQL DATABASE
#=================================================
# Remove a database if it exists, along with the associated user
db_name=$app
dbuser=$app
ynh_mysql_remove_db "$db_name" "$dbuser"
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_secure_remove "/var/www/$app" ynh_secure_remove "/var/www/$app"
# Remove configuration files #=================================================
ynh_secure_remove /etc/nginx/conf.d/$domain.d/$app.conf # REMOVE NGINX CONFIGURATION
#=================================================
ynh_secure_remove /etc/php5/fpm/pool.d/$app.conf # Remove the dedicated nginx config
ynh_secure_remove /etc/php5/fpm/conf.d/20-$app.ini ynh_remove_nginx_config
# Drop MySQL database and user #=================================================
dbname=$app # REMOVE PHP-FPM CONFIGURATION
dbuser=$app #=================================================
ynh_mysql_drop_db "$dbname" || true
ynh_mysql_drop_user "$dbuser" || true
service nginx reload # Remove the dedicated php-fpm config
service php5-fpm reload ynh_remove_fpm_config

View file

@ -30,77 +30,75 @@ app=$YNH_APP_INSTANCE_NAME
# Retrieve old app settings # Retrieve old app settings
domain=$(ynh_app_setting_get "$app" domain) domain=$(ynh_app_setting_get "$app" domain)
path=$(ynh_app_setting_get "$app" path) path_url=$(ynh_app_setting_get "$app" path)
admin=$(ynh_app_setting_get "$app" admin) admin=$(ynh_app_setting_get "$app" admin)
is_public=$(ynh_app_setting_get "$app" is_public) is_public=$(ynh_app_setting_get "$app" is_public)
public_site=$(ynh_app_setting_get "$app" public_site) public_site=$(ynh_app_setting_get "$app" public_site)
legal=$(ynh_app_setting_get "$app" legal) db_name=$(ynh_app_setting_get "$app" db_name)
dbuser=$app
final_path=$(ynh_app_setting_get "$app" final_path)
# Check domain/path availability #=================================================
yunohost app checkurl $domain$path -a $app \ # CHECK IF THE APP CAN BE RESTORED
|| ynh_die "Path not available: ${domain}${path}" #================================================
ynh_webpath_available $domain $path_url \
|| ynh_die "Path not available: ${domain}${path_url}"
test ! -d $final_path \
|| ynh_die "There is already a directory: $final_path"
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_restore_file "$final_path"
#=================================================
# RESTORE USER RIGHTS
#=================================================
# Set permissions
chown -R www-data:www-data $final_path
final_path=/var/www/$app #=================================================
if [ -d $final_path ]; then # RESTORE THE PHP-FPM CONFIGURATION
ynh_die "There is already a directory: $final_path " #=================================================
fi
conf=/etc/nginx/conf.d/$domain.d/$app.conf ynh_restore_file "/etc/php5/fpm/pool.d/$app.conf"
if [ -f $conf ]; then ynh_restore_file "/etc/php5/fpm/conf.d/20-$app.ini"
ynh_die "There is already a nginx conf file at this path: $conf "
fi
phpconf=/etc/php5/fpm/pool.d/$app.conf #=================================================
if [ -f $phpconf ]; then # RESTORE THE MYSQL DATABASE
ynh_die "There is already a php-fpm conf file at this path: $phpconf " #=================================================
fi
phpini=/etc/php5/fpm/conf.d/20-$app.ini dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
if [ -f $phpini ]; then ynh_mysql_setup_db "$db_name" "$db_name" "$db_pwd"
ynh_die "There is already a php-fpm ini file at this path: $phpini " ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" < ./db.sql
fi
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
# Dependences # Dependences
ynh_package_install php-fpdf ynh_package_install php-fpdf
# Restore sources & data #=================================================
ynh_restore_file "$final_path" # GENERIC FINALIZATION
#=================================================
dbname=$app # RELOAD NGINX AND PHP-FPM
dbuser=$app #=================================================
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./dump.sql
# Set permissions
chmod 700 $final_path/admin/logs_studs.txt
chown -R www-data:www-data $final_path
# Restore conf files
cp -a ./nginx.conf $conf
cp -a ./php-fpm.conf $phpconf
chown root: $phpconf
chmod 644 $phpconf
cp -a ./php-fpm.ini $phpini
chown root: $phpini
chmod 644 $phpini
# Set Administrator
if ynh_user_exists $admin; then
yunohost app addaccess $app -u $admin
fi
# Reload Nginx # Reload Nginx
service php5-fpm restart service php5-fpm restart
service nginx reload service nginx reload
# Set ssowat config
ynh_app_setting_set "$app" skipped_uris "/"
if [[ $is_public -eq 0 ]];
then
ynh_app_setting_set "$app" protected_uris "/admin,/index.php,/choix_date.php,/choix_autre.php,/infos_sondage.php,/scripts"
else
ynh_app_setting_set "$app" protected_uris "/admin/index.php,/admin/logs_studs.txt,/scripts"
fi
yunohost app ssowatconf

View file

@ -24,102 +24,167 @@ app=$YNH_APP_INSTANCE_NAME
# Retrieve arguments # Retrieve arguments
domain=$(ynh_app_setting_get "$app" domain) domain=$(ynh_app_setting_get "$app" domain)
path=$(ynh_app_setting_get "$app" path) path_url=$(ynh_app_setting_get "$app" path)
admin=$(ynh_app_setting_get "$app" admin) admin=$(ynh_app_setting_get "$app" admin)
public_site=$(ynh_app_setting_get "$app" public_site) public_site=$(ynh_app_setting_get "$app" public_site)
legal=$(ynh_app_setting_get "$app" legal)
is_public=$(ynh_app_setting_get "$app" is_public) is_public=$(ynh_app_setting_get "$app" is_public)
if [[ "$is_public" = "" ]]; db_name=$(ynh_app_setting_get $app db_name)
then dbuser=$app
if [ $public_site = "No" ]; dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
then final_path=(ynh_app_setting_get "$app" final_path)
is_public=0
else #=================================================
is_public=1 # ENSURE DOWNWARD COMPATIBILITY
fi #=================================================
ynh_app_setting_set "$app" is_public "$is_public"
# Fix is_public as a boolean value
if [ "$is_public" = "Yes" ]; then
ynh_app_setting_set $app is_public 1
is_public=1
elif [ "$is_public" = "No" ]; then
ynh_app_setting_set $app is_public 0
is_public=0
fi fi
# If db_name doesn't exist, create it
if [ -z $db_name ]; then
db_name=$(ynh_sanitize_dbid $app)
ynh_app_setting_set $app db_name $db_name
fi
# If final_path doesn't exist, create it
if [ -z $final_path ]; then
final_path=/var/www/$app
ynh_app_setting_set $app final_path $final_path
fi
# make sure default language is set
language=$(ynh_app_setting_get "$app" language) language=$(ynh_app_setting_get "$app" language)
if [[ "$language" = "" ]]; if [[ "$language" = "" ]];
then then
language=$(grep LANGUE /var/www/$app/variables.php | grep -Po "'.*?'" | cut -d"'" -f2) language=$(grep LANGUE /var/www/$app/variables.php | grep -Po "'.*?'" | cut -d"'" -f2)
fi fi
# Check if admin is not null #=================================================
if [[ "$admin" = "" || "$language" = "" ]]; then # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
ynh_die "Unable to upgrade, please contact support" #=================================================
fi
# Remove trailing "/" for next commands # Backup the current version of the app
path=${path%/} ynh_backup_before_upgrade
ynh_clean_setup () {
# restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
root_pwd=$(cat /etc/yunohost/mysql) #=================================================
dbname=$app # CHECK THE PATH
dbpass=$(ynh_app_setting_get "$app" mysqlpwd) #=================================================
dbuser=$app
### Execute potential SQL statements here # Normalize the URL path syntax
# Copy files to the right place path_url=$(ynh_normalize_url_path $path_url)
final_path=/var/www/$app
# Check web path availability
ynh_webpath_available $domain $path_url
#=================================================
# STANDARD UPGRADE STEPS
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
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 "$final_path"
cp ../conf/constants.php.template $final_path/app/inc/constants.php #=================================================
# NGINX CONFIGURATION
#=================================================
# Create a dedicated nginx config
ynh_add_nginx_config
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
# Create a dedicated php-fpm config
ynh_add_fpm_config
#=================================================
# SPECIFIC UPGRADE
#=================================================
# Create config.php
#=================================================
config="$final_path/app/inc/config.php"
cp ../conf/config.php $config
# Change variables in configuration # Change variables in configuration
sed -i "s/yunouser/$dbuser/g" $final_path/app/inc/constants.php ynh_replace_string "__DBUSER__" "$dbuser" $config
sed -i "s/yunopass/$dbpass/g" $final_path/app/inc/constants.php ynh_replace_string "__DBPWD__" "$dbpass" $config
sed -i "s/yunobase/$dbname/g" $final_path/app/inc/constants.php ynh_replace_string "__DBNAME__" "$db_name" $config
sed -i "s/yunoadmin/$admin/g" $final_path/app/inc/constants.php ynh_replace_string "__ADMINMAIL__" "$admin" $config
sed -i "s/I18NTOCHANGE/$language/g" $final_path/app/inc/constants.php ynh_replace_string "__LANGUAGE__" "$language" $config
sed -i "s@yunourl@$domain$path@g" $final_path/app/inc/constants.php ynh_replace_string "__DOMAIN__" "$domain" $config
sed -i "s@yunodomain@$domain@g" $final_path/app/inc/constants.php ynh_replace_string "__PATH__" "$path_url" $config
sed -i "s@yunoabout@$legal@g" $final_path/app/inc/constants.php
#=================================================
# Replace logo image (default is FramaDate)
#=================================================
cp ../img/logo.png "$final_path/images"
#=================================================
# STORE THE CHECKSUM OF THE CONFIG FILE
#=================================================
# Verify the checksum and backup the file if it's different
ynh_backup_if_checksum_is_different "$config"
# Recalculate and store the config file checksum into the app settings
ynh_store_file_checksum "$config"
#=================================================
# Create log file
#=================================================
# Create log file # Create log file
cp ../conf/logs_studs.txt $final_path/admin/ touch $final_path/admin/stdout.log
chmod 700 $final_path/admin/logs_studs.txt
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set permissions to roundcube directory # Set permissions to roundcube directory
chown -R www-data: $final_path chown -R www-data: $final_path
# Modify Nginx configuration file and copy it to Nginx conf directory #=================================================
sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf # Run database initilization
sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf #=================================================
sed -i "s@YNH_APP_INSTANCE_NAME@$app@g" ../conf/nginx.conf
if ynh_user_exists $admin; then init_composer "www-data" "$final_path"
yunohost app addaccess $app -u $admin
fi
cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
sed -i "s@NAMETOCHANGE@$app@g" ../conf/php-fpm.conf sudo -u "www-data" php "$final_path/admin/migration.php"
finalphpconf=/etc/php5/fpm/pool.d/$app.conf
cp ../conf/php-fpm.conf $finalphpconf
chown root: $finalphpconf
chmod 644 $finalphpconf
finalphpini=/etc/php5/fpm/conf.d/20-$app.ini #=================================================
cp ../conf/php-fpm.ini $finalphpini # SETUP SSOWAT
chown root: $finalphpini #=================================================
chmod 644 $finalphpini
service php5-fpm restart
# Reload Nginx
service nginx reload
ynh_app_setting_set "$app" skipped_uris "/" ynh_app_setting_set "$app" skipped_uris "/"
if [ $is_public -eq 0 ]; if [ $is_public -eq 0 ];
then then
ynh_app_setting_set "$app" protected_uris "/admin,/index.php,/choix_date.php,/choix_autre.php,/infos_sondage.php,/scripts" ynh_app_setting_set "$app" protected_uris "/admin,/index.php,/choix_date.php,/choix_autre.php,/infos_sondage.php,/scripts"
else else
ynh_app_setting_set "$app" protected_uris "/admin/index.php,/admin/logs_studs.txt,/scripts" ynh_app_setting_set "$app" protected_uris "/admin/index.php,/admin/stdout.log,/scripts"
ynh_replace_string " include conf.d/" " #include conf.d/" "$finalnginxconf"
ynh_store_file_checksum "$finalnginxconf"
fi fi
yunohost app ssowatconf
#=================================================
# RELOAD NGINX
#=================================================
systemctl reload nginx