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

135 lines
4.5 KiB
Text
Raw Normal View History

2014-06-02 13:38:03 +02:00
#!/bin/bash
2018-01-29 00:55:27 +01:00
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2016-02-03 12:59:58 +01:00
2018-01-29 00:55:27 +01:00
source _common.sh
source /usr/share/yunohost/helpers
2014-06-02 13:38:03 +02:00
2018-01-29 00:55:27 +01:00
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
2014-06-02 13:38:03 +02:00
2018-01-29 00:55:27 +01:00
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
2022-03-25 01:09:30 +01:00
admin=$YNH_APP_ARG_ADMIN
2018-01-29 00:55:27 +01:00
app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
2022-03-25 01:09:30 +01:00
ynh_script_progression --message="Validating installation parameters..."
2016-02-03 16:41:20 +01:00
2016-02-03 12:59:58 +01:00
final_path=/var/www/$app
2022-03-25 01:09:30 +01:00
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
2018-01-29 00:55:27 +01:00
# Register (book) web path
2022-03-25 01:09:30 +01:00
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
2018-01-29 00:55:27 +01:00
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
2022-03-25 01:09:30 +01:00
ynh_script_progression --message="Storing installation settings..."
2018-01-29 00:55:27 +01:00
2022-03-25 01:09:30 +01:00
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=admin --value=$admin
2018-01-29 00:55:27 +01:00
#=================================================
# STANDARD MODIFICATIONS
#=================================================
2022-03-25 01:09:30 +01:00
# FIND AND OPEN A PORT
2018-01-29 00:55:27 +01:00
#=================================================
2022-03-25 01:09:30 +01:00
ynh_script_progression --message="Finding an available port..."
2018-01-29 00:55:27 +01:00
2022-03-25 01:09:30 +01:00
# Find an available port
port=$(ynh_find_port --port=8095)
ynh_app_setting_set --app=$app --key=port --value=$port
2018-01-29 00:55:27 +01:00
#=================================================
2022-03-25 01:09:30 +01:00
# INSTALL DEPENDENCIES
2018-01-29 00:55:27 +01:00
#=================================================
2022-03-25 01:09:30 +01:00
ynh_script_progression --message="Installing dependencies..."
2018-01-29 00:55:27 +01:00
2022-03-25 01:09:30 +01:00
ynh_install_app_dependencies $pkg_dependencies
2018-01-29 00:55:27 +01:00
#=================================================
2022-03-25 01:09:30 +01:00
# CREATE DEDICATED USER
2018-01-29 00:55:27 +01:00
#=================================================
2022-03-25 01:09:30 +01:00
ynh_script_progression --message="Configuring system user..."
2018-01-29 00:55:27 +01:00
2022-03-25 01:09:30 +01:00
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
2018-01-29 00:55:27 +01:00
#=================================================
2022-03-25 01:09:30 +01:00
# DOWNLOAD, CHECK AND UNPACK SOURCE
2018-01-29 00:55:27 +01:00
#=================================================
2022-03-25 01:09:30 +01:00
ynh_script_progression --message="Setting up source files..."
2018-01-29 00:55:27 +01:00
2022-03-25 01:09:30 +01:00
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
2018-01-29 00:55:27 +01:00
#=================================================
2022-03-25 01:09:30 +01:00
# NGINX CONFIGURATION
2018-01-29 00:55:27 +01:00
#=================================================
2022-03-25 01:09:30 +01:00
ynh_script_progression --message="Configuring NGINX web server..."
2018-01-29 00:55:27 +01:00
2022-03-25 01:09:30 +01:00
# Create a dedicated NGINX config
ynh_add_nginx_config
2018-01-29 00:55:27 +01:00
#=================================================
# SPECIFIC SETUP
#=================================================
2022-03-25 01:09:30 +01:00
# REMOVE GOOGLE !!!
2018-01-29 00:55:27 +01:00
#=================================================
2014-06-02 13:38:03 +02:00
2022-03-25 01:09:30 +01:00
sed --in-place "/googlecode\|googleapis/d" "$final_path/index.html"
2018-01-29 00:55:27 +01:00
#=================================================
2022-03-25 01:09:30 +01:00
# SETUP SUPERVISOR
2018-01-29 00:55:27 +01:00
#=================================================
2022-03-25 01:09:30 +01:00
ynh_script_progression --message="Configuring supervisor..."
2018-01-29 00:55:27 +01:00
2022-03-25 01:09:30 +01:00
ynh_add_config --template="../conf/supervisor.conf" --destination="/etc/supervisor/conf.d/$app.conf"
supervisorctl update
supervisorctl restart $app
2018-01-29 00:55:27 +01:00
#=================================================
# GENERIC FINALIZATION
#=================================================
2022-03-25 01:09:30 +01:00
# SETUP SSOWAT
2018-01-29 00:55:27 +01:00
#=================================================
2022-03-25 01:09:30 +01:00
ynh_script_progression --message="Configuring permissions..."
2018-01-29 00:55:27 +01:00
2022-03-25 01:09:30 +01:00
# Only the admin can access the admin panel of the app (if the app has an admin panel)
ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin
2018-01-29 00:55:27 +01:00
#=================================================
2022-03-25 01:09:30 +01:00
# RELOAD NGINX
2018-01-29 00:55:27 +01:00
#=================================================
2022-03-25 01:09:30 +01:00
ynh_script_progression --message="Reloading NGINX web server..."
2018-01-29 00:55:27 +01:00
2022-03-25 01:09:30 +01:00
ynh_systemd_action --service_name=nginx --action=reload
2018-01-29 00:55:27 +01:00
#=================================================
2022-03-25 01:09:30 +01:00
# END OF SCRIPT
2018-01-29 00:55:27 +01:00
#=================================================
2022-03-25 01:09:30 +01:00
ynh_script_progression --message="Installation of $app completed"