#!/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 datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # SPECIFIC GETTERS FOR TOML SHORT KEY #================================================= #================================================= # SPECIFIC VALIDATORS FOR TOML SHORT KEYS #================================================= #================================================= # SPECIFIC SETTERS FOR TOML SHORT KEYS #================================================= set__directories() { mkdir -p /etc/samba/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 $datadir/$directory chmod 750 "$datadir/$directory" chmod -R o-rwx "$datadir/$directory" chown -R root:root "$datadir/$directory" setfacl -R -m g:samba.$directory:rwx,d:g:samba.$directory:rwx $datadir/$directory # Add the configuration in /etc/samba/smb.conf if needed cat > /etc/samba/smb.conf.d/$directory.conf < /etc/samba/smb.conf <> /etc/samba/smb.conf #--------------------------------------------- # IMPORTANT: to be able to upgrade properly, you have to saved the value in settings too #--------------------------------------------- ynh_app_setting_set $app directories $directories } #================================================= # GENERIC FINALIZATION #================================================= ynh_app_config_run $1