1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/cops_ynh.git synced 2024-09-03 18:25:57 +02:00
cops_ynh/scripts/install

91 lines
2.5 KiB
Text
Raw Normal View History

2016-12-21 18:46:36 +01:00
#!/bin/bash
set -eu
# Charge les fonctions génériques habituellement utilisées dans le script
source fonctions
# Active trap pour arrêter le script si une erreur est détectée.
TRAP_ON
# Source app helpers
source /usr/share/yunohost/helpers
# Retrieve arguments
app=$YNH_APP_INSTANCE_NAME
domain=$YNH_APP_ARG_DOMAIN
path=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC
runninguser=$YNH_APP_ARG_RUNNINGUSER
calibrepath=$YNH_APP_ARG_CALIBREPATH
2016-12-21 18:46:36 +01:00
# We check variables are not empty
CHECK_VAR "$app" "app name not set"
# Check the path value and correct it (adds / at begining and removes it at the end)
CHECK_PATH
# Check domain and path availibility
CHECK_DOMAINPATH
# Check destination folder is not used already
CHECK_FINALPATH
final_path=/var/www/$app
# Define variables and Save app settings
ynh_app_setting_set "$app" domain "$domain"
ynh_app_setting_set "$app" is_public "$is_public"
ynh_app_setting_set "$app" final_path "$final_path"
ynh_app_setting_set "$app" runninguser "$runninguser"
ynh_app_setting_set "$app" calibrepath "$calibrepath"
2016-12-21 18:46:36 +01:00
finalnginxconf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
ynh_app_setting_set "$app" finalnginxconf "$finalnginxconf"
finalphpconf="/etc/php5/fpm/pool.d/${app}.conf"
ynh_app_setting_set "$app" finalphpconf "$finalphpconf"
# We install dependencies
sudo apt-get install --quiet --assume-yes php5-gd php5-sqlite php5-json php5-intl
2016-12-21 18:46:36 +01:00
# Creation of folder
#sudo rm -rf $final_path
sudo mkdir -p $final_path
# Site adjustments
sudo cp ../conf/config_local.php ../sources/
sed -i "s@CALIBRETOCHANGE@$calibrepath@g" ../sources/config_local.php
2016-12-21 18:46:36 +01:00
# Base site
2016-12-22 02:13:41 +01:00
sudo cp -a ../sources/* $final_path/
2016-12-21 18:46:36 +01:00
# Set permissions
sudo chmod 775 -R $final_path
sudo chown -hR $runninguser:$runninguser $final_path
2016-12-21 18:46:36 +01:00
# Modify Nginx configuration file and copy it to Nginx conf directory
sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf
sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf
sed -i "s@NAMETOCHANGE@$app@g" ../conf/nginx.conf
sudo cp ../conf/nginx.conf $finalnginxconf
sed -i "s@NAMETOCHANGE@$app@g" ../conf/php-fpm.conf
2016-12-22 01:08:35 +01:00
sed -i "s@FOLDERTOCHANGE@$final_path@g" ../conf/php-fpm.conf
sed -i "s@USERTOCHANGE@$runninguser@g" ../conf/php-fpm.conf
2016-12-21 18:46:36 +01:00
sudo cp ../conf/php-fpm.conf $finalphpconf
sudo chown root: $finalphpconf
sudo chmod 644 $finalphpconf
# Make app public if necessary
is_public=$(ynh_app_setting_get $app is_public)
if [ "$is_public" = "Yes" ];
then
ynh_app_setting_set $app skipped_uris "/"
fi
# Reload Nginx and regenerate SSOwat conf
sudo service php5-fpm reload
sudo service nginx reload
sudo yunohost app ssowatconf