diff --git a/bench/cli.py b/bench/cli.py index 97fa5122..8e797ee0 100644 --- a/bench/cli.py +++ b/bench/cli.py @@ -47,9 +47,8 @@ def check_uid(): sys.exit(1) def cmd_requires_root(): - if len(sys.argv) > 2 and sys.argv[2] in ('production', 'sudoers', 'lets-encrypt'): + if len(sys.argv) > 2 and sys.argv[2] in ('production', 'sudoers', 'lets-encrypt', 'fonts'): return True - #Changed > to >=, unsure if will cause the apolcaypse if len(sys.argv) >= 2 and sys.argv[1] in ('patch', 'renew-lets-encrypt', 'disable-production'): return True diff --git a/bench/commands/setup.py b/bench/commands/setup.py index 93676b15..5e7190f7 100644 --- a/bench/commands/setup.py +++ b/bench/commands/setup.py @@ -37,6 +37,13 @@ def setup_redis(): generate_config('.') +@click.command('fonts') +def setup_fonts(): + "Add frappe fonts to system" + from bench.config.fonts import setup_fonts + setup_fonts() + + @click.command('production') @click.argument('user') def setup_production(user): @@ -106,3 +113,4 @@ setup.add_command(setup_env) setup.add_command(setup_procfile) setup.add_command(setup_socketio) setup.add_command(setup_config) +setup.add_command(setup_fonts) diff --git a/bench/config/fonts.py b/bench/config/fonts.py new file mode 100644 index 00000000..f6885ab3 --- /dev/null +++ b/bench/config/fonts.py @@ -0,0 +1,17 @@ +import os, shutil +from bench.utils import exec_cmd + +def setup_fonts(): + fonts_path = os.path.join('/tmp', 'fonts') + + exec_cmd("git clone https://github.com/frappe/fonts.git", cwd='/tmp') + os.rename('/usr/share/fonts', '/usr/share/fonts_backup') + os.rename('/etc/fonts', '/etc/fonts_backup') + os.rename(os.path.join(fonts_path, 'usr_share_fonts'), '/usr/share/fonts') + os.rename(os.path.join(fonts_path, 'etc_fonts'), '/etc/fonts') + shutil.rmtree(fonts_path) + exec_cmd("fc-cache -fv") + + + +