2022-02-22 13:59:54 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2022-02-25 12:52:27 +01:00
|
|
|
#=================================================
|
|
|
|
# STORE SETTINGS FROM MANIFEST
|
|
|
|
#=================================================
|
2024-08-31 02:58:19 +02:00
|
|
|
ynh_script_progression "Storing installation settings..."
|
2022-02-25 12:52:27 +01:00
|
|
|
|
2024-08-31 02:58:19 +02:00
|
|
|
ynh_app_setting_set --key=directories --value=share
|
|
|
|
ynh_app_setting_set --key=advanced --value=0
|
|
|
|
ynh_app_setting_set --key=readonly_dir --value=''
|
|
|
|
ynh_app_setting_set --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
|
|
|
|
#=================================================
|
2024-08-31 02:58:19 +02:00
|
|
|
ynh_script_progression "Creating a data directory..."
|
2022-02-22 13:59:54 +01:00
|
|
|
|
2023-08-13 12:38:51 +02:00
|
|
|
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
|
|
|
|
#=================================================
|
2024-08-31 02:58:19 +02:00
|
|
|
ynh_script_progression "Adding $app's configuration..."
|
2022-02-22 13:59:54 +01:00
|
|
|
|
2023-08-13 12:38:51 +02:00
|
|
|
mkdir -p $install_dir/smb.conf.d
|
2024-08-31 02:58:19 +02:00
|
|
|
ynh_config_add --template="global-smb.conf" --destination="$install_dir/smb.conf.d/0-global.conf"
|
|
|
|
ynh_config_add --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
|
2024-08-31 02:58:19 +02:00
|
|
|
# =================================================
|
|
|
|
|
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
|
|
|
#=================================================
|
2022-02-22 17:45:17 +01:00
|
|
|
# INTEGRATE SERVICE IN YUNOHOST
|
2022-07-14 02:33:15 +02:00
|
|
|
#=================================================
|
2024-08-31 02:58:19 +02:00
|
|
|
ynh_script_progression "Integrating service in YunoHost..."
|
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
|
|
|
|
#=================================================
|
2024-08-31 02:58:19 +02:00
|
|
|
ynh_script_progression "Starting $app's systemd service..."
|
2022-02-22 13:59:54 +01:00
|
|
|
|
2024-08-31 02:58:19 +02:00
|
|
|
ynh_systemctl --service=smbd --action="start"
|
2022-02-22 13:59:54 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2024-08-31 02:58:19 +02:00
|
|
|
ynh_script_progression "Installation of $app completed"
|