#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source /usr/share/yunohost/helpers #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." #REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:$app "$install_dir" chmod +x "$install_dir/Headphones.py" #================================================= # NGINX CONFIGURATION #================================================= ynh_script_progression --message="Configuring NGINX web server..." # Create a dedicated NGINX config ynh_add_nginx_config #================================================= # SPECIFIC SETUP #================================================= # INSTALL PYTHON DEPENDENCIES #================================================= #REMOVEME? ynh_script_progression --message="Installing Python dependencies..." python3 -m venv $install_dir/venv #================================================= # CREATE DATA DIRECTORY #================================================= ynh_script_progression --message="Creating a data directory..." #REMOVEME? data_dir=/home/yunohost.app/$app #REMOVEME? ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir mkdir -p $data_dir chmod 750 "$data_dir" chmod -R o-rwx "$data_dir" chown -R $app:$app "$data_dir" #================================================= # ADD A CONFIGURATION #================================================= ynh_script_progression --message="Adding a configuration file..." mkdir -p "/etc/$app" ynh_add_config --template="../conf/headphones.ini" --destination="/etc/$app/$app.ini" chmod 600 "/etc/$app/$app.ini" chown $app:$app "/etc/$app/$app.ini" #================================================= # SETUP SYSTEMD #================================================= ynh_script_progression --message="Configuring a systemd service..." # Create a dedicated systemd config ynh_add_systemd_config #================================================= # GENERIC FINALIZATION #================================================= # SETUP LOGROTATE #================================================= ynh_script_progression --message="Configuring log rotation..." mkdir -p "/var/log/$app" chown -R $app:$app "/var/log/$app" # Use logrotate to manage application logfile(s) ynh_use_logrotate #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add $app --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." # Start a systemd service ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="Starting Headphones web server" #================================================= # SETUP SSOWAT #================================================= #REMOVEME? ynh_script_progression --message="Configuring permissions..." # Make app public if necessary #REMOVEME? if [ $is_public -eq 1 ] then # Everyone can access the app. # The "main" permission is automatically created before the install script. #REMOVEME? ynh_permission_update --permission="main" --add="visitors" fi #================================================= # RELOAD NGINX #================================================= #REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Installation of $app completed"