Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data is not persistent (PB in run.sh) #4

Open
erambour opened this issue May 24, 2024 · 5 comments
Open

Data is not persistent (PB in run.sh) #4

erambour opened this issue May 24, 2024 · 5 comments

Comments

@erambour
Copy link

The way data is moved and linked, is only working once.

When I re-launch the docker-compose, my data is lost and I have to put new credentials
This seem to be because ln -sf can create a link to a removed (by mv) dir, but not to an existing one (it creates link in the existing directory). The result is that if data is effectively stored to an external volume, it's not mapped to the right place a the second run.

Explanation :

user@server:~/temp$ mkdir A; mkdir B; touch A/a; touch B/b
user@server:~/temp$ tree
.
├── A
│   └── a
└── B
    └── b

2 directories, 2 files
user@server:~/temp$ ln -sf A B
user@server:~/temp$ tree
.
├── A
│   └── a
└── B
    ├── A -> A
    └── b

2 directories, 3 files

That's not what we want, but if we remove the B directory the same command works as expected

user@server:~/temp$ rm -r B
user@server:~/temp$ ln -sf A B
user@server:~/temp$ tree
.
├── A
│   └── a
└── B -> A

I'v tried this modification, who partially solves the problem (user credentials are kept):

for path in $paths; do
    if [ ! -e /data/$path ]; then
        mkdir -p /data/$(dirname $path)
        if [ -e $path ]; then
            mv $path /data/$path
            echo "Moved ${path} to /data${path}."
        else
            mkdir -p /data/$path
            echo "Created ${path} in /data."
        fi
    else
         if [ -e $path ]; 
                then rm -r $path
         fi
    fi
    ln -sf /data$path $path
    echo "Created symlink for ${path}."
done

But the config folder ( I don't understand why config is stored in configS, and why the 'special case' ) if I apply the same procedure, Z-Wave is not working , and I've got a :
[I] [core] Notification: critical (z-wave): Cannot start Z-Wave binding: Error: Invalid config' error message.
But for a few apps ln -s to a directory just don't work, I've already had this problem.

@PoltoS
Copy link
Member

PoltoS commented May 24, 2024

Looks like we need to add just before this line

ln -sf /data/opt/z-way-server/configs/ /opt/z-way-server/
an rm -f $path. The first time this dir is moved (so not present), while the second time we need to remove it and replace with the symlink.

This rm should be places in two places (but in the second this is never a problem)

@PoltoS
Copy link
Member

PoltoS commented May 24, 2024

@msazanov Please fix.

The problem is that if the path is already present in the /data, the original folder is present (not moved), so the symlink goes into that folder

@PoltoS
Copy link
Member

PoltoS commented May 24, 2024

@erambour thanks for the finding!

@PoltoS
Copy link
Member

PoltoS commented May 24, 2024

Please try this:
#5

@erambour
Copy link
Author

erambour commented May 24, 2024

I've already added (see my post above) the following lines :

    else
         if [ -e $path ]; 
                then rm -r $path
         fi

in case of /data/ ... folder is existent.

That solves nearly everything, but I' was still facing a problem of invalid config / config not available for write

After a couple of modifications ( mapping a permanent storage to /opt/z-way-server/config : no change) and then chmoding 0777 all storage folder, the deleting and re-adding the z-wave and Zigbee apps (I own a z-station), it finally works (since a few minutes :-) .
The problem is that I don't really know what try did fix the last issue I had (no read/write access to config)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants