cancel
Showing results for 
Search instead for 
Did you mean: 
SOLVED

How to map files under $SNAP_DATA to active configuration

How to map files under $SNAP_DATA to active configuration

chockalingam
Member

Hello Community,

I have created a snap and it contains configuration files, which are saved under $SNAP_DATA. During the runtime, I want to edit the configuration files in order to integrate other components.

By referring few documentation and example codes, I was able to create an empty folder inside the active configuration. But, I do not know how to map the files under $SNAP_DATA to this folder. 

First, is it possible to map the files in this way? If yes, please let me know the steps to perform.

Thank you

4 REPLIES 4

bostroemc
New Contributor

CodeShepherd describes in this thread how to copy files to the active configuration using a hook.  See script "connect-plug-active-solution".

Hello,

Thank you for the response. Actually, what I want to achieve is something different. 

I am following this source https://github.com/giaever-online-iot/home-assistant-snap/blob/master/snap/snapcraft.yaml  to generate a snap for home assistant.

Under apps, the command bin/hass --config $SNAP_DATA starts the application and generates few configuration files and folders, which will get stored at $SNAP_DATA. The command takes a path as arguement, where there files and folders need to be stored.

I have modified the command to bin/hass --config /var/snap/rexroth-solutions/common/solutions/activeConfiguration/home-assistant/config

At the moment, I am facing the following issue: Fatal Error: Unable to create library directory /var/snap/rexroth-solutions/common/solutions/activeConfiguration/home-assistant/config/deps: [Errno 13] Permission denied: '/var/snap/rexroth-solutions/common/solutions/activeConfiguration/home-assistant/config/deps' 

Steps I have followed so far:

1. Added a shell script, which will create a folder named home-assistant and sub folder named config inside activeConfiguration directory.

2. Added configs folder with package-assets file

3. Added active-solution plugs to snapcraft.yaml

4. Added parts to dump shell script and package-assets

5. Added hooks connect-plug-active-solution

I have attached the complete project as Zip. Please, let me know where I am making mistakes. Any help would be highly appreciable. 

Thanks & Regards

 

Hello,

Try to follow this how to step by step:

SDK - Empower your app with Data Persistance

 

ANd tell me where you got stuck 🙂

 

Hi Riboni,

The post really helped me.

I made a mistake of not naming the package manifest file same as snapcraft project name. Renaming it, fixed the issue and directory now got the permission to map files.

Thanks & Regards

Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist