2022-02-22 13:59:54 +01:00
|
|
|
#!/bin/bash
|
|
|
|
# In simple cases, you don't need a config script.
|
|
|
|
|
|
|
|
# With a simple config_panel.toml, you can write in the app settings, in the
|
|
|
|
# upstream config file or replace complete files (logo ...) and restart services.
|
|
|
|
|
|
|
|
# The config scripts allows you to go further, to handle specific cases
|
|
|
|
# (validation of several interdependent fields, specific getter/setter for a value,
|
|
|
|
# display dynamic informations or choices, pre-loading of config type .cube... ).
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC STARTING
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SPECIFIC GETTERS FOR TOML SHORT KEY
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SPECIFIC VALIDATORS FOR TOML SHORT KEYS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SPECIFIC SETTERS FOR TOML SHORT KEYS
|
|
|
|
#=================================================
|
2022-02-25 14:04:21 +01:00
|
|
|
set__directories() {
|
|
|
|
|
|
|
|
mkdir -p /etc/samba/smb.conf.d
|
2022-02-22 13:59:54 +01:00
|
|
|
|
|
|
|
#---------------------------------------------
|
|
|
|
# IMPORTANT: setter are trigger only if a change is detected
|
|
|
|
#---------------------------------------------
|
2022-02-25 14:04:21 +01:00
|
|
|
for directory in $(echo $directories | sed "s/,/ /"); do
|
|
|
|
# Create permission if needed
|
|
|
|
if ! ynh_permission_exists --permission=samba.${directory} ; then
|
|
|
|
ynh_permission_create --permission="samba.${directory}" --allowed=all_users --show_tile=false
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Add the configuration in /etc/samba/smb.conf if needed
|
|
|
|
cat > /etc/samba/smb.conf.d/${directory}.conf <<EOF
|
|
|
|
[${directory}]
|
|
|
|
comment = ${directory}
|
|
|
|
read only = no
|
|
|
|
path = /home/yunohost.app/samba/${directory}
|
|
|
|
guest ok = no
|
|
|
|
browsable = yes
|
|
|
|
valid users = @samba.${directory}
|
|
|
|
create mask = 0660
|
|
|
|
directory mask = 770
|
|
|
|
vfs objects = dfs_samba4 acl_xattr recycle
|
|
|
|
recycle:repository = .recycle
|
|
|
|
recycle:keeptree = yes
|
|
|
|
recycle:versions = yes
|
|
|
|
EOF
|
2022-02-22 13:59:54 +01:00
|
|
|
|
|
|
|
done
|
2022-02-25 14:04:21 +01:00
|
|
|
|
|
|
|
cat > /etc/samba/smb.conf <<EOF
|
|
|
|
# =================================================
|
|
|
|
# DO NOT EDIT THIS FILE
|
|
|
|
# EDIT SUBPARTS IN /etc/samba/smb.conf.d
|
|
|
|
# =================================================
|
|
|
|
|
|
|
|
EOF
|
|
|
|
cat /etc/samba/smb.conf.d/*.conf >> /etc/samba/smb.conf
|
2022-02-22 13:59:54 +01:00
|
|
|
|
|
|
|
#---------------------------------------------
|
|
|
|
# IMPORTANT: to be able to upgrade properly, you have to saved the value in settings too
|
|
|
|
#---------------------------------------------
|
2022-02-25 14:04:21 +01:00
|
|
|
ynh_app_setting_set $app directories $directories
|
2022-02-22 13:59:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
|
|
|
ynh_app_config_run $1
|