This commit is contained in:
Zsolt Ero
2023-12-21 03:07:55 +01:00
parent 48736bf87b
commit aaf9d2c74e
10 changed files with 50 additions and 42 deletions

View File

@@ -24,6 +24,7 @@ ignore = [
'E711', 'E711',
'E712', 'E712',
'E741', 'E741',
'F401', # unused imports
'F841', 'F841',
'PT004', 'PT004',
'SIM102', 'SIM102',

View File

@@ -30,8 +30,6 @@ def prepare_shared(c):
def prepare_tile_gen(c): def prepare_tile_gen(c):
install_planetiler(c) install_planetiler(c)
apt_get_install(c, 'btrfs-progs')
c.sudo('chown -R ofm:ofm /data/ofm') c.sudo('chown -R ofm:ofm /data/ofm')
for file in [ for file in [
@@ -40,8 +38,6 @@ def prepare_tile_gen(c):
'planetiler_planet.sh', 'planetiler_planet.sh',
'prepare-virtualenv.sh', 'prepare-virtualenv.sh',
'upload_cloudflare.sh', 'upload_cloudflare.sh',
'extract_mbtiles/extract_mbtiles.py',
'shrink_btrfs/extract_mbtiles.py',
]: ]:
put( put(
c, c,
@@ -54,19 +50,19 @@ def prepare_tile_gen(c):
put( put(
c, c,
scripts / 'tile_gen' / 'extract_mbtiles' / 'extract_mbtiles.py', scripts / 'tile_gen' / 'extract_mbtiles' / 'extract_mbtiles.py',
TILE_GEN_BIN / 'extract_mbtiles', f'{TILE_GEN_BIN}/extract_mbtiles/extract_mbtiles.py',
permissions='755', permissions='755',
owner='ofm', owner='ofm',
target_is_dir=True, create_parent_dir=True,
) )
put( put(
c, c,
scripts / 'tile_gen' / 'shrink_btrfs' / 'shrink_btrfs.py', scripts / 'tile_gen' / 'shrink_btrfs' / 'shrink_btrfs.py',
TILE_GEN_BIN / 'shrink_btrfs', f'{TILE_GEN_BIN}/shrink_btrfs/shrink_btrfs.py',
permissions='755', permissions='755',
owner='ofm', owner='ofm',
target_is_dir=True, create_parent_dir=True,
) )
sudo_cmd(c, f'cd {TILE_GEN_BIN} && source prepare-virtualenv.sh', user='ofm') sudo_cmd(c, f'cd {TILE_GEN_BIN} && source prepare-virtualenv.sh', user='ofm')

View File

@@ -92,4 +92,4 @@ mv image2.btrfs tiles.btrfs
pigz tiles.btrfs --fast pigz tiles.btrfs --fast
echo DONE echo extract_btrfs.sh DONE

View File

@@ -42,7 +42,7 @@ def cli(mbtiles_path: Path, dir_path: Path):
# print(f'Tile number: {calculate_tiles_sum(14)} - OK') # print(f'Tile number: {calculate_tiles_sum(14)} - OK')
write_metadata(c, dir_path=dir_path) write_metadata(c, dir_path=dir_path)
print('DONE') print('extract_mbtiles.py DONE')
def write_metadata(c, *, dir_path): def write_metadata(c, *, dir_path):

View File

@@ -22,8 +22,8 @@ java -Xmx1g \
`# Store temporary node locations at fixed positions in a memory-mapped file` \ `# Store temporary node locations at fixed positions in a memory-mapped file` \
--nodemap-type=array --storage=mmap \ --nodemap-type=array --storage=mmap \
--force \ --force \
> "planetiler_out.log" 2> "planetiler_err.log" > planetiler_out 2> planetiler_err
rm -r data rm -r data
$TILE_GEN_BIN/extract_btrfs.sh #$TILE_GEN_BIN/extract_btrfs.sh

View File

@@ -24,7 +24,8 @@ java -Xmx30g \
`# Store temporary node locations at fixed positions in a memory-mapped file` \ `# Store temporary node locations at fixed positions in a memory-mapped file` \
--nodemap-type=array --storage=mmap \ --nodemap-type=array --storage=mmap \
--force \ --force \
> "planetiler_out.log" 2> "planetiler_err.log" > planetiler_out 2> planetiler_err
rm -r data rm -r data
#$TILE_GEN_BIN/extract_btrfs.sh

View File

@@ -11,5 +11,6 @@ venv/bin/pip -V
venv/bin/pip install -U pip wheel setuptools venv/bin/pip install -U pip wheel setuptools
venv/bin/pip install click

View File

@@ -70,6 +70,7 @@ def cli(btrfs_img: Path):
subprocess.run(['truncate', '-s', str(total_size), btrfs_img]) subprocess.run(['truncate', '-s', str(total_size), btrfs_img])
print(f'Truncated {btrfs_img} to {total_size//1_000_000} MB size') print(f'Truncated {btrfs_img} to {total_size//1_000_000} MB size')
print('shrink_btrfs.py DONE')
def get_usage(mnt: Path, key: str): def get_usage(mnt: Path, key: str):

View File

@@ -7,11 +7,31 @@ from ssh_lib.utils import (
) )
def pkg_upgrade(c): def pkg_base(c):
apt_get_update(c) pkg_list = [
c.sudo( 'lsb-release',
'DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -y -o Dpkg::Options::="--force-confold"' 'wget',
) 'git',
'build-essential',
'unzip',
'rsync',
'btrfs-progs',
'pigz',
#
'gnupg2',
'gnupg-agent',
'ca-certificates',
'ubuntu-keyring',
#
'nload',
'iftop',
'vnstat',
#
'python3',
'python3-venv',
]
apt_get_install(c, ' '.join(pkg_list))
def pkg_clean(c): def pkg_clean(c):
@@ -34,25 +54,8 @@ def pkg_clean(c):
c.sudo('iptables -L', warn=True) c.sudo('iptables -L', warn=True)
def pkg_base(c): def pkg_upgrade(c):
pkg_list = [ apt_get_update(c)
'lsb-release', c.sudo(
'wget', 'DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -y -o Dpkg::Options::="--force-confold"'
'git', )
'build-essential',
'unzip',
#
'gnupg2',
'gnupg-agent',
'ca-certificates',
'ubuntu-keyring',
#
'nload',
'iftop',
'vnstat',
#
'python3',
'python3-venv',
]
apt_get_install(c, ' '.join(pkg_list))

View File

@@ -4,12 +4,17 @@ import string
def put( def put(
c, local_path, remote_path, permissions=None, owner='root', group=None, target_is_dir=False c, local_path, remote_path, permissions=None, owner='root', group=None, create_parent_dir=False
): ):
tmp_path = f'/tmp/fabtmp_{random_string(8)}' tmp_path = f'/tmp/fabtmp_{random_string(8)}'
c.put(local_path, tmp_path) c.put(local_path, tmp_path)
if is_dir(c, remote_path) or target_is_dir: if create_parent_dir:
dirname = os.path.dirname(remote_path)
c.sudo(f'mkdir -p {dirname}')
set_permission(c, dirname, owner=owner, group=group)
if is_dir(c, remote_path):
if not remote_path.endswith('/'): if not remote_path.endswith('/'):
remote_path += '/' remote_path += '/'