mirror of
https://github.com/YunoHost-Apps/agora_ynh.git
synced 2024-09-03 18:06:21 +02:00
Update install
This commit is contained in:
parent
49277d7169
commit
7faff293bf
1 changed files with 72 additions and 35 deletions
107
scripts/install
107
scripts/install
|
@ -1,56 +1,93 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
source ./_common
|
|
||||||
source .fonctions
|
|
||||||
set -eu
|
|
||||||
|
|
||||||
# Retrieve arguments
|
#=================================================
|
||||||
domain=$1
|
# GENERIC START
|
||||||
path=$2
|
#=================================================
|
||||||
is_public=$3
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
source _common.sh
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# MANAGE SCRIPT FAILURE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
|
path_url=$YNH_APP_ARG_PATH
|
||||||
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
# Source app helpers
|
#=================================================
|
||||||
source /usr/share/yunohost/helpers
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
script_dir=$PWD
|
final_path=/var/www/$app
|
||||||
|
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
||||||
|
|
||||||
# Vérifie que les variables ne sont pas vides.
|
path_url=$(ynh_normalize_url_path $path_url)
|
||||||
CHECK_VAR "$app" "app name not set"
|
ynh_webpath_available $domain $path_url
|
||||||
CHECK_VAR "$script_dir" "script_dir not set"
|
ynh_webpath_register $app $domain $path_url
|
||||||
|
|
||||||
CHECK_PATH # Vérifie et corrige la syntaxe du path.
|
#=================================================
|
||||||
CHECK_DOMAINPATH # Vérifie la disponibilité du path et du domaine.
|
# STORE SETTINGS FROM MANIFEST
|
||||||
|
#=================================================
|
||||||
|
|
||||||
CHECK_FINALPATH # Vérifie que le dossier de destination n'est pas déjà utilisé.
|
ynh_app_setting_set $app domain $domain
|
||||||
|
ynh_app_setting_set $app path $path_url
|
||||||
|
ynh_app_setting_set $app is_public $is_public
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Source YunoHost helpers
|
|
||||||
source /usr/share/yunohost/helpers
|
|
||||||
|
|
||||||
# Copy files to the right place
|
|
||||||
final_path=/var/www/$app
|
final_path=/var/www/$app
|
||||||
sudo mkdir -p /var/www/$app
|
sudo mkdir -p /var/www/$app
|
||||||
extract_source
|
extract_source
|
||||||
|
|
||||||
# Files owned by root, www-data can just read
|
#=================================================
|
||||||
sudo chown www-data:www-data $final_path -R
|
# NGINX CONFIGURATION
|
||||||
sudo chmod 775 $final_path -R
|
#=================================================
|
||||||
|
|
||||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
ynh_add_nginx_config
|
||||||
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
|
|
||||||
sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf
|
|
||||||
nginxconf=/etc/nginx/conf.d/$domain.d/$app.conf
|
|
||||||
sudo cp ../conf/nginx.conf $nginxconf
|
|
||||||
sudo chown root: $nginxconf
|
|
||||||
sudo chmod 600 $nginxconf
|
|
||||||
|
|
||||||
ynh_app_setting_set "$app" is_public "$is_public"
|
#=================================================
|
||||||
if [ "$is_public" = "Yes" ];
|
# CREATE DEDICATED USER
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_system_user_create $app
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SECURE FILES AND DIRECTORIES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Set permissions to app files
|
||||||
|
chown -R $app:www-data $final_path
|
||||||
|
chmod 775 $final_path -R
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SETUP SSOWAT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
if [ $is_public -eq 0 ]
|
||||||
then
|
then
|
||||||
ynh_app_setting_set "$app" unprotected_uris "/"
|
ynh_app_setting_delete $app skipped_uris
|
||||||
|
fi
|
||||||
|
if [ $is_public -eq 1 ]
|
||||||
|
then
|
||||||
|
ynh_app_setting_set $app unprotected_uris "/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo service nginx reload
|
#=================================================
|
||||||
sudo yunohost app ssowatconf
|
# RELOAD NGINX
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
systemctl reload nginx
|
||||||
|
|
Loading…
Add table
Reference in a new issue