-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introduce new cronjob setup feature (#276)
* introduce new cronjob setup feature * add cron to allowed STEPS * update docs; update env config parsing for cron step * fix subproc function call to provide a list * add note in README about cronjobs
- Loading branch information
Showing
9 changed files
with
311 additions
and
253 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
""" | ||
NAME: onboardme.cron | ||
DESC: install cron jobs for the user and root | ||
AUTHORS: Jesse Hitch | ||
LICENSE: GNU AFFERO GENERAL PUBLIC LICENSE | ||
""" | ||
|
||
import logging as log | ||
from os import path | ||
from pathlib import Path | ||
|
||
# custom libs | ||
from getpass import getuser | ||
|
||
from .constants import HOME_DIR, OS | ||
from .console_logging import print_header, print_msg | ||
from .subproc import subproc | ||
|
||
|
||
def cron_setup() -> None: | ||
""" | ||
Installs crontab to run onboardme for user only functions | ||
On Linux: | ||
installs crontab for root to run apt commands | ||
""" | ||
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 | ||
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" | ||
|
||
# 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.') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "onboardme" | ||
version = "1.9.2" | ||
version = "1.10.0" | ||
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 <[email protected]>", | ||
|