FORUM CTRLX AUTOMATION
ctrlX World Partner Apps for ctrlX AUTOMATION
Dear Community User! We have started the migration process.
This community is now in READ ONLY mode.
Read more: Important
information on the platform change.
11-22-2021 12:47 PM - edited 11-22-2021 12:49 PM
Moved to own topic from this thread:
Solved! Go to Solution.
11-08-2021 12:40 PM - last edited on 11-22-2021 12:49 PM by CodeShepherd
Resurecting an old topic here, I'm dealing with sort of the same thing. I need to copy over a db config.
Is it possible to copy over the file to th defult configuration during install of the snap?
11-09-2021 12:04 PM - edited 11-22-2021 12:49 PM
Could you specify what you want to do? As I understood you created an own app with a db inside. This db needs it settings in the active configuration so you'd like to put it there while installing it.
For that case I would suggest to simply copy it there while booting up the process.
11-09-2021 01:14 PM - last edited on 11-22-2021 12:50 PM by CodeShepherd
Correct, I'm snapping an app with db, and to be able to create users I need to change the db config and restart the app.
The way I have done it now is that I'm uploading the config before installing the snap, but I want a more streamline install.
I have tried to copy over the file during install but havnt succeded. I have used the install hook to try and copy but nothing shows up in the folder.
I have tried this
cp "myfile.." /var/snap/rexroth-solutions/common/solutions/activeConfiguration/
cp "myfile.." $SNAP_COMMON/solutions/activeConfiguration/
Do you now the exact path?
11-10-2021 02:38 PM - edited 11-22-2021 12:50 PM
You can try to use hooks (see online documentation) but you will have to check if the content interface is connected via snapctl. Otherwise your snap is not allowed to access the path you I and also you mentioned above.
11-10-2021 03:33 PM - last edited on 11-22-2021 12:50 PM by CodeShepherd
plugs: active-solution: interface: content content: solutions target: $SNAP_COMMON/solutions
Shouldnt that interface be auto connected?
I cant really check snapctl as I'm not able to access SSH on this ctrlx as it has been disabled. I was told that SSH was going to be disabled going forward?
Either way, I have been able to write a file to that location with a sandbox app so I know that I have access. What I cant figure out is how to put a file there during the install of the snap. Could you please provide an example on how you do that?
11-17-2021 02:06 PM - last edited on 11-22-2021 12:50 PM by CodeShepherd
Any update?
11-22-2021 01:12 PM - edited 11-22-2021 02:13 PM
Sorry for the late reply, busy days...
Yes, this plug is "auto" connected by the deviceadmin snap.
I extended the datalayer.registernode example from the SDK version 1.12 and added a hook that copies files when the necessary plug (active-solution) is connected.
See documentation of snapcraft:
https://snapcraft.io/docs/interface-hooks
https://snapcraft.io/docs/supported-snap-hooks
chmod +x connect-plug-active-solution
Add plug to the application, to be able to read/write test file in the program later on
apps:
registerNode:
command: registerNode
# interfaces to connect to https://snapcraft.io/docs/supported-interfaces
plugs:
- network
- datalayer
- active-solution
parts:
test:
plugin: dump
source: ./db_config
organize:
'*': ./db_config/
plugs:
active-solution:
interface: content
content: solutions
target: $SNAP_COMMON/solutions
hooks:
connect-plug-active-solution:
plugs: [active-solution]
#!/bin/bash
mkdir -p $SNAP_COMMON/solutions/activeConfiguration/db_config/
cp $SNAP/db_config/test $SNAP_COMMON/solutions/activeConfiguration/db_config/
After installation the folder "db_config" is added to the active configuration including file "test"