1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/lstu_ynh.git synced 2024-09-03 19:36:12 +02:00

Update install

This commit is contained in:
frju365 2018-02-20 17:39:56 +01:00 committed by GitHub
parent 13776b8e0c
commit cb94aded30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,58 +1,82 @@
#!/bin/bash #!/bin/bash
# vim:set noexpandtab:
# Exit on command errors and treat unset variables as an error #=================================================
set -eu # GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source .fonctions # Loads the generic functions usually used in the script source _common.sh
source /usr/share/yunohost/helpers # Source app helpers source /usr/share/yunohost/helpers
CLEAN_SETUP () { #=================================================
# Clean installation residues that are not supported by the remove script. # MANAGE SCRIPT FAILURE
# Clean hosts #=================================================
echo ""
} # Exit if an error occurs during the execution of the script
TRAP_ON # Active trap to stop the script if an error is detected. ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
# Retrieve arguments
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
path=$YNH_APP_ARG_PATH path_url=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC is_public=$YNH_APP_ARG_IS_PUBLIC
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
script_dir=$PWD script_dir=$PWD
# Check variables are not empty #=================================================
CHECK_VAR "$app" "app name not set" # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
CHECK_VAR "$script_dir" "script_dir not set" #=================================================
CHECK_PATH # Check and fix path syntax final_path=/var/www/$app
CHECK_DOMAINPATH # Check and fix domain disponibility test ! -e "$final_path" || ynh_die "This path already contains a folder"
CHECK_FINALPATH # Check final path # Normalize the url path syntax
path_url=$(ynh_normalize_url_path $path_url)
# Check domain with regex # Check web path availability
domain_regex=$(echo "$domain" | sed 's@-@.@g') ynh_webpath_available $domain $path_url
CHECK_VAR "$domain_regex" "domain_regex empty" # Register (book) web path
ynh_webpath_register $app $domain $path_url
FIND_PORT 8096 # Check port availability #=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
# Save app settings
ynh_app_setting_set $app domain $domain ynh_app_setting_set $app domain $domain
ynh_app_setting_set $app path $path_url
ynh_app_setting_set $app is_public $is_public ynh_app_setting_set $app is_public $is_public
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# FIND AND OPEN A PORT
#=================================================
# Find a free port
port=$(ynh_find_port 8096)
# Open this port
yunohost firewall allow --no-upnp TCP $port 2>&1
ynh_app_setting_set $app port $port ynh_app_setting_set $app port $port
# Install dependencies #=================================================
ynh_package_update # INSTALL DEPENDENCIES
ynh_package_install build-essential libssl-dev libpq-dev #=================================================
ynh_install_app_dependencies build-essential libssl-dev libpq-dev libpng-dev
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
# Copy files to the right place
sudo mkdir "${final_path}"
ynh_app_setting_set $app final_path $final_path 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"
# Get source #Refactoring : end of part one.
SETUP_SOURCE
# Copy it to Nginx conf directory # Copy it to Nginx conf directory
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf