diff --git a/pasarguard.sh b/pasarguard.sh index 0d6664f..3e21c05 100755 --- a/pasarguard.sh +++ b/pasarguard.sh @@ -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 } 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