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

154 lines
4.2 KiB
Text
Raw Normal View History

2017-10-21 01:09:55 +02:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# 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
admin=$YNH_APP_ARG_ADMIN
is_public=$YNH_APP_ARG_IS_PUBLIC
app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die "This path already contains a folder"
path_url=$(ynh_normalize_url_path $path_url)
ynh_webpath_available $domain $path_url
ynh_webpath_register $app $domain $path_url
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_app_setting_set $app domain $domain
ynh_app_setting_set $app path $path_url
ynh_app_setting_set $app admin $admin
ynh_app_setting_set $app is_public $is_public
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# FIND AND OPEN A PORT
#=================================================
# Find a free port
port=$(ynh_find_port 8095)
# Open this port
yunohost firewall allow --no-upnp TCP $port 2>&1
ynh_app_setting_set $app port $port
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_install_app_dependencies deb1 deb2
#=================================================
# CREATE A MYSQL DATABASE
#=================================================
db_name=$(ynh_sanitize_dbid $app)
ynh_app_setting_set $app db_name $db_name
ynh_mysql_setup_db $db_name $db_name
mv ../conf/config.php $final_path
ynh_replace_string "DB_NAME" "$db_name" "$final_path/config.php"
ynh_replace_string "DB_USER" "$db_user" "$final_path/config.php"
ynh_replace_string "DB_PASS" "$db_pass" "$final_path/config.php"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_app_setting_set $app final_path $final_path
ynh_setup_source "$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_system_user_create $app
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_add_fpm_config
#=================================================
# SETUP SYSTEMD
#=================================================
# Create a dedicated systemd config
ynh_systemd_config
#=================================================
# STORE THE CHECKSUM OF THE CONFIG FILE
#=================================================
ynh_store_file_checksum "$final_path/config.php"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set permissions to app files
chown -R $app:www-data $final_path
chmod 755 $final_path -R
chmod 777 $final_path/cache -R
chmodd 777 $final_path/img/avatars -R
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_use_logrotate
#=================================================
# SETUP SSOWAT
#=================================================
if [ $is_public -eq 0 ]
then
ynh_app_setting_delete $app skipped_uris
fi
if [ $is_public -eq 1 ]
then
ynh_app_setting_set $app unprotected_uris "/"
fi
#=================================================
# RELOAD NGINX
#=================================================
systemctl reload nginx