2022-02-22 13:59:54 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2022-02-25 12:52:27 +01:00
|
|
|
#=================================================
|
|
|
|
# STORE SETTINGS FROM MANIFEST
|
|
|
|
#=================================================
|
2023-08-13 12:49:12 +02:00
|
|
|
ynh_script_progression --message="Storing installation settings..." --weight=1
|
2022-02-25 12:52:27 +01:00
|
|
|
|
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-07-19 09:58:23 +02:00
|
|
|
#=================================================
|
2022-02-22 13:59:54 +01:00
|
|
|
# CREATE DATA DIRECTORY
|
|
|
|
#=================================================
|
2022-05-07 18:24:57 +02:00
|
|
|
ynh_script_progression --message="Creating a data directory..." --weight=1
|
2022-02-22 13:59:54 +01:00
|
|
|
|
2023-08-13 12:38:51 +02:00
|
|
|
chmod 750 "$data_dir/share"
|
|
|
|
chmod -R o-rwx "$data_dir/share"
|
|
|
|
chown -R root:root "$data_dir/share"
|
|
|
|
setfacl -R -m g:samba.share:rwx,d:g:samba.share:rwx $data_dir/share
|
2022-02-22 13:59:54 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# ADD A CONFIGURATION
|
|
|
|
#=================================================
|
2022-05-07 18:24:57 +02:00
|
|
|
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
2022-02-22 13:59:54 +01:00
|
|
|
|
2023-08-13 12:38:51 +02:00
|
|
|
mkdir -p $install_dir/smb.conf.d
|
|
|
|
ynh_add_config --template="global-smb.conf" --destination="$install_dir/smb.conf.d/0-global.conf"
|
|
|
|
ynh_add_config --template="share-smb.conf" --destination="$install_dir/smb.conf.d/share.conf"
|
2022-02-25 14:04:21 +01:00
|
|
|
|
2023-08-13 12:38:51 +02:00
|
|
|
cat > $install_dir/smb.conf <<EOF
|
2022-02-27 20:07:04 +01:00
|
|
|
# =================================================
|
|
|
|
# DO NOT EDIT THIS FILE
|
|
|
|
# EDIT SUBPARTS IN /etc/samba/smb.conf.d
|
|
|
|
# =================================================
|
|
|
|
|
|
|
|
EOF
|
2023-08-13 12:38:51 +02:00
|
|
|
cat $install_dir/smb.conf.d/*.conf >> $install_dir/smb.conf
|
2022-02-22 17:45:17 +01:00
|
|
|
|
2022-07-14 02:33:15 +02:00
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
2022-02-22 17:45:17 +01:00
|
|
|
# INTEGRATE SERVICE IN YUNOHOST
|
2022-07-14 02:33:15 +02:00
|
|
|
#=================================================
|
2022-05-07 18:28:07 +02:00
|
|
|
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
2022-02-22 17:45:17 +01:00
|
|
|
|
2023-08-13 12:49:12 +02:00
|
|
|
yunohost service add smbd --description="Samba service" --log="/var/log/smbd/smbd.log" --needs_exposed_ports $port
|
2022-02-22 13:59:54 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
#=================================================
|
2022-05-07 18:24:57 +02:00
|
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=10
|
2022-02-22 13:59:54 +01:00
|
|
|
|
|
|
|
# Start a systemd service
|
|
|
|
ynh_systemd_action --service_name=smbd --action="start"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2022-05-07 18:24:57 +02:00
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|