diff --git a/bench/cli.py b/bench/cli.py index b3eb871d..4ed7149d 100755 --- a/bench/cli.py +++ b/bench/cli.py @@ -29,9 +29,12 @@ def cli(): change_working_directory() logger = setup_logging() logger.info(command) - check_uid() + + if sys.argv[1] not in ("src", ): + check_uid() + change_uid() + change_dir() - change_uid() if is_dist_editable(bench.PROJECT_NAME) and len(sys.argv) > 1 and sys.argv[1] != "src" and not get_config(".").get("developer_mode"): log("bench is installed in editable mode!\n\nThis is not the recommended mode of installation for production. Instead, install the package from PyPI with: `pip install frappe-bench`\n", level=3) diff --git a/bench/commands/utils.py b/bench/commands/utils.py index 78899d19..5d9ac6d5 100644 --- a/bench/commands/utils.py +++ b/bench/commands/utils.py @@ -111,7 +111,7 @@ def download_translations(): download_translations_p() -@click.command('renew-lets-encrypt', help="Renew Let's Encrypt certificate") +@click.command('renew-lets-encrypt', help="Sets Up latest cron and Renew Let's Encrypt certificate") def renew_lets_encrypt(): from bench.config.lets_encrypt import renew_certs renew_certs() diff --git a/bench/config/lets_encrypt.py b/bench/config/lets_encrypt.py index 5f0396b9..32ca3380 100755 --- a/bench/config/lets_encrypt.py +++ b/bench/config/lets_encrypt.py @@ -87,11 +87,17 @@ def run_certbot_and_setup_ssl(site, custom_domain, bench_path, interactive=True) def setup_crontab(): job_command = '/opt/certbot-auto renew -a nginx --post-hook "systemctl reload nginx"' + job_comment = 'Renew lets-encrypt every month' + print("Setting Up cron job to {0}".format(job_comment)) + system_crontab = CronTab(user='root') - if job_command not in str(system_crontab): - job = system_crontab.new(command=job_command, comment="Renew lets-encrypt every month") - job.day.on(1) - system_crontab.write() + + for job in system_crontab.find_comment(comment=job_comment): # Removes older entries + system_crontab.remove(job) + + job = system_crontab.new(command=job_command, comment=job_comment) + job.setall('0 0 */1 * *') # Run at 00:00 every day-of-month + system_crontab.write() def create_dir_if_missing(path): @@ -113,10 +119,13 @@ def get_certbot_path(): def renew_certs(): + # Needs to be run with sudo click.confirm('Running this will stop the nginx service temporarily causing your sites to go offline\n' 'Do you want to continue?', abort=True) + setup_crontab() + service('nginx', 'stop') exec_cmd("{path} renew".format(path=get_certbot_path())) service('nginx', 'start') diff --git a/docs/bench_usage.md b/docs/bench_usage.md index cf9a0364..807d021f 100644 --- a/docs/bench_usage.md +++ b/docs/bench_usage.md @@ -72,7 +72,7 @@ These commands belong directly to the bench group so they can be invoked directl - **init**: Initialize a new bench instance in the specified path. This sets up a complete bench folder with an `apps` folder which contains all the Frappe apps available in the current bench, `sites` folder that stores all site data seperated by individual site folders, `config` folder that contains your redis, NGINX and supervisor configuration files. The `env` folder consists of all python dependencies the current bench and installed Frappe applications have. - **restart**: Restart web, supervisor, systemd processes units. Used in production setup. - - **update**: Updates bench tool and if executed in a bench directory, without any flags will backup, pull, setup requirements, build, run patches and restart bench. Using specific flags will only do certain tasks instead of all. + - **update**: If executed in a bench directory, without any flags will backup, pull, setup requirements, build, run patches and restart bench. Using specific flags will only do certain tasks instead of all. - **migrate-env**: Migrate Virtual Environment to desired Python version. This regenerates the `env` folder with the specified Python version. - **retry-upgrade**: Retry a failed upgrade - **disable-production**: Disables production environment for the bench. diff --git a/docs/commands_and_usage.md b/docs/commands_and_usage.md index 92ad33bc..ed71cc59 100644 --- a/docs/commands_and_usage.md +++ b/docs/commands_and_usage.md @@ -2,9 +2,14 @@ * Updating - Currently, `bench update` can be run from any directory however the context of the command changes. If run from a bench directory, the vanilla command itself updates all apps, runs migrations and backs up all sites. +To update the bench CLI tool, depending on your method of installation, you may use - bench update + pip3 install -U frappe-bench + + +To backup, update all apps and sites on your bench, you may use + + bench update To manually update the bench, run `bench update` to update all the apps, run diff --git a/install.py b/install.py index 2b70d7f4..46ce4247 100644 --- a/install.py +++ b/install.py @@ -163,7 +163,7 @@ def install_prerequisites(): install_package('pip3', 'python3-pip') success = run_os_command({ - 'python3': "sudo -H python3 -m pip install --upgrade setuptools cryptography ansible==2.8.5 pip" + 'python3': "sudo -H python3 -m pip install --upgrade setuptools wheel cryptography ansible==2.8.5 pip" }) if not (success or shutil.which('ansible')): @@ -269,7 +269,7 @@ def install_bench(args): def clone_bench_repo(args): '''Clones the bench repository in the user folder''' - branch = args.bench_branch or 'master' + branch = args.bench_branch or 'develop' repo_url = args.repo_url or 'https://github.com/frappe/bench' if os.path.exists(tmp_bench_repo): @@ -464,11 +464,11 @@ if __name__ == '__main__': with warnings.catch_warnings(): warnings.simplefilter("ignore") setup_log_stream(args) + install_prerequisites() setup_script_requirements() check_distribution_compatibility() check_system_package_managers() check_environment() - install_prerequisites() install_bench(args) log("Bench + Frappe + ERPNext has been successfully installed!") diff --git a/requirements.txt b/requirements.txt index e00b90ea..ea1bdd08 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,6 +5,6 @@ Jinja2==2.10.3 python-crontab==2.4.0 requests==2.22.0 semantic-version==2.8.2 -setuptools==40.8.0 -six==1.12.0 -virtualenv==16.6.0 +setuptools +six +virtualenv diff --git a/vm/scripts/set_message_production.sh b/vm/scripts/set_message_production.sh index 74182ca6..2fddcb77 100644 --- a/vm/scripts/set_message_production.sh +++ b/vm/scripts/set_message_production.sh @@ -6,7 +6,7 @@ message=" Please access ERPNext by going to http://localhost:8080 on the host system. The username is \"Administrator\" and password is \"admin\" - Do consider donating at https://frappe.io/buy + Consider buying professional support from us at https://erpnext.com/support To update, login as username: frappe