Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions pasarguard.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down