2022-02-22 13:59:54 +01:00
|
|
|
#!/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
|
|
|
|
|
|
|
|
#=================================================
|
2022-02-22 17:45:17 +01:00
|
|
|
# STORE SETTINGS FROM MANIFEST
|
2022-02-22 13:59:54 +01:00
|
|
|
#=================================================
|
2022-02-22 17:45:17 +01:00
|
|
|
ynh_script_progression --message="Storing installation settings..." --time --weight=1
|
2022-02-22 13:59:54 +01:00
|
|
|
|
2022-02-25 12:52:27 +01:00
|
|
|
#=================================================
|
|
|
|
# STORE SETTINGS FROM MANIFEST
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Storing installation settings..." --time --weight=1
|
|
|
|
|
2022-02-25 17:05:34 +01:00
|
|
|
ynh_app_setting_set --app=$app --key=directories --value=shared
|
2022-02-25 12:52:27 +01:00
|
|
|
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=''
|
|
|
|
|
2022-02-22 13:59:54 +01:00
|
|
|
#=================================================
|
2022-02-22 17:45:17 +01:00
|
|
|
# FIND AND OPEN A PORT
|
2022-02-22 13:59:54 +01:00
|
|
|
#=================================================
|
|
|
|
|
2022-02-22 17:45:17 +01:00
|
|
|
ynh_exec_warn_less yunohost firewall allow Both 445 --no-upnp
|
|
|
|
|
2022-02-22 13:59:54 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# INSTALL DEPENDENCIES
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Installing dependencies..." --time --weight=1
|
|
|
|
|
|
|
|
ynh_install_app_dependencies $pkg_dependencies
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CREATE DATA DIRECTORY
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Creating a data directory..." --time --weight=1
|
|
|
|
|
2022-02-22 17:45:17 +01:00
|
|
|
datadir=/home/yunohost.app/samba
|
|
|
|
ynh_app_setting_set --app=samba --key=datadir --value=$datadir
|
2022-02-22 13:59:54 +01:00
|
|
|
|
2022-02-22 17:45:17 +01:00
|
|
|
mkdir -p $datadir/share
|
2022-02-22 13:59:54 +01:00
|
|
|
|
2022-02-22 17:45:17 +01:00
|
|
|
chmod 750 "$datadir/share"
|
|
|
|
chmod -R o-rwx "$datadir/share"
|
|
|
|
chown -R root:root "$datadir/share"
|
|
|
|
setfacl -R -m g:all_users:rwx,d:g:all_users:rwx $datadir/share
|
2022-02-22 13:59:54 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# ADD A CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Adding a configuration file..." --time --weight=1
|
|
|
|
|
2022-02-25 14:04:21 +01:00
|
|
|
mkdir -p /etc/samba/smb.conf.d
|
|
|
|
ynh_add_config --template="global-smb.conf" --destination="/etc/samba/smb.conf.d/0-global.conf"
|
|
|
|
ynh_add_config --template="shared-smb.conf" --destination="/etc/samba/smb.conf.d/shared.conf"
|
|
|
|
|
|
|
|
cat /etc/samba/smb.conf.d/*.conf > /etc/samba/smb.conf
|
2022-02-22 17:45:17 +01:00
|
|
|
|
|
|
|
#================================================
|
|
|
|
# INTEGRATE SERVICE IN YUNOHOST
|
|
|
|
#================================================
|
|
|
|
|
|
|
|
yunohost service add smbd --description="Samba service" --log="/var/log/smbd/smbd.log"
|
2022-02-22 13:59:54 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Starting a systemd service..." --time --weight=1
|
|
|
|
|
|
|
|
# Start a systemd service
|
|
|
|
ynh_systemd_action --service_name=smbd --action="start"
|
|
|
|
|
2022-02-22 17:45:17 +01:00
|
|
|
#=================================================
|
|
|
|
# SETUP SSOWAT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_permission_create --permission="share" --allowed=all_users
|
|
|
|
|
2022-02-22 13:59:54 +01:00
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_script_progression --message="Installation of $app completed" --time --last
|