diff --git a/init-server.py b/init-server.py index d19fdd8..97d9dde 100755 --- a/init-server.py +++ b/init-server.py @@ -131,14 +131,15 @@ def upload_https_host_files(c): create_parent_dir=True, ) - put(c, SCRIPTS_DIR / 'http_host' / 'cron.d' / 'ofm_http_host', '/etc/cron.d/') - c.sudo('chown -R ofm:ofm /data/ofm/http_host') c.sudo('rm -rf /data/ofm/http_host/logs') c.sudo('mkdir -p /data/ofm/http_host/logs') c.sudo('chown root:root /data/ofm/http_host/logs') + # always last + put(c, SCRIPTS_DIR / 'http_host' / 'cron.d' / 'ofm_http_host', '/etc/cron.d/') + def upload_certificates(c): for file in (CONFIG_DIR / 'certs').iterdir(): @@ -158,7 +159,7 @@ def debug_tmp(c): # upload_https_host_files(c) for file in [ - 'deploy_tiles_version.py', + 'mounter.py', ]: put( c, diff --git a/scripts/http_host/download_tiles.py b/scripts/http_host/download_tiles.py index af22828..188d62a 100755 --- a/scripts/http_host/download_tiles.py +++ b/scripts/http_host/download_tiles.py @@ -97,7 +97,7 @@ def download(area: str, version: str, runs_dir: Path) -> bool: check=True, ) - subprocess.run(['unpigz', temp_dir / 'tiles.btrfs.gz']) + subprocess.run(['unpigz', temp_dir / 'tiles.btrfs.gz'], check=True) btrfs_src = temp_dir / 'tiles.btrfs' shutil.rmtree(version_dir, ignore_errors=True) diff --git a/scripts/http_host/mounter.py b/scripts/http_host/mounter.py index 4ce973c..f7f2210 100755 --- a/scripts/http_host/mounter.py +++ b/scripts/http_host/mounter.py @@ -73,11 +73,22 @@ def clean_up_mounts(): with open('/etc/fstab') as fp: fstab_str = fp.read() + # handle deleted files + p = subprocess.run(['mount'], capture_output=True, text=True, check=True) + lines = [l for l in p.stdout.splitlines() if '/mnt/ofm/' in l and '(deleted)' in l] + for l in lines: + mnt_path = Path(l.split('(deleted) on ')[1].split(' type btrfs')[0]) + assert mnt_path.exists() + subprocess.run(['umount', mnt_path], check=True) + mnt_path.rmdir() + + # clean all mounts not in current fstab for subdir in mnt_dir.iterdir(): if f'{subdir} ' in fstab_str: continue - subprocess.run(['umount', subdir]) + print(f'removing old mount {subdir}') + subprocess.run(['umount', subdir], check=True) subdir.rmdir()