#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source ynh_send_readme_to_admin__2 source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= #REMOVEME? ynh_clean_setup () { ynh_clean_check_starting } # Exit if an error occurs during the execution of the script #REMOVEME? ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= #REMOVEME? admin=$YNH_APP_ARG_ADMIN #REMOVEME? password=$YNH_APP_ARG_PASSWORD #REMOVEME? app=$YNH_APP_INSTANCE_NAME admin_mail=$(ynh_user_get_info --username=$admin --key=mail) #================================================= # STORE SETTINGS FROM MANIFEST #================================================= #REMOVEME? ynh_script_progression --message="Storing installation settings..." --weight=1 #REMOVEME? ynh_app_setting_set --app=$app --key=admin --value=$admin #REMOVEME? ynh_app_setting_set --app=$app --key=password --value=$password #================================================= # STANDARD MODIFICATIONS #================================================= # OPEN PORT 445 #================================================= ynh_script_progression --message="Configuring firewall..." --weight=1 ynh_exec_warn_less yunohost firewall allow --no-upnp TCP 445 # Allow SMB access #================================================= # INSTALL DEPENDENCIES #================================================= #REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=1 #REMOVEME? ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE DEDICATED USER #================================================= #REMOVEME? ynh_script_progression --message="Configuring system user..." --weight=1 # Create a system user #REMOVEME? ynh_system_user_create --username=$app #================================================= # SPECIFIC SETUP #================================================= # CREATE DATA DIRECTORY #================================================= ynh_script_progression --message="Creating a data directory..." --weight=1 #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: "$data_dir" #================================================= # ADD A CONFIGURATION #================================================= ynh_script_progression --message="Adding a configuration file..." --weight=1 samba_sysadmin_setup ynh_add_config --template="../conf/smb.conf" --destination="/etc/smb/smb.d/$app.conf" ynh_add_config --template="../conf/avahi-samba.service" --destination="/etc/avahi/services/$app.service" # Create a samba user (echo "$password"; echo "$password") | ynh_exec_warn_less smbpasswd -s -a "$app" # Update samba configuration samba_sysadmin_update # Check and Add samba_sysadmin_add #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add smbd --needs_exposed_ports 445 #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_exec_warn_less testparm -s ynh_systemd_action --service_name=smbd --action="reload" ynh_systemd_action --service_name=avahi-daemon --action="restart" #================================================= # SEND A README FOR THE ADMIN #================================================= ynh_script_progression --message="Sending a readme for the admin..." ynh_send_readme_to_admin --app_message="../conf/msg_install" --recipients="$admin_mail" --type='install' #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Installation of $app completed" --last