From ab0b0d7f9a241ae72be015e76f212d52d252c9e8 Mon Sep 17 00:00:00 2001 From: Jesse Hitch Date: Mon, 21 Oct 2024 00:45:01 +0200 Subject: [PATCH] simplify `cronjob_setup` function by using `crontab`, and update pre-commit dep (#277) * simplify cronjob_setup function * fix docs and finish fixing macos crontab usage --- docs/onboardme/screenshots/help_text.svg | 232 ++++++++++++----------- onboardme/cron.py | 19 +- poetry.lock | 8 +- pyproject.toml | 4 +- 4 files changed, 131 insertions(+), 132 deletions(-) diff --git a/docs/onboardme/screenshots/help_text.svg b/docs/onboardme/screenshots/help_text.svg index ac16413..6b20187 100644 --- a/docs/onboardme/screenshots/help_text.svg +++ b/docs/onboardme/screenshots/help_text.svg @@ -1,4 +1,4 @@ - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + - term + term - + - -                                                  ☁️  OnBoardMe 💻 -Get your daily driver just the way you like it, from textformatting, and dot files to opensource package -installation, onboardme intends to save you time with initializing or upgrading your environment. - -Usage:  onboardme[OPTIONS] - -╭─ ⌥  Options ───────────────────────────────────────────────────────────────────────────────────────────────────╮ - --l--log_level LOGLEVELLogging level. Choices: debuginfowarnerror -Default: warn - --o--log_file LOGFILEFull path to file to log to, if set.                                            - --s--steps STEPOnly run STEP in the script.                                                    -Choices: dot_filespackagesfont_setupneovim_setupgroup_setupsudo_setup -Example: -sdot_files-spackages - --u--git_url URLA git repo URL for your dot files. Default:                                     -https://github.com/jessebot/dot_files - --b--git_branch BRANCHBranch to use for the git repo url. Default: main                               - --d--git_config_dir PATHDirectory to store the git configuration for your dot files. Default:           -~/.config/dot_files                                                             - --O--overwriteOverwrites existing dot files with files from configured --git_url repo. If     -you've set overwrite: true in your config, then --overwrite on the command line -will act as a toggle, so it will NOT overwrite your dot files.                  - --p--pkg_managers PKG_MANAGERSpecific PKG_MANAGER to run. Choices: brewpip3.12pip3.11pipx -Example: -pbrew-ppip3.12 - --g--pkg_groups PKG_GROUPPackage groups to install.                                                      -Choices: defaultdata_sciencedevopsgamingguimailmusicwork -Example: -gdevops-ggaming - --f--firewallSetup iptables (on linux only).                                                 - --r--remote_host IP_ADDRSetup SSH on a random port & add IP_ADDR to firewall                            - --n--no_upgradeDo not upgrade the existing brew or apt packages.                               - ---versionPrint the version of onboardme (1.10.0)                                         - ---helpShow this message and exit.                                                     -╰────────────────────────────────────────────────────────────────────────  ♥ docs: jessebot.github.io/onboardme─╯ + +                                                  ☁️  OnBoardMe 💻 +Get your daily driver just the way you like it, from textformatting, and dot files to opensource package +installation, onboardme intends to save you time with initializing or upgrading your environment. + +Usage:  onboardme[OPTIONS] + +╭─ ⌥  Options ───────────────────────────────────────────────────────────────────────────────────────────────────╮ + +-l--log_level LOGLEVELLogging level. Choices: debuginfowarnerror +Default: warn + +-o--log_file LOGFILEFull path to file to log to, if set.                                            + +-s--steps STEPOnly run STEP in the script.                                                    +Choices: dot_filespackagescronfont_setupneovim_setupgroup_setup,      +sudo_setup +Example: -sdot_files-spackages + +-u--git_url URLA git repo URL for your dot files. Default:                                     +https://github.com/jessebot/dot_files + +-b--git_branch BRANCHBranch to use for the git repo url. Default: main                               + +-d--git_config_dir PATHDirectory to store the git configuration for your dot files. Default:           +~/.config/dot_files                                                             + +-O--overwriteOverwrites existing dot files with files from configured --git_url repo. If     +you've set overwrite: true in your config, then --overwrite on the command line +will act as a toggle, so it will NOT overwrite your dot files.                  + +-p--pkg_managers PKG_MANAGERSpecific PKG_MANAGER to run. Choices: brewpip3.12pip3.11pipx +Example: -pbrew-ppip3.12 + +-g--pkg_groups PKG_GROUPPackage groups to install.                                                      +Choices: defaultdata_sciencedevopsgamingguimailmusicwork +Example: -gdevops-ggaming + +-f--firewallSetup iptables (on linux only).                                                 + +-r--remote_host IP_ADDRSetup SSH on a random port & add IP_ADDR to firewall                            + +-n--no_upgradeDo not upgrade the existing brew or apt packages.                               + +--versionPrint the version of onboardme (1.10.1)                                         + +--helpShow this message and exit.                                                     +╰────────────────────────────────────────────────────────────────────────  ♥ docs: jessebot.github.io/onboardme─╯ diff --git a/onboardme/cron.py b/onboardme/cron.py index b624e90..5342e64 100644 --- a/onboardme/cron.py +++ b/onboardme/cron.py @@ -24,25 +24,20 @@ def cron_setup() -> None: On Linux: installs crontab for root to run apt commands """ + user_crontab = f'{HOME_DIR}/.config/cron/user/crontab' + print_header('⏰ [i]crontab[/i] installations') if 'Linux' in OS: - cron_dir = "/etc/crontab.d" - - # install root level cronjobs root_crontab = f'{HOME_DIR}/.config/cron/root/crontab' - - # do a shallow clone of the repo + # install root level cronjobs if path.exists(root_crontab): log.info('Installing root crontab.') - subproc([f'sudo cp {root_crontab} {cron_dir}/root']) - print_msg('[i]root crontab installed.') - else: - cron_dir = "/var/at/tabs" + subproc([f'sudo crontab {root_crontab}']) + print_msg('\n[i]root crontab installed.') # install user level cronjobs - user_crontab = f'{HOME_DIR}/.config/cron/user/crontab' if path.exists(user_crontab): log.info('Installing user crontab.') username = getuser() - subproc([f'sudo cp {user_crontab} {cron_dir}/{username}']) - print_msg('[i]User crontab installed.') + subproc([f'crontab {HOME_DIR}/.config/cron/user/crontab']) + print_msg('\n[i]User crontab installed.') diff --git a/poetry.lock b/poetry.lock index 17a2b02..9d8ff5d 100644 --- a/poetry.lock +++ b/poetry.lock @@ -173,13 +173,13 @@ type = ["mypy (>=1.11.2)"] [[package]] name = "pre-commit" -version = "3.8.0" +version = "4.0.1" description = "A framework for managing and maintaining multi-language pre-commit hooks." optional = false python-versions = ">=3.9" files = [ - {file = "pre_commit-3.8.0-py2.py3-none-any.whl", hash = "sha256:9a90a53bf82fdd8778d58085faf8d83df56e40dfe18f45b19446e26bf1b3a63f"}, - {file = "pre_commit-3.8.0.tar.gz", hash = "sha256:8bb6494d4a20423842e198980c9ecf9f96607a07ea29549e180eef9ae80fe7af"}, + {file = "pre_commit-4.0.1-py2.py3-none-any.whl", hash = "sha256:efde913840816312445dc98787724647c65473daefe420785f885e8ed9a06878"}, + {file = "pre_commit-4.0.1.tar.gz", hash = "sha256:80905ac375958c0444c65e9cebebd948b3cdb518f335a091a670a89d652139d2"}, ] [package.dependencies] @@ -338,4 +338,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = ">=3.11,<3.13" -content-hash = "9d04e54c7f72cc24f29c0308f79a25643fd6dcef761079b9e2e8a1213d1745f1" +content-hash = "fdf2266dfc7b6282981fd8d2d5b0dc03cec97403f10da58045dcc441f06b6b83" diff --git a/pyproject.toml b/pyproject.toml index 862d5bb..47aac84 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "onboardme" -version = "1.10.0" +version = "1.10.1" description = "Install dot files and packages, including a base mode with sensible defaults to run on most computers running Debian based distros or macOS." authors = [ "Jesse Hitch ", @@ -32,7 +32,7 @@ wget = "^3.2" xdg-base-dirs = "^6.0" [tool.poetry.group.dev.dependencies] -pre-commit = "^3.7" +pre-commit = "^4.0" [tool.poetry.plugins."onboardme.application.plugin"] "onboardme" = "onboardme:main"