This commit is contained in:
ahmadbilalkhalid 2019-09-17 17:46:00 +05:00
parent abbf68d5f1
commit 41737ee35a
2 changed files with 16 additions and 16 deletions

View file

@ -2,7 +2,7 @@ import click
import subprocess as sp
import os
from app.helper import install_available
from app.helper import install_available, get_distro_name
@click.group()
def file_scan():
@ -44,13 +44,14 @@ def setup(path, base_dir, file_prefix, etcd_url, branch):
# Create virtualenv with site-packages enabled and install all dependencies
sp.check_output(['pipenv', 'install'], cwd=repo_name)
# TODO: Devuan/Debian have crontab under /etc/crontab
# while Alpine have it under /etc/crontabs/root
# Detect in the following code where should we write
# our crontab entries
# Write Crontab entry
with open("/etc/crontabs/root", "a") as crontab:
if get_distro_name() == "alpine":
crontab_path = "/etc/crontabs/root"
else:
crontab_path = "/etc/crontab"
with open(crontab_path, "a") as crontab:
crontab.write(
f"*/1\t*\t*\t*\t*\t$(cd {os.path.join(os.getcwd(), repo_name)} && pipenv run python main.py)\n"
)
)

View file

@ -2,7 +2,7 @@ import click
import subprocess as sp
import os
from app.helper import install_available
from app.helper import install_available, get_distro_name
@click.group()
def image():
@ -42,15 +42,14 @@ def setup(path, base_dir, etcd_url, without_ceph, branch):
install_available(repo_name)
sp.check_output(['pipenv', 'install'], cwd=repo_name)
# TODO: Devuan/Debian have crontab under /etc/crontab
# while Alpine have it under /etc/crontabs/root
# Detect in the following code where should we write
# our crontab entries
# Write Crontab entry
with open("/etc/crontabs/root", "a") as crontab:
if get_distro_name() == "alpine":
crontab_path = "/etc/crontabs/root"
else:
crontab_path = "/etc/crontab"
with open(crontab_path, "a") as crontab:
crontab.write(
f"*/1\t*\t*\t*\t*\t$(cd {os.path.join(os.getcwd(), repo_name)} && pipenv run python main.py)\n"
)