mirror of
https://github.com/hyperknot/openfreemap.git
synced 2026-05-21 14:02:15 +00:00
cron fixes
This commit is contained in:
@@ -4,11 +4,39 @@ from pathlib import Path
|
||||
from http_host_lib import DEFAULT_RUNS_DIR, MNT_DIR
|
||||
|
||||
|
||||
def create_fstab():
|
||||
fstab_new = []
|
||||
|
||||
for area in ['planet', 'monaco']:
|
||||
area_dir = (DEFAULT_RUNS_DIR / area).resolve()
|
||||
if not area_dir.exists():
|
||||
continue
|
||||
|
||||
versions = sorted(area_dir.iterdir())
|
||||
for version in versions:
|
||||
version_str = version.name
|
||||
btrfs_file = area_dir / version_str / 'tiles.btrfs'
|
||||
if not btrfs_file.is_file():
|
||||
continue
|
||||
|
||||
mnt_folder = MNT_DIR / f'{area}-{version_str}'
|
||||
mnt_folder.mkdir(exist_ok=True, parents=True)
|
||||
|
||||
fstab_new.append(f'{btrfs_file} {mnt_folder} btrfs loop,ro 0 0\n')
|
||||
print(f' created fstab entry for {btrfs_file} -> {mnt_folder}')
|
||||
|
||||
with open('/etc/fstab') as fp:
|
||||
fstab_orig = [l for l in fp.readlines() if f'{MNT_DIR}/' not in l]
|
||||
|
||||
with open('/etc/fstab', 'w') as fp:
|
||||
fp.writelines(fstab_orig + fstab_new)
|
||||
|
||||
|
||||
def clean_up_mounts(mnt_dir):
|
||||
if not mnt_dir.exists():
|
||||
return
|
||||
|
||||
print('Cleaning up mounts')
|
||||
print(' cleaning up mounts')
|
||||
|
||||
# handle deleted files
|
||||
p = subprocess.run(['mount'], capture_output=True, text=True, check=True)
|
||||
@@ -32,31 +60,3 @@ def clean_up_mounts(mnt_dir):
|
||||
print(f' removing old mount {subdir}')
|
||||
subprocess.run(['umount', subdir], check=True)
|
||||
subdir.rmdir()
|
||||
|
||||
|
||||
def create_fstab():
|
||||
fstab_new = []
|
||||
|
||||
for area in ['planet', 'monaco']:
|
||||
area_dir = (DEFAULT_RUNS_DIR / area).resolve()
|
||||
if not area_dir.exists():
|
||||
continue
|
||||
|
||||
versions = sorted(area_dir.iterdir())
|
||||
for version in versions:
|
||||
version_str = version.name
|
||||
btrfs_file = area_dir / version_str / 'tiles.btrfs'
|
||||
if not btrfs_file.is_file():
|
||||
continue
|
||||
|
||||
mnt_folder = MNT_DIR / f'{area}-{version_str}'
|
||||
mnt_folder.mkdir(exist_ok=True, parents=True)
|
||||
|
||||
fstab_new.append(f'{btrfs_file} {mnt_folder} btrfs loop,ro 0 0\n')
|
||||
print(f'Created fstab entry for {btrfs_file} -> {mnt_folder}')
|
||||
|
||||
with open('/etc/fstab') as fp:
|
||||
fstab_orig = [l for l in fp.readlines() if f'{MNT_DIR}/' not in l]
|
||||
|
||||
with open('/etc/fstab', 'w') as fp:
|
||||
fp.writelines(fstab_orig + fstab_new)
|
||||
|
||||
Reference in New Issue
Block a user