-
Notifications
You must be signed in to change notification settings - Fork 10
Fix: add crontab to acme.sh install dependency checks #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -321,16 +321,36 @@ is_port_in_use() { | |||||||||||||||||||||||||||||||
| return 1 | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| get_cron_package_name() { | ||||||||||||||||||||||||||||||||
| if [[ "$OS" == "Ubuntu"* ]] || [[ "$OS" == "Debian"* ]]; then | ||||||||||||||||||||||||||||||||
| echo "cron" | ||||||||||||||||||||||||||||||||
| elif [[ "$OS" == "CentOS"* ]] || [[ "$OS" == "AlmaLinux"* ]] || [ "$OS" == "Fedora"* ] || [ "$OS" == "Arch Linux" ]; then | ||||||||||||||||||||||||||||||||
| echo "cronie" | ||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||
| return 1 | ||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| ensure_acme_dependencies() { | ||||||||||||||||||||||||||||||||
| command -v socat >/dev/null 2>&1 || install_package socat | ||||||||||||||||||||||||||||||||
| command -v openssl >/dev/null 2>&1 || install_package openssl | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| local cron_pkg | ||||||||||||||||||||||||||||||||
| if ! command -v crontab >/dev/null 2>&1; then | ||||||||||||||||||||||||||||||||
| cron_pkg="$(get_cron_package_name)" | ||||||||||||||||||||||||||||||||
| install_package "$cron_pkg" | ||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||
|
Comment on lines
+337
to
+342
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing error handling when If 🛡️ Proposed fix to add error handling local cron_pkg
if ! command -v crontab >/dev/null 2>&1; then
- cron_pkg="$(get_cron_package_name)"
- install_package "$cron_pkg"
+ if cron_pkg="$(get_cron_package_name)"; then
+ install_package "$cron_pkg"
+ else
+ colorized_echo yellow "Warning: Could not determine cron package for this OS. Please install crontab manually."
+ fi
fi📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| install_acme() { | ||||||||||||||||||||||||||||||||
| colorized_echo blue "Installing acme.sh for SSL certificate management..." | ||||||||||||||||||||||||||||||||
| if curl -s https://get.acme.sh | sh >/dev/null 2>&1; then | ||||||||||||||||||||||||||||||||
| colorized_echo green "acme.sh installed successfully" | ||||||||||||||||||||||||||||||||
| return 0 | ||||||||||||||||||||||||||||||||
| local acme_bin="" | ||||||||||||||||||||||||||||||||
| acme_bin="$(get_acme_sh_binary)" || true | ||||||||||||||||||||||||||||||||
| if [ -n "$acme_bin" ] && [ -x "$acme_bin" ]; then | ||||||||||||||||||||||||||||||||
| colorized_echo green "acme.sh installed successfully" | ||||||||||||||||||||||||||||||||
| return 0 | ||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||
| colorized_echo red "Failed to install acme.sh" | ||||||||||||||||||||||||||||||||
| return 1 | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Glob pattern won't work with single brackets; also missing openSUSE support.
Line 327:
[ "$OS" == "Fedora"* ]uses single brackets which don't support glob matching. This condition will never match Fedora variants. The static analysis tool (Shellcheck SC2081) also flags this.Additionally,
openSUSEis supported ininstall_package()(line 207-209) but is not handled here, which will causeget_cron_package_nameto return failure on openSUSE systems.🐛 Proposed fix
get_cron_package_name() { if [[ "$OS" == "Ubuntu"* ]] || [[ "$OS" == "Debian"* ]]; then echo "cron" - elif [[ "$OS" == "CentOS"* ]] || [[ "$OS" == "AlmaLinux"* ]] || [ "$OS" == "Fedora"* ] || [ "$OS" == "Arch Linux" ]; then + elif [[ "$OS" == "CentOS"* ]] || [[ "$OS" == "AlmaLinux"* ]] || [[ "$OS" == "Fedora"* ]] || [[ "$OS" == "Arch Linux" ]]; then echo "cronie" + elif [[ "$OS" == "openSUSE"* ]]; then + echo "cronie" else return 1 fi }📝 Committable suggestion
🧰 Tools
🪛 Shellcheck (0.11.0)
[error] 327-327: [ .. ] can't match globs. Use [[ .. ]] or case statement.
(SC2081)
🤖 Prompt for AI Agents