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

150 lines
5 KiB
Text
Raw Normal View History

2021-03-07 01:45:20 +01:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
true
}
# 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
2021-03-07 02:33:00 +01:00
path_url="/"
2021-03-07 01:45:20 +01:00
admin=$YNH_APP_ARG_ADMIN
2021-12-17 07:57:41 +01:00
architecture=$YNH_ARCH
2021-03-07 01:45:20 +01:00
app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
2022-01-25 01:31:50 +01:00
ynh_script_progression --message="Validating installation parameters..."
2021-03-07 01:45:20 +01:00
2021-08-18 23:23:37 +02:00
final_path=/var/www/$app
2021-03-07 01:45:20 +01:00
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
# Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
2022-01-25 01:31:50 +01:00
ynh_script_progression --message="Storing installation settings..."
2021-03-07 01:45:20 +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
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# FIND AND OPEN A PORT
#=================================================
2022-01-25 01:31:50 +01:00
ynh_script_progression --message="Finding an available port..."
2021-03-07 01:45:20 +01:00
# Find an available port
2022-01-25 01:31:50 +01:00
port=$(ynh_find_port --port=8095)
2021-03-07 01:45:20 +01:00
ynh_app_setting_set --app=$app --key=port --value=$port
2021-06-13 15:30:36 +02:00
#=================================================
# CREATE DEDICATED USER
#=================================================
2022-01-25 01:31:50 +01:00
ynh_script_progression --message="Configuring system user..."
2021-06-13 15:30:36 +02:00
# Create a system user
2022-01-25 01:31:50 +01:00
ynh_system_user_create --username=$app --home_dir=$final_path
2021-03-07 01:45:20 +01:00
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
2022-01-25 01:31:50 +01:00
ynh_script_progression --message="Setting up source files..."
2021-03-07 01:45:20 +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
2021-06-13 15:49:55 +02:00
ynh_setup_source --dest_dir="$final_path" --source_id="$architecture"
2021-03-07 01:45:20 +01:00
2021-06-13 15:30:36 +02:00
chmod 750 "$final_path"
2021-07-08 18:24:57 +02:00
chmod -R o-rwx "$final_path"
2021-06-13 15:30:36 +02:00
chown -R $app:www-data "$final_path"
2021-03-07 01:45:20 +01:00
#=================================================
# NGINX CONFIGURATION
#=================================================
2022-01-25 01:31:50 +01:00
ynh_script_progression --message="Configuring NGINX web server..."
2021-03-07 01:45:20 +01:00
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
2022-01-25 01:31:50 +01:00
# SPECIFIC SETUP
#=================================================
# ADD A CONFIGURATION
2021-03-07 01:45:20 +01:00
#=================================================
2022-01-25 01:31:50 +01:00
ynh_script_progression --message="Adding a configuration file..."
2021-03-07 01:45:20 +01:00
2022-01-25 01:31:50 +01:00
ynh_add_config --template="../conf/beehive.conf" --destination="$final_path/beehive.conf"
chmod 600 "$final_path/beehive.conf"
chown $app:$app "$final_path/beehive.conf"
2021-03-07 01:45:20 +01:00
#=================================================
2022-01-25 01:31:50 +01:00
# SETUP SYSTEMD
#=================================================
2022-01-25 01:31:50 +01:00
ynh_script_progression --message="Configuring a systemd service..."
2022-01-25 01:31:50 +01:00
# Create a dedicated systemd config
ynh_add_systemd_config
2022-01-25 01:31:50 +01:00
#=================================================
# GENERIC FINALIZATION
2021-03-07 01:45:20 +01:00
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
2022-01-25 01:31:50 +01:00
ynh_script_progression --message="Integrating service in YunoHost..."
2021-03-07 01:45:20 +01:00
2022-01-25 01:31:50 +01:00
yunohost service add $app --description="$app service"
2021-03-07 01:45:20 +01:00
#=================================================
# START SYSTEMD SERVICE
#=================================================
2022-01-25 01:31:50 +01:00
ynh_script_progression --message="Starting a systemd service..."
2021-03-07 01:45:20 +01:00
2022-01-25 01:31:50 +01:00
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Config file loaded from"
2021-03-07 01:45:20 +01:00
#=================================================
# SETUP SSOWAT
#=================================================
2022-01-25 01:31:50 +01:00
ynh_script_progression --message="Configuring permissions..."
2021-03-07 01:45:20 +01:00
# Only the admin can access the admin panel of the app (if the app has an admin panel)
2022-01-25 01:31:50 +01:00
ynh_permission_update --permission="main" --remove="all_users" --add="$admin"
2021-03-07 01:45:20 +01:00
#=================================================
# RELOAD NGINX
#=================================================
2022-01-25 01:31:50 +01:00
ynh_script_progression --message="Reloading NGINX web server..."
2021-03-07 01:45:20 +01:00
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
2022-01-25 01:31:50 +01:00
ynh_script_progression --message="Installation of $app completed"