1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/garradin_ynh.git synced 2024-09-03 18:36:17 +02:00
garradin_ynh/scripts/restore

118 lines
3.3 KiB
Text
Raw Normal View History

2017-01-28 23:40:29 +01:00
#!/bin/bash
2018-03-24 01:33:15 +01:00
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2017-01-28 23:40:29 +01:00
2018-03-24 01:33:15 +01:00
source _common.sh
2017-01-29 16:32:14 +01:00
source /usr/share/yunohost/helpers
2017-01-28 23:40:29 +01:00
2018-03-24 01:33:15 +01:00
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
2020-04-02 16:34:46 +02:00
# Retrieve arguments
2018-03-24 01:33:15 +01:00
#=================================================
2017-01-28 23:40:29 +01:00
2020-04-02 16:34:46 +02:00
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC
2017-02-12 12:40:44 +01:00
2020-04-02 16:34:46 +02:00
app=$YNH_APP_INSTANCE_NAME
2017-01-28 23:40:29 +01:00
2018-03-24 01:33:15 +01:00
#=================================================
2020-04-02 16:34:46 +02:00
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
2018-03-24 01:33:15 +01:00
#=================================================
2017-01-28 23:40:29 +01:00
2020-04-02 16:34:46 +02:00
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die "This path already contains a folder"
2017-01-28 23:40:29 +01:00
2020-04-02 16:34:46 +02:00
# Normalize the url path syntax
path_url=$(ynh_normalize_url_path $path_url)
2020-03-31 17:43:53 +02:00
2020-04-02 16:34:46 +02:00
# Check web path availability
ynh_webpath_available $domain $path_url
# Register (book) web path
ynh_webpath_register $app $domain $path_url
2020-03-31 17:43:53 +02:00
2018-03-24 01:33:15 +01:00
#=================================================
2020-04-02 16:34:46 +02:00
# STORE SETTINGS FROM MANIFEST
2018-03-24 01:33:15 +01:00
#=================================================
2017-01-28 23:40:29 +01:00
2020-04-02 16:34:46 +02:00
ynh_app_setting_set $app path_url $path_url
ynh_app_setting_set $app domain $domain
ynh_app_setting_set $app is_public $is_public
2018-03-24 01:33:15 +01:00
#=================================================
2020-04-02 16:34:46 +02:00
# Install dependency to convert tracks to a readable format for the browser
2018-03-24 01:33:15 +01:00
#=================================================
2020-03-31 02:03:44 +02:00
if [ "$(lsb_release --codename --short)" != "jessie" ]
2018-07-01 11:25:00 +02:00
then
2020-04-02 17:28:53 +02:00
ynh_install_app_dependencies php-sqlite3
2018-07-01 11:25:00 +02:00
else
2020-04-02 16:34:46 +02:00
ynh_install_app_dependencies php5-sqlite
2018-07-01 11:25:00 +02:00
fi
2018-03-24 01:33:15 +01:00
#=================================================
2020-04-02 16:34:46 +02:00
# CREATE DEDICATED USER
2018-03-24 01:33:15 +01:00
#=================================================
2020-03-31 17:43:53 +02:00
2020-04-02 16:34:46 +02:00
# Create a system user
ynh_system_user_create $app
2020-03-31 17:43:53 +02:00
#=================================================
2020-04-02 16:34:46 +02:00
# DOWNLOAD, CHECK AND UNPACK SOURCE
2020-03-31 17:43:53 +02:00
#=================================================
2020-04-02 16:34:46 +02:00
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"
2020-03-31 17:43:53 +02:00
#=================================================
2020-04-02 16:34:46 +02:00
# Files owned by user app
2020-03-31 17:43:53 +02:00
#=================================================
2020-04-02 16:34:46 +02:00
sudo chown $app:$app $final_path -R
sudo chmod 755 $final_path -R
2020-03-31 17:43:53 +02:00
2020-04-02 16:34:46 +02:00
#=================================================
# NGINX CONFIGURATION
#=================================================
2020-03-31 17:43:53 +02:00
2020-04-02 16:34:46 +02:00
# Create a dedicated nginx config
ynh_add_nginx_config
2020-03-31 17:43:53 +02:00
#=================================================
2020-04-02 16:34:46 +02:00
# PHP-FPM CONFIGURATION
2020-03-31 17:43:53 +02:00
#=================================================
2020-04-02 16:34:46 +02:00
# Create a dedicated php-fpm config
ynh_add_fpm_config
2018-03-24 01:33:15 +01:00
#=================================================
2020-04-02 16:34:46 +02:00
# SETUP SSOWAT
2018-03-24 01:33:15 +01:00
#=================================================
2020-03-31 17:43:53 +02:00
2020-04-02 16:34:46 +02:00
if [ $is_public -eq 0 ]
then # Remove the public access
ynh_app_setting_delete $app skipped_uris
fi
# Make app public if necessary
if [ $is_public -eq 1 ]
then
# unprotected_uris allows SSO credentials to be passed anyway.
ynh_app_setting_set $app unprotected_uris "/"
fi
2020-03-31 17:43:53 +02:00
#=================================================
2020-04-02 16:34:46 +02:00
# RELOAD NGINX
2020-03-31 17:43:53 +02:00
#=================================================
2020-04-02 16:34:46 +02:00
systemctl reload nginx