1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/grav_ynh.git synced 2024-09-03 19:16:01 +02:00
grav_ynh/scripts/install

91 lines
2.2 KiB
Text
Raw Normal View History

2015-11-11 18:03:16 +01:00
#!/bin/bash
2017-03-02 15:44:54 +01:00
# Exit on command errors and treat unset variables as an error
set -eu
2015-11-11 18:03:16 +01:00
2017-03-08 00:50:23 +01:00
source .fonctions # Loads the generic functions usually used in the script
source /usr/share/yunohost/helpers # Source app helpers
2017-03-02 15:44:54 +01:00
CLEAN_SETUP () {
2017-03-08 00:50:23 +01:00
# Clean installation residues that are not supported by the remove script.
2017-03-02 15:44:54 +01:00
# Clean hosts
sudo sed -i '/#GRAV/d' /etc/hosts
}
2017-03-08 00:50:23 +01:00
TRAP_ON # Active trap to stop the script if an error is detected.
2017-03-02 15:44:54 +01:00
domain=$YNH_APP_ARG_DOMAIN
path=$YNH_APP_ARG_PATH
admin_grav=$YNH_APP_ARG_ADMIN
language=$YNH_APP_ARG_LANGUAGE
multisite=$YNH_APP_ARG_MULTISITE
is_public=$YNH_APP_ARG_IS_PUBLIC
app=$YNH_APP_INSTANCE_NAME
CHECK_VAR "$app" "app name not set"
CHECK_USER "$admin_grav"
CHECK_PATH
CHECK_DOMAINPATH
CHECK_FINALPATH
ynh_app_setting_set $app domain $domain
ynh_app_setting_set $app path $path
ynh_app_setting_set $app admin $admin_grav
ynh_app_setting_set $app is_public $is_public
ynh_app_setting_set $app language $language
ynh_app_setting_set $app multisite $multisite
2017-03-08 00:50:23 +01:00
# Creates the destination directory and stores its location.
2017-03-02 15:44:54 +01:00
sudo mkdir "$final_path"
ynh_app_setting_set $app final_path $final_path
2015-11-11 18:03:16 +01:00
SETUP_SOURCE
2017-03-02 15:44:54 +01:00
2017-03-08 00:50:23 +01:00
# Grav install
2017-03-02 17:03:30 +01:00
sudo $final_path/bin/grav
2017-03-08 00:50:23 +01:00
# Set permissions
2015-11-11 18:03:16 +01:00
sudo chown -R www-data: $final_path
2017-03-02 15:44:54 +01:00
echo -e "127.0.0.1 $domain #GRAV" | sudo tee -a /etc/hosts
2017-03-08 00:50:23 +01:00
# Copy nginx config
2017-03-02 15:44:54 +01:00
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
2017-03-08 00:50:23 +01:00
# Modif the variables in the nginx configuration file
2017-03-02 15:44:54 +01:00
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 [ "$multisite" = "Yes" ];
then
sudo sed -i "s@#--MULTISITE--@@g" /etc/nginx/conf.d/$domain.d/$app.conf
fi
if [ "$is_public" = "Yes" ];
then
sudo sed -i "s@#--PRIVATE--@@g" /etc/nginx/conf.d/$domain.d/$app.conf
fi
POOL_FPM
2017-03-08 00:50:23 +01:00
# Setup SSOwat
ynh_app_setting_set "$app" is_public "$is_public"
if [ "$is_public" = "Yes" ];
then
ynh_app_setting_set "$app" unprotected_uris "/"
fi
2015-11-11 18:03:16 +01:00
2017-03-08 00:50:23 +01:00
# Reload SSOwat configuration
2017-03-02 15:44:54 +01:00
sudo yunohost app ssowatconf
2015-11-11 18:03:16 +01:00
# Reload Nginx and regenerate SSOwat conf
sudo service php5-fpm restart
sudo service nginx reload
2017-03-02 15:44:54 +01:00
# Nettoyer hosts
sudo sed -i '/#GRAV/d' /etc/hosts