2017-03-11 19:16:28 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-10-28 21:24:13 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# MANAGE SCRIPT FAILURE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_clean_setup () {
|
|
|
|
### Remove this function if there's nothing to clean before calling the remove script.
|
|
|
|
true
|
|
|
|
}
|
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
|
|
#=================================================
|
2017-03-11 19:16:28 +01:00
|
|
|
|
2017-03-11 19:22:05 +01:00
|
|
|
domain=$YNH_APP_ARG_DOMAIN
|
|
|
|
path=$YNH_APP_ARG_PATH
|
|
|
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
2017-03-11 19:16:28 +01:00
|
|
|
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
2018-10-28 21:24:13 +01:00
|
|
|
script_dir=$PWD
|
2017-03-11 19:16:28 +01:00
|
|
|
|
2018-10-28 21:24:13 +01:00
|
|
|
#=================================================
|
|
|
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
|
|
|
#=================================================
|
2017-03-11 19:16:28 +01:00
|
|
|
|
2018-10-28 21:24:13 +01:00
|
|
|
### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app".
|
|
|
|
### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app"
|
|
|
|
final_path=/var/www/$app
|
|
|
|
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
2017-03-11 19:16:28 +01:00
|
|
|
|
2018-10-28 21:24:13 +01:00
|
|
|
# Normalize the url path syntax
|
|
|
|
path_url=$(ynh_normalize_url_path $path_url)
|
2017-03-11 19:16:28 +01:00
|
|
|
|
2018-10-28 21:24:13 +01:00
|
|
|
# Check web path availability
|
|
|
|
ynh_webpath_available $domain $path_url
|
|
|
|
# Register (book) web path
|
|
|
|
ynh_webpath_register $app $domain $path_url
|
2017-03-11 19:16:28 +01:00
|
|
|
|
2018-10-28 21:24:13 +01:00
|
|
|
#=================================================
|
|
|
|
# STORE SETTINGS FROM MANIFEST
|
|
|
|
#=================================================
|
2017-03-11 19:16:28 +01:00
|
|
|
|
2018-10-28 21:24:13 +01:00
|
|
|
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
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_app_setting_set $app final_path $final_path
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
|
|
|
ynh_setup_source "$final_path"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# Install Composer + install Dependencies
|
|
|
|
#=================================================
|
2017-03-11 19:16:28 +01:00
|
|
|
|
2017-03-11 19:21:29 +01:00
|
|
|
pushd $final_path
|
|
|
|
sudo php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
|
2017-10-06 10:38:22 +02:00
|
|
|
sudo php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
|
2017-03-11 19:21:29 +01:00
|
|
|
sudo php composer-setup.php
|
|
|
|
sudo php -r "unlink('composer-setup.php');"
|
|
|
|
sudo ./composer.phar install
|
|
|
|
sudo mkdir db
|
|
|
|
popd
|
2017-03-11 19:16:28 +01:00
|
|
|
|
2018-10-28 21:24:13 +01:00
|
|
|
#=================================================
|
|
|
|
# CREATE DEDICATED USER
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Create a system user
|
|
|
|
ynh_system_user_create $app
|
|
|
|
|
|
|
|
#=================================================
|
2017-03-11 19:16:28 +01:00
|
|
|
# Files owned by root, www-data can just read
|
2018-10-28 21:24:13 +01:00
|
|
|
#=================================================
|
|
|
|
|
|
|
|
chown $app:$app $final_path -R
|
|
|
|
chmod 755 $final_path -R
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Create a dedicated nginx config
|
|
|
|
ynh_add_nginx_config
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SETUP SSOWAT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Make app public if necessary
|
|
|
|
if [ $is_public -eq 1 ]
|
2017-03-11 19:16:28 +01:00
|
|
|
then
|
2018-10-28 21:24:13 +01:00
|
|
|
# unprotected_uris allows SSO credentials to be passed anyway.
|
|
|
|
ynh_app_setting_set $app unprotected_uris "/"
|
2017-03-11 19:16:28 +01:00
|
|
|
fi
|
|
|
|
|
2018-10-28 21:24:13 +01:00
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
systemctl reload nginx
|