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

86 lines
2.1 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
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
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
# Get source
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 [ "$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
2017-03-02 15:44:54 +01:00
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
2017-03-26 16:29:13 +02:00
sudo systemctl reload php5-fpm
sudo systemctl reload nginx
2017-03-02 15:44:54 +01:00
# Nettoyer hosts
sudo sed -i '/#GRAV/d' /etc/hosts