#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= # Exit if an error occurs during the execution of the script ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= ynh_script_progression --message="Validating installation parameters..." final_path="/etc/samba" #================================================= # STORE SETTINGS FROM MANIFEST #================================================= ynh_script_progression --message="Storing installation settings..." --weight=1 ynh_app_setting_set --app=$app --key=directories --value=shared ynh_app_setting_set --app=$app --key=advanced --value=0 ynh_app_setting_set --app=$app --key=readonly_dir --value='' ynh_app_setting_set --app=$app --key=unbrowseable --value='' ynh_app_setting_set --app=$app --key=final_path --value=$final_path #================================================= # STANDARD MODIFICATIONS #================================================= # FIND AND OPEN A PORT #================================================= ynh_script_progression --message="Configuring firewall..." ynh_exec_warn_less yunohost firewall allow Both 445 --no-upnp #================================================= # INSTALL DEPENDENCIES #================================================= ynh_script_progression --message="Installing dependencies..." --weight=10 ynh_install_app_dependencies $pkg_dependencies #================================================= # SPECIFIC SETUP #================================================= # SETUP SSOWAT #================================================= ynh_script_progression --message="Configuring permissions..." # We define the permission in advance to be able to use the group # in unix permission ynh_permission_create --permission="share" --allowed=all_users #================================================= # CREATE DATA DIRECTORY #================================================= ynh_script_progression --message="Creating a data directory..." --weight=1 datadir=/home/yunohost.app/samba ynh_app_setting_set --app=samba --key=datadir --value=$datadir mkdir -p $datadir/share chmod 750 "$datadir/share" chmod -R o-rwx "$datadir/share" chown -R root:root "$datadir/share" setfacl -R -m g:samba.share:rwx,d:g:samba.share:rwx $datadir/share #================================================= # ADD A CONFIGURATION #================================================= ynh_script_progression --message="Adding a configuration file..." --weight=1 mkdir -p $final_path/smb.conf.d ynh_add_config --template="global-smb.conf" --destination="$final_path/smb.conf.d/0-global.conf" ynh_add_config --template="share-smb.conf" --destination="$final_path/smb.conf.d/share.conf" cat > $final_path/smb.conf <> $final_path/smb.conf #================================================= # GENERIC FINALIZATION #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 yunohost service add smbd --description="Samba service" --log="/var/log/smbd/smbd.log" --needs_exposed_ports 445 #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=10 # Start a systemd service ynh_systemd_action --service_name=smbd --action="start" #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Installation of $app completed" --last