keep symlinks after updating
This commit is contained in:
parent
c0d9e168b3
commit
6450001541
@ -39,7 +39,6 @@ class Stack:
|
|||||||
|
|
||||||
self.pid = config.get(f"{self.name}-pid")
|
self.pid = config.get(f"{self.name}-pid")
|
||||||
|
|
||||||
|
|
||||||
def install(self):
|
def install(self):
|
||||||
if self.is_installed():
|
if self.is_installed():
|
||||||
self.update()
|
self.update()
|
||||||
@ -74,8 +73,10 @@ class Stack:
|
|||||||
self.stop()
|
self.stop()
|
||||||
|
|
||||||
logger.info(f"Updating {self.name}")
|
logger.info(f"Updating {self.name}")
|
||||||
|
symlinks = utils.find_symlink_in_folder(self.path)
|
||||||
self.git_pull(folder)
|
self.git_pull(folder)
|
||||||
self._update()
|
self._update()
|
||||||
|
utils.create_symlinks(symlinks)
|
||||||
|
|
||||||
if status:
|
if status:
|
||||||
self.start()
|
self.start()
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
import importlib
|
import importlib
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
|
from pathlib import Path
|
||||||
from urllib import request, error
|
from urllib import request, error
|
||||||
|
|
||||||
from core.stack import Stack
|
from core.stack import Stack
|
||||||
@ -79,3 +81,24 @@ def load_service_from_string(service: str) -> Stack:
|
|||||||
met = getattr(module, service_name)
|
met = getattr(module, service_name)
|
||||||
return met()
|
return met()
|
||||||
|
|
||||||
|
|
||||||
|
def find_symlink_in_folder(folder: str):
|
||||||
|
symlinks = {}
|
||||||
|
for file in Path(folder).rglob("webui/**"):
|
||||||
|
if file.is_symlink():
|
||||||
|
symlinks[file] = file.resolve()
|
||||||
|
|
||||||
|
return symlinks
|
||||||
|
|
||||||
|
|
||||||
|
def create_symlinks(symlinks: dict[Path, Path]):
|
||||||
|
for target, link in symlinks.items():
|
||||||
|
logger.debug(f"(re)Creating symlink: {link} -> {target}")
|
||||||
|
|
||||||
|
if target.is_symlink():
|
||||||
|
target.unlink()
|
||||||
|
|
||||||
|
if target.exists() and target.is_dir():
|
||||||
|
shutil.rmtree(target)
|
||||||
|
|
||||||
|
os.symlink(link, target)
|
||||||
|
Loading…
Reference in New Issue
Block a user