#!/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... ). source /usr/share/yunohost/helpers #REMOVEME? ynh_abort_if_errors data_dir=$(ynh_app_setting_get --key=data_dir) install_dir=$(ynh_app_setting_get --key=install_dir) #================================================= # recreate the smb.conf from smb.conf.d #================================================= write_smb_conf() { cat > $install_dir/smb.conf <> $install_dir/smb.conf } #================================================= # SPECIFIC SETTERS FOR TOML SHORT KEYS #================================================= set__directories() { mkdir -p $install_dir/smb.conf.d #--------------------------------------------- # IMPORTANT: setter are trigger only if a change is detected #--------------------------------------------- for directory in $(echo $directories | sed "s/,/ /g"); do # Create yunohost permission if ! ynh_permission_exists --permission=$directory ; then ynh_permission_create --permission="$directory" --allowed=all_users --show_tile=false fi # Create the directory mkdir -p $data_dir/$directory #REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "$data_dir/$directory" chmod -R o-rwx "$data_dir/$directory" chown -R root:root "$data_dir/$directory" setfacl -R -m g:samba.$directory:rwx,d:g:samba.$directory:rwx $data_dir/$directory # Add the configuration in /etc/samba/smb.conf.d/ if its missing if [ ! -f "$install_dir/smb.conf.d/$directory.conf" ]; then cat > $install_dir/smb.conf.d/$directory.conf <