Add TAG V1.0.0 + rename commands

This commit is contained in:
Erreur32 2024-07-15 12:59:33 +02:00
parent 709f402bc8
commit 74c15959c5

View file

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
# Nginx Proxy Manager CLI Script v0.0.2 # Nginx Proxy Manager CLI Script v1.0.0
# Erreur32 - July 2024 # Erreur32 - July 2024
# #
# This script allows you to manage Nginx Proxy Manager via the API. It provides # This script allows you to manage Nginx Proxy Manager via the API. It provides
@ -11,22 +11,24 @@
# ./nginx_proxy_manager_cli.sh [OPTIONS] # ./nginx_proxy_manager_cli.sh [OPTIONS]
# #
# Examples: # Examples:
# Backup First ! # 📦 Backup First!
# ./nginx_proxy_manager_cli.sh --backup # ./nginx_proxy_manager_cli.sh --host-backup
# #
# 🌐 Host Creation:
# ./nginx_proxy_manager_cli.sh -d example.com -i 192.168.1.10 -p 8080 (check default values below) # ./nginx_proxy_manager_cli.sh -d example.com -i 192.168.1.10 -p 8080 (check default values below)
# ./nginx_proxy_manager_cli.sh --show-default # ./nginx_proxy_manager_cli.sh --host-show-default
# ./nginx_proxy_manager_cli.sh --create-user newuser password123 user@example.com # ./nginx_proxy_manager_cli.sh --host-create-user newuser password123 user@example.com
# ./nginx_proxy_manager_cli.sh --delete-user 'username' # ./nginx_proxy_manager_cli.sh --host-delete-user 'username'
# ./nginx_proxy_manager_cli.sh --list-hosts # ./nginx_proxy_manager_cli.sh --host-list
# #
# ./nginx_proxy_manager_cli.sh --generate-cert example.com user@example.com --custom # 🔧 Advanced Example:
# ./nginx_proxy_manager_cli.sh --ssl-host-enable 1
#
# Advanced proxy tab example:
# ./nginx_proxy_manager_cli.sh -d example.com -i 192.168.1.10 -p 8080 -a 'proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;' # ./nginx_proxy_manager_cli.sh -d example.com -i 192.168.1.10 -p 8080 -a 'proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;'
# ./nginx_proxy_manager_cli.sh --host-ssl-enable 1
# ./nginx_proxy_manager_cli.sh --host-generate-cert example.com user@example.com --custom
# #
# Options: # Options:
#
# 🌐 Host proxy creation:
# -d DOMAIN_NAMES Domain name (required for creating/updating hosts) # -d DOMAIN_NAMES Domain name (required for creating/updating hosts)
# -i FORWARD_HOST IP address or domain name of the target server (required for creating/updating hosts) # -i FORWARD_HOST IP address or domain name of the target server (required for creating/updating hosts)
# -p FORWARD_PORT Port of the target server (required for creating/updating hosts) # -p FORWARD_PORT Port of the target server (required for creating/updating hosts)
@ -35,24 +37,31 @@
# -b BLOCK_EXPLOITS Block exploits (true/false, default: true) # -b BLOCK_EXPLOITS Block exploits (true/false, default: true)
# -w ALLOW_WEBSOCKET_UPGRADE Allow WebSocket upgrade (true/false, default: true) # -w ALLOW_WEBSOCKET_UPGRADE Allow WebSocket upgrade (true/false, default: true)
# -a ADVANCED_CONFIG Advanced configuration (block of configuration settings) # -a ADVANCED_CONFIG Advanced configuration (block of configuration settings)
# --backup Backup all configurations to a file #
# --check-token Check if the current token is valid # 📦 Backup and Restore:
# --create-user user pass email Create a user with a username, password and email # --host-backup Backup all configurations to a file
# --delete-user username Delete a user by username # --host-backup-id id Backup a single host configuration and its certificate (if exists)
# --delete-host id Delete a proxy host by ID # --host-restore Restore configurations from a backup file
# --show-host id Show full details for a specific host by ID # --host-restore-id id Restore a single host configuration and its certificate (if exists)
# --show-default Show default settings for creating hosts #
# --list-hosts List the names of all proxy hosts # 🔧 Miscellaneous:
# --list-hosts-full List all proxy hosts with full details # --host-check-token Check if the current token is valid
# --list-ssl-certificates List all SSL certificates # --host-create-user user pass email Create a user with a username, password and email
# --list-users List all users # --host-delete-user username Delete a user by username
# --search-host hostname Search for a proxy host by domain name # --host-delete id Delete a proxy host by ID
# --enable-host id Enable a proxy host by ID # --host-show id Show full details for a specific host by ID
# --disable-host id Disable a proxy host by ID # --host-show-default Show default settings for creating hosts
# --ssl-host-enable id Enable SSL, HTTP/2, and HSTS for a proxy host ( don't need to generate a custom cert. ) # --host-list List the names of all proxy hosts
# --ssl-host-disable id Disable SSL, HTTP/2, and HSTS for a proxy host # --host-list-full List all proxy hosts with full details
# --generate-cert domain email [--custom] Generate a Let's Encrypt or Custom certificate for the given domain and email ( not finish ) # --host-list-ssl-certificates List all SSL certificates
# --help Display this help # --host-list-users List all users
# --host-search hostname Search for a proxy host by domain name
# --host-enable id Enable a proxy host by ID
# --host-disable id Disable a proxy host by ID
# --host-ssl-enable id Enable SSL, HTTP/2, and HSTS for a proxy host (don't need to generate a custom cert.)
# --host-ssl-disable id Disable SSL, HTTP/2, and HSTS for a proxy host
# --host-generate-cert domain email [--custom] Generate a Let's Encrypt or Custom certificate for the given domain and email
# --host-help Display this help
################################ ################################
# Variables to Edit (required) # # Variables to Edit (required) #
@ -63,7 +72,6 @@ NGINX_IP="127.0.0.1"
API_USER="user@nginx" API_USER="user@nginx"
API_PASS="pass nginx" API_PASS="pass nginx"
################################# #################################
# Variables to Edit (optional) # # Variables to Edit (optional) #
################################# #################################
@ -106,6 +114,9 @@ ENABLE_HOST=false
DISABLE_HOST=false DISABLE_HOST=false
CHECK_TOKEN=false CHECK_TOKEN=false
BACKUP=false BACKUP=false
BACKUP_HOST=false
RESTORE=false
RESTORE_HOST=false
GENERATE_CERT=false GENERATE_CERT=false
ENABLE_SSL=false ENABLE_SSL=false
DISABLE_SSL=false DISABLE_SSL=false
@ -137,23 +148,26 @@ check_dependencies
# Display help # Display help
usage() { usage() {
echo -e "\n${COLOR_YELLOW}Usage:./nginx_proxy_manager_cli.sh -d domain -i ip -p port [-f forward_scheme] [-c caching_enabled] [-b block_exploits] [-w allow_websocket_upgrade] [-a advanced_config] [-t token_expiry] [--create-user username password email] [--delete-user username] [--delete-host id] [--list-hosts] [--list-hosts-full] [--list-ssl-certificates] [--list-users] [--search-host hostname] [--enable-host id] [--disable-host id] [--check-token] [--backup] [--generate-cert domain email [--custom]] [--ssl-host-enable id] [--ssl-host-disable id] [--show-host id] [--show-default] [--help]${COLOR_RESET}" echo -e "\n${COLOR_YELLOW}Usage: ./nginx_proxy_manager_cli.sh -d domain -i ip -p port [-f forward_scheme] [-c caching_enabled] [-b block_exploits] [-w allow_websocket_upgrade] [-a advanced_config] [-t token_expiry] [--host-create-user username password email] [--host-delete-user username] [--host-delete id] [--host-list] [--host-list-full] [--host-list-ssl-certificates] [--host-list-users] [--host-search hostname] [--host-enable id] [--host-disable id] [--host-check-token] [--host-backup] [--host-backup-id id] [--host-restore] [--host-restore-id id] [--host-generate-cert domain email [--custom]] [--host-ssl-enable id] [--host-ssl-disable id] [--host-show id] [--host-show-default] [--host-help]${COLOR_RESET}"
echo "" echo ""
echo -e "Examples:" echo -e "Examples:"
echo -e "\n 📦 Backup First before doing anything!" echo -e "\n 📦 Backup First before doing anything!"
echo -e " ./nginx_proxy_manager_cli.sh --backup" echo -e " ./nginx_proxy_manager_cli.sh --host-backup"
echo -e " ./nginx_proxy_manager_cli.sh --host-backup-id 1"
echo -e " ./nginx_proxy_manager_cli.sh --host-restore"
echo -e " ./nginx_proxy_manager_cli.sh --host-restore-id 1"
echo -e "\n 🌐 Host Creation" echo -e "\n 🌐 Host Creation"
echo -e " ./nginx_proxy_manager_cli.sh --show-default" echo -e " ./nginx_proxy_manager_cli.sh --host-show-default"
echo -e " ./nginx_proxy_manager_cli.sh -d example.com -i 192.168.1.10 -p 8080" echo -e " ./nginx_proxy_manager_cli.sh -d example.com -i 192.168.1.10 -p 8080"
echo -e " ./nginx_proxy_manager_cli.sh --list-hosts" echo -e " ./nginx_proxy_manager_cli.sh --host-list"
echo -e " ./nginx_proxy_manager_cli.sh --show-host 1" echo -e " ./nginx_proxy_manager_cli.sh --host-show 1"
echo -e "\n 👤 User Management" echo -e "\n 👤 User Management"
echo -e " ./nginx_proxy_manager_cli.sh --create-user newuser password123 user@example.com" echo -e " ./nginx_proxy_manager_cli.sh --host-create-user newuser password123 user@example.com"
echo -e " ./nginx_proxy_manager_cli.sh --delete-user 'username'" echo -e " ./nginx_proxy_manager_cli.sh --host-delete-user 'username'"
echo -e "\n 🔧 Advanced Example:" echo -e "\n 🔧 Advanced Example:"
echo -e " ./nginx_proxy_manager_cli.sh -d example.com -i 192.168.1.10 -p 8080 -a 'proxy_set_header X-Real-IP \$remote_addr; proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;'" echo -e " ./nginx_proxy_manager_cli.sh -d example.com -i 192.168.1.10 -p 8080 -a 'proxy_set_header X-Real-IP \$remote_addr; proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;'"
echo -e " ./nginx_proxy_manager_cli.sh --ssl-host-enable 32" echo -e " ./nginx_proxy_manager_cli.sh --host-ssl-enable 32"
echo -e " ./nginx_proxy_manager_cli.sh --generate-cert example.com user@example.com --custom" echo -e " ./nginx_proxy_manager_cli.sh --host-generate-cert example.com user@example.com --custom"
echo -e "" echo -e ""
echo -e "Options:" echo -e "Options:"
echo -e " -d ${COLOR_ORANGE}DOMAIN_NAMES${COLOR_RESET} Domain name (${COLOR_RED}required${COLOR_RESET})" echo -e " -d ${COLOR_ORANGE}DOMAIN_NAMES${COLOR_RESET} Domain name (${COLOR_RED}required${COLOR_RESET})"
@ -164,28 +178,33 @@ usage() {
echo -e " -b BLOCK_EXPLOITS Block exploits (true/false, default: $(colorize_boolean $BLOCK_EXPLOITS))" echo -e " -b BLOCK_EXPLOITS Block exploits (true/false, default: $(colorize_boolean $BLOCK_EXPLOITS))"
echo -e " -w ALLOW_WEBSOCKET_UPGRADE Allow WebSocket upgrade (true/false, default: $(colorize_boolean $ALLOW_WEBSOCKET_UPGRADE))" echo -e " -w ALLOW_WEBSOCKET_UPGRADE Allow WebSocket upgrade (true/false, default: $(colorize_boolean $ALLOW_WEBSOCKET_UPGRADE))"
echo -e " -a ADVANCED_CONFIG Advanced configuration (${COLOR_YELLOW}string${COLOR_RESET})" echo -e " -a ADVANCED_CONFIG Advanced configuration (${COLOR_YELLOW}string${COLOR_RESET})"
echo -e " --backup ${COLOR_GREEN}Backup${COLOR_RESET} all configurations to a differnts files in $BACKUP_DIR" echo ""
echo -e " --check-token ${COLOR_YELLOW}Check${COLOR_RESET} if the current token is valid" echo -e " --host-backup 📦 ${COLOR_GREEN}Backup${COLOR_RESET} All configurations to a different files in $BACKUP_DIR"
echo -e " --create-user user pass email ${COLOR_GREEN}Create${COLOR_RESET} a user with a ${COLOR_YELLOW}username, ${COLOR_YELLOW}password${COLOR_RESET} and ${COLOR_YELLOW}email${COLOR_RESET}" echo -e " --host-backup-id id 📦 ${COLOR_GREEN}Backup${COLOR_RESET} Single host configuration and its certificate (if exists)"
echo -e " --delete-user username ${COLOR_ORANGE}Delete${COLOR_RESET} a user by ${COLOR_YELLOW}username${COLOR_RESET}" echo -e " --host-restore 📦 ${COLOR_GREEN}Restore${COLOR_RESET} All configurations from a backup file"
echo -e " --delete-host id ${COLOR_ORANGE}Delete${COLOR_RESET} a proxy host by ${COLOR_YELLOW}ID${COLOR_RESET}" echo -e " --host-restore-id id 📦 ${COLOR_GREEN}Restore${COLOR_RESET} Single host configuration and its certificate (if exists)"
echo -e " --show-default ${COLOR_YELLOW}Show${COLOR_RESET} default settings for creating hosts" echo -e " --host-check-token 🔧 ${COLOR_YELLOW}Check${COLOR_RESET} If the current token is valid"
echo -e " --show-host id ${COLOR_YELLOW}Show${COLOR_RESET} full details for a specific host by ${COLOR_YELLOW}ID${COLOR_RESET}" echo -e " --host-create-user user pass email 👤 ${COLOR_GREEN}Create${COLOR_RESET} User with a ${COLOR_YELLOW}username, ${COLOR_YELLOW}password${COLOR_RESET} and ${COLOR_YELLOW}email${COLOR_RESET}"
echo -e " --list-hosts ${COLOR_YELLOW}List${COLOR_RESET} the names of all proxy hosts" echo -e " --host-delete-user username 💣 ${COLOR_ORANGE}Delete${COLOR_RESET} User by ${COLOR_YELLOW}username${COLOR_RESET}"
echo -e " --list-hosts-full ${COLOR_YELLOW}List${COLOR_RESET} all proxy hosts with full details" echo -e " --host-delete id 💣 ${COLOR_ORANGE}Delete${COLOR_RESET} Proxy host by ${COLOR_YELLOW}ID${COLOR_RESET}"
echo -e " --list-ssl-certificates ${COLOR_YELLOW}List${COLOR_RESET} all SSL certificates" echo -e " --host-search hostname 🔍 ${COLOR_GREEN}Search${COLOR_RESET} Proxy host by domain name"
echo -e " --list-users ${COLOR_YELLOW}List${COLOR_RESET} all users" echo -e " --host-show-default 🔍 ${COLOR_YELLOW}Show${COLOR_RESET} Default settings for creating hosts"
echo -e " --search-host hostname ${COLOR_GREEN}Search${COLOR_RESET} for a proxy host by domain name" echo -e " --host-show id 🔍 ${COLOR_YELLOW}Show${COLOR_RESET} Full details for a specific host by ${COLOR_YELLOW}ID${COLOR_RESET}"
echo -e " --enable-host id ${COLOR_GREEN}Enable${COLOR_RESET} a proxy host by ${COLOR_YELLOW}ID${COLOR_RESET}" echo -e " --host-list 📋 ${COLOR_YELLOW}List${COLOR_RESET} Names of all proxy hosts"
echo -e " --disable-host id ${COLOR_ORANGE}Disable${COLOR_RESET} a proxy host by ${COLOR_YELLOW}ID${COLOR_RESET}" echo -e " --host-list-full 📋 ${COLOR_YELLOW}List${COLOR_RESET} All Proxy hosts with full details"
echo -e " --ssl-host-enable id ${COLOR_GREEN}Enable${COLOR_RESET} SSL, HTTP/2, and HSTS for a proxy host ( Will generate Certificat auto if needed )" echo -e " --host-list-ssl-certificates 📋 ${COLOR_YELLOW}List${COLOR_RESET} All SSL certificates"
echo -e " --ssl-host-disable id ${COLOR_ORANGE}Disable${COLOR_RESET} SSL, HTTP/2, and HSTS for a proxy host" echo -e " --host-list-users 📋 ${COLOR_YELLOW}List${COLOR_RESET} All Users"
echo -e " --generate-cert domain email [--custom] Generate a Let's Encrypt [or] Custom certificate for the given domain and email ( don't use not finish )" echo -e " --host-enable id ✅ ${COLOR_GREEN}Enable${COLOR_RESET} Proxy host by ${COLOR_YELLOW}ID${COLOR_RESET}"
echo -e " --help ${COLOR_YELLOW}Display${COLOR_RESET} this help" echo -e " --host-disable id ❌ ${COLOR_ORANGE}Disable${COLOR_RESET} Proxy host by ${COLOR_YELLOW}ID${COLOR_RESET}"
echo echo -e " --host-ssl-enable id 🔒 ${COLOR_GREEN}Enable${COLOR_RESET} SSL, HTTP/2, and HSTS for a proxy host (Will generate Certificat auto if needed)"
echo -e " --host-ssl-disable id 🔓 ${COLOR_ORANGE}Disable${COLOR_RESET} SSL, HTTP/2, and HSTS for a proxy host"
echo -e " --host-generate-cert domain email [--custom] 🛡️ ${COLOR_GREEN}Generate${COLOR_RESET} Custom certificate for the given domain and email (not finished yet)"
echo -e " --host-help ${COLOR_YELLOW}Display${COLOR_RESET} This help"
echo ""
exit 0 exit 0
} }
# Colorize boolean values for display # Colorize boolean values for display
colorize_boolean() { colorize_boolean() {
local value=$1 local value=$1
@ -194,8 +213,8 @@ colorize_boolean() {
else else
echo -e "${COLOR_YELLOW}false${COLOR_RESET}" echo -e "${COLOR_YELLOW}false${COLOR_RESET}"
fi fi
} }
colorize_booleanh() { colorize_booleanh() {
local value=$1 local value=$1
if [ "$value" = https ]; then if [ "$value" = https ]; then
@ -203,7 +222,6 @@ colorize_booleanh() {
else else
echo -e "${COLOR_YELLOW}http${COLOR_RESET}" echo -e "${COLOR_YELLOW}http${COLOR_RESET}"
fi fi
} }
# Parse options # Parse options
@ -219,57 +237,68 @@ while getopts "d:i:p:f:c:b:w:a:t:-:" opt; do
a) ADVANCED_CONFIG="$OPTARG" ;; a) ADVANCED_CONFIG="$OPTARG" ;;
-) -)
case "${OPTARG}" in case "${OPTARG}" in
help) usage ;; host-help) usage ;;
create-user) host-backup-id)
BACKUP_HOST=true
HOST_ID="${!OPTIND}"; shift
;;
host-backup) BACKUP=true ;;
host-restore)
RESTORE=true
;;
host-restore-id)
RESTORE_HOST=true
HOST_ID="${!OPTIND}"; shift
;;
host-create-user)
CREATE_USER=true CREATE_USER=true
USERNAME="${!OPTIND}"; shift USERNAME="${!OPTIND}"; shift
PASSWORD="${!OPTIND}"; shift PASSWORD="${!OPTIND}"; shift
EMAIL="${!OPTIND}"; shift EMAIL="${!OPTIND}"; shift
;; ;;
delete-user) host-delete-user)
DELETE_USER=true DELETE_USER=true
USERNAME="${!OPTIND}"; shift USERNAME="${!OPTIND}"; shift
;; ;;
delete-host) host-delete)
DELETE_HOST=true DELETE_HOST=true
HOST_ID="${!OPTIND}"; shift HOST_ID="${!OPTIND}"; shift
;; ;;
list-hosts) LIST_HOSTS=true ;; host-list) LIST_HOSTS=true ;;
list-hosts-full) LIST_HOSTS_FULL=true ;; host-list-full) LIST_HOSTS_FULL=true ;;
list-ssl-certificates) LIST_SSL_CERTIFICATES=true ;; host-list-ssl-certificates) LIST_SSL_CERTIFICATES=true ;;
list-users) LIST_USERS=true ;; host-list-users) LIST_USERS=true ;;
search-host) host-search)
SEARCH_HOST=true SEARCH_HOST=true
SEARCH_HOSTNAME="${!OPTIND}"; shift SEARCH_HOSTNAME="${!OPTIND}"; shift
;; ;;
enable-host) host-enable)
ENABLE_HOST=true ENABLE_HOST=true
HOST_ID="${!OPTIND}"; shift HOST_ID="${!OPTIND}"; shift
;; ;;
disable-host) host-disable)
DISABLE_HOST=true DISABLE_HOST=true
HOST_ID="${!OPTIND}"; shift HOST_ID="${!OPTIND}"; shift
;; ;;
check-token) CHECK_TOKEN=true ;; host-check-token) CHECK_TOKEN=true ;;
backup) BACKUP=true ;; host-generate-cert)
generate-cert)
GENERATE_CERT=true GENERATE_CERT=true
DOMAIN="${!OPTIND}"; shift DOMAIN="${!OPTIND}"; shift
EMAIL="${!OPTIND}"; shift EMAIL="${!OPTIND}"; shift
;; ;;
custom) CUSTOM_CERT=true ;; custom) CUSTOM_CERT=true ;;
ssl-host-enable) host-ssl-enable)
ENABLE_SSL=true ENABLE_SSL=true
HOST_ID="${!OPTIND}"; shift HOST_ID="${!OPTIND}"; shift
;; ;;
ssl-host-disable) host-ssl-disable)
DISABLE_SSL=true DISABLE_SSL=true
HOST_ID="${!OPTIND}"; shift HOST_ID="${!OPTIND}"; shift
;; ;;
show-default) host-show-default)
SHOW_DEFAULT=true SHOW_DEFAULT=true
;; ;;
show-host) host-show)
SHOW_HOST=true SHOW_HOST=true
HOST_ID="${!OPTIND}"; shift HOST_ID="${!OPTIND}"; shift
;; ;;
@ -343,7 +372,7 @@ validate_token() {
} }
# Ensure Nginx access and token validity before proceeding # Ensure Nginx access and token validity before proceeding
if [[ ! "$1" =~ --help ]]; then if [[ ! "$1" =~ --host-help ]]; then
check_nginx_access check_nginx_access
if ! validate_token; then if ! validate_token; then
@ -353,6 +382,111 @@ if [[ ! "$1" =~ --help ]]; then
fi fi
# Function to backup a single host configuration and its certificate (if exists)
backup_single_host() {
if [ -z "$HOST_ID" ]; then
echo " 📦 The --host-backup-id option requires a host ID."
usage
fi
mkdir -p "$BACKUP_DIR"
# Backup proxy host
RESPONSE=$(curl -s -X GET "$BASE_URL/nginx/proxy-hosts/$HOST_ID" \
-H "Authorization: Bearer $(cat $TOKEN_FILE)")
echo "$RESPONSE" | jq '.' > "$BACKUP_DIR/proxy_host_+${HOST_ID}_${NGINX_IP//./_}_$DATE.json"
# Backup SSL certificate if it exists
CERTIFICATE_ID=$(echo "$RESPONSE" | jq -r '.certificate_id')
if [ "$CERTIFICATE_ID" != "null" ]; then
RESPONSE=$(curl -s -X GET "$BASE_URL/nginx/certificates/$CERTIFICATE_ID" \
-H "Authorization: Bearer $(cat $TOKEN_FILE)")
echo "$RESPONSE" | jq '.' > "$BACKUP_DIR/ssl_certificate_+${CERTIFICATE_ID}_${NGINX_IP//./_}_$DATE.json"
fi
echo -e "${COLOR_GREEN}Backup for host ID $HOST_ID completed successfully in 📂 '$BACKUP_DIR' ${COLOR_RESET}\n"
}
# Function to restore configurations from a backup file
restore_backup() {
echo " 📦 Restoring backup from '$BACKUP_DIR'..."
# Restore proxy hosts
RESPONSE=$(cat "$BACKUP_DIR/proxy_hosts_${NGINX_IP//./_}_$DATE.json")
echo "$RESPONSE" | jq -c '.[]' | while read -r proxy; do
curl -s -X POST "$BASE_URL/nginx/proxy-hosts" \
-H "Authorization: Bearer $(cat $TOKEN_FILE)" \
-H "Content-Type: application/json; charset=UTF-8" \
--data-raw "$proxy"
done
# Restore users
RESPONSE=$(cat "$BACKUP_DIR/users_${NGINX_IP//./_}_$DATE.json")
echo "$RESPONSE" | jq -c '.[]' | while read -r user; do
curl -s -X POST "$BASE_URL/users" \
-H "Authorization: Bearer $(cat $TOKEN_FILE)" \
-H "Content-Type: application/json; charset=UTF-8" \
--data-raw "$user"
done
# Restore SSL certificates
RESPONSE=$(cat "$BACKUP_DIR/ssl_certificates_${NGINX_IP//./_}_$DATE.json")
echo "$RESPONSE" | jq -c '.[]' | while read -r cert; do
curl -s -X POST "$BASE_URL/nginx/certificates" \
-H "Authorization: Bearer $(cat $TOKEN_FILE)" \
-H "Content-Type: application/json; charset=UTF-8" \
--data-raw "$cert"
done
# Restore access lists
RESPONSE=$(cat "$BACKUP_DIR/access_lists_${NGINX_IP//./_}_$DATE.json")
echo "$RESPONSE" | jq -c '.[]' | while read -r list; do
curl -s -X POST "$BASE_URL/nginx/access-lists" \
-H "Authorization: Bearer $(cat $TOKEN_FILE)" \
-H "Content-Type: application/json; charset=UTF-8" \
--data-raw "$list"
done
# Restore settings
RESPONSE=$(cat "$BACKUP_DIR/settings_${NGINX_IP//./_}_$DATE.json")
curl -s -X POST "$BASE_URL/nginx/settings" \
-H "Authorization: Bearer $(cat $TOKEN_FILE)" \
-H "Content-Type: application/json; charset=UTF-8" \
--data-raw "$RESPONSE"
echo -e "${COLOR_GREEN}Restore completed successfully from 📂 '$BACKUP_DIR' ${COLOR_RESET}"
}
# Function to restore a single host configuration and its certificate (if exists)
restore_single_host() {
if [ -z "$HOST_ID" ]; then
echo " 🩹 The --host-restore-id option requires a host ID."
usage
fi
echo " 🩹 Restoring backup for host ID $HOST_ID from '$BACKUP_DIR'..."
# Restore proxy host
RESPONSE=$(cat "$BACKUP_DIR/proxy_host_${HOST_ID}_${NGINX_IP//./_}_$DATE.json")
curl -s -X POST "$BASE_URL/nginx/proxy-hosts" \
-H "Authorization: Bearer $(cat $TOKEN_FILE)" \
-H "Content-Type: application/json; charset=UTF-8" \
--data-raw "$RESPONSE"
# Restore SSL certificate if it exists
if [ -f "$BACKUP_DIR/ssl_certificate_${CERTIFICATE_ID}_${NGINX_IP//./_}_$DATE.json" ]; then
RESPONSE=$(cat "$BACKUP_DIR/ssl_certificate_${CERTIFICATE_ID}_${NGINX_IP//./_}_$DATE.json")
curl -s -X POST "$BASE_URL/nginx/certificates" \
-H "Authorization: Bearer $(cat $TOKEN_FILE)" \
-H "Content-Type: application/json; charset=UTF-8" \
--data-raw "$RESPONSE"
fi
echo -e "${COLOR_GREEN}Restore for host ID $HOST_ID completed successfully from 📂 '$BACKUP_DIR' ${COLOR_RESET}"
}
# Check if a proxy host with the given domain names already exists # Check if a proxy host with the given domain names already exists
check_existing_proxy_host() { check_existing_proxy_host() {
RESPONSE=$(curl -s -X GET "$BASE_URL/nginx/proxy-hosts" \ RESPONSE=$(curl -s -X GET "$BASE_URL/nginx/proxy-hosts" \
@ -361,7 +495,7 @@ check_existing_proxy_host() {
if [ -n "$EXISTING_HOST" ]; then if [ -n "$EXISTING_HOST" ]; then
echo -e "\n 🔔 Proxy host for $DOMAIN_NAMES already exists.${COLOR_GREEN}" echo -e "\n 🔔 Proxy host for $DOMAIN_NAMES already exists.${COLOR_GREEN}"
read -p " Do you want to update it with the new configuration? (y/n): " -r read -p " 👉 Do you want to update it with the new configuration? (y/n): " -r
if [[ $REPLY =~ ^[Yy]$ ]]; then if [[ $REPLY =~ ^[Yy]$ ]]; then
HOST_ID=$(echo "$EXISTING_HOST" | jq -r '.id') HOST_ID=$(echo "$EXISTING_HOST" | jq -r '.id')
update_proxy_host "$HOST_ID" update_proxy_host "$HOST_ID"
@ -377,7 +511,7 @@ check_existing_proxy_host() {
# Update an existing proxy host # Update an existing proxy host
update_proxy_host() { update_proxy_host() {
HOST_ID=$1 HOST_ID=$1
echo -e "\n Updating proxy host for $DOMAIN_NAMES..." echo -e "\n 🌀 Updating proxy host for $DOMAIN_NAMES..."
ADVANCED_CONFIG_ESCAPED=$(printf '%s' "$ADVANCED_CONFIG" | sed ':a;N;$!ba;s/\n/\\n/g' | sed 's/"/\\"/g') ADVANCED_CONFIG_ESCAPED=$(printf '%s' "$ADVANCED_CONFIG" | sed ':a;N;$!ba;s/\n/\\n/g' | sed 's/"/\\"/g')
@ -425,7 +559,7 @@ update_proxy_host() {
# Create a new proxy host # Create a new proxy host
create_new_proxy_host() { create_new_proxy_host() {
echo "Creating proxy host for $DOMAIN_NAMES..." echo -e "\n 🌍 Creating proxy host for $DOMAIN_NAMES..."
DATA='{ DATA='{
"domain_names": ["'"$DOMAIN_NAMES"'"], "domain_names": ["'"$DOMAIN_NAMES"'"],
"forward_host": "'"$FORWARD_HOST"'", "forward_host": "'"$FORWARD_HOST"'",
@ -460,7 +594,7 @@ create_new_proxy_host() {
# Create or update a proxy host based on the existence of the domain # Create or update a proxy host based on the existence of the domain
create_or_update_proxy_host() { create_or_update_proxy_host() {
if [ -z "$DOMAIN_NAMES" ] || [ -z "$FORWARD_HOST" ] || [ -z "$FORWARD_PORT" ]; then if [ -z "$DOMAIN_NAMES" ] || [ -z "$FORWARD_HOST" ] || [ -z "$FORWARD_PORT" ]; then
echo " The -d, -i, and -p options are required to create or update a proxy host." echo -e "\n 🌍 The -d, -i, and -p options are required to create or update a proxy host."
usage usage
fi fi
@ -470,7 +604,7 @@ create_or_update_proxy_host() {
# Delete a proxy host by ID # Delete a proxy host by ID
delete_proxy_host() { delete_proxy_host() {
if [ -z "$HOST_ID" ]; then if [ -z "$HOST_ID" ]; then
echo " The --delete-host option requires a host ID." echo -e "\n 💣 The --host-delete option requires a host ID."
usage usage
fi fi
echo " Deleting proxy host ID: $HOST_ID..." echo " Deleting proxy host ID: $HOST_ID..."
@ -481,7 +615,7 @@ delete_proxy_host() {
if echo "$RESPONSE" | jq -e .error > /dev/null 2>&1; then if echo "$RESPONSE" | jq -e .error > /dev/null 2>&1; then
echo -e "${COLOR_RED}Failed to delete proxy host. Error: $(echo "$RESPONSE" | jq -r '.message')${COLOR_RESET}" echo -e "${COLOR_RED}Failed to delete proxy host. Error: $(echo "$RESPONSE" | jq -r '.message')${COLOR_RESET}"
else else
echo -e "${COLOR_GREEN}Proxy host deleted successfully!${COLOR_RESET}" echo -e "${COLOR_GREEN}Proxy host 💣 deleted successfully!${COLOR_RESET}"
fi fi
} }
@ -523,26 +657,7 @@ list_proxy_hosts() {
printf " ${COLOR_YELLOW}%6s${COLOR_RESET} ${COLOR_GREEN}%-36s${COLOR_RESET} %-8s %-4s\n" \ printf " ${COLOR_YELLOW}%6s${COLOR_RESET} ${COLOR_GREEN}%-36s${COLOR_RESET} %-8s %-4s\n" \
"$(pad "$id" 6)" "$(pad "$domain" 36)" "$status" "$ssl_status" "$(pad "$id" 6)" "$(pad "$domain" 36)" "$status" "$ssl_status"
done done
} echo ""
# List all proxy hosts with basic details
list_proxy_hosts_() {
echo -e "\n${COLOR_ORANGE} 👉 List of proxy hosts (simple)${COLOR_RESET}"
RESPONSE=$(curl -s -X GET "$BASE_URL/nginx/proxy-hosts" \
-H "Authorization: Bearer $(cat $TOKEN_FILE)")
echo "$RESPONSE" | jq -r '.[] | "\(.id) \(.domain_names | join(", ")) \(.enabled)"' | while read -r id domain enabled; do
if [ "$enabled" -eq 1 ]; then
status="[${WHITE_ON_GREEN}enabled${COLOR_RESET}]"
else
status="[${COLOR_RED}disabled${COLOR_RESET}]"
fi
printf " id: ${COLOR_YELLOW}%-4s${COLOR_RESET} ${COLOR_GREEN}%-20s${COLOR_RESET} %b\n" "$id" "$domain" "$status"
done
} }
# List all proxy hosts with full details # List all proxy hosts with full details
@ -554,28 +669,16 @@ list_proxy_hosts_full() {
echo "$RESPONSE" | jq -c '.[]' | while read -r proxy; do echo "$RESPONSE" | jq -c '.[]' | while read -r proxy; do
echo "$proxy" | jq . echo "$proxy" | jq .
done done
} echo ""
# Show full details for a specific host by ID
show_host() {
if [ -z "$HOST_ID" ]; then
echo " The --show-host option requires a host ID."
usage
fi
echo -e "\n${COLOR_ORANGE} 👉 Full details for proxy host ID: $HOST_ID...${COLOR_RESET}\n"
RESPONSE=$(curl -s -X GET "$BASE_URL/nginx/proxy-hosts/$HOST_ID" \
-H "Authorization: Bearer $(cat $TOKEN_FILE)")
echo "$RESPONSE" | jq .
} }
# Search for a proxy host by domain name # Search for a proxy host by domain name
search_proxy_host() { search_proxy_host() {
if [ -z "$SEARCH_HOSTNAME" ]; then if [ -z "$SEARCH_HOSTNAME" ]; then
echo " The --search-host option requires a domain name." echo " 🔍 The --host-search option requires a domain name."
usage usage
fi fi
echo -e "\nSearching for proxy host for $SEARCH_HOSTNAME..." echo -e "\n 🔍 Searching for proxy host for $SEARCH_HOSTNAME..."
RESPONSE=$(curl -s -X GET "$BASE_URL/nginx/proxy-hosts" \ RESPONSE=$(curl -s -X GET "$BASE_URL/nginx/proxy-hosts" \
-H "Authorization: Bearer $(cat $TOKEN_FILE)") -H "Authorization: Bearer $(cat $TOKEN_FILE)")
@ -583,7 +686,7 @@ search_proxy_host() {
id=$(echo "$line" | jq -r '.id') id=$(echo "$line" | jq -r '.id')
domain_names=$(echo "$line" | jq -r '.domain_names[]') domain_names=$(echo "$line" | jq -r '.domain_names[]')
echo -e " id: ${COLOR_YELLOW}$id${COLOR_RESET} ${COLOR_GREEN}$domain_names${COLOR_RESET}" echo -e " 🔎 id: ${COLOR_YELLOW}$id${COLOR_RESET} ${COLOR_GREEN}$domain_names${COLOR_RESET}\n"
done done
} }
@ -603,14 +706,13 @@ list_users() {
echo "$RESPONSE" | jq echo "$RESPONSE" | jq
} }
# Create a new user # Create a new user
create_user() { create_user() {
if [ -z "$USERNAME" ] || [ -z "$PASSWORD" ] || [ -z "$EMAIL" ]; then if [ -z "$USERNAME" ] || [ -z "$PASSWORD" ] || [ -z "$EMAIL" ]; then
echo " The username, password, and email parameters are required to create a user." echo " 👤 The username, password, and email parameters are required to create a user."
usage usage
fi fi
echo " Creating user $USERNAME..." echo " 👤 Creating user $USERNAME..."
DATA=$(jq -n --arg username "$USERNAME" --arg password "$PASSWORD" --arg email "$EMAIL" --arg name "$USERNAME" --arg nickname "$USERNAME" --arg secret "$PASSWORD" '{ DATA=$(jq -n --arg username "$USERNAME" --arg password "$PASSWORD" --arg email "$EMAIL" --arg name "$USERNAME" --arg nickname "$USERNAME" --arg secret "$PASSWORD" '{
name: $name, name: $name,
@ -635,20 +737,20 @@ create_user() {
HTTP_STATUS=$(echo "$HTTP_RESPONSE" | tr -d '\n' | sed -e 's/.*HTTPSTATUS://') HTTP_STATUS=$(echo "$HTTP_RESPONSE" | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')
if [ "$HTTP_STATUS" -eq 201 ]; then if [ "$HTTP_STATUS" -eq 201 ]; then
echo -e "${COLOR_GREEN}User created successfully!${COLOR_RESET}" echo -e "${COLOR_GREEN}User created successfully!${COLOR_RESET}\n"
else else
echo "Data sent: $DATA" # Log the data sent echo "Data sent: $DATA" # Log the data sent
echo -e "${COLOR_RED}Failed to create user. HTTP status: $HTTP_STATUS. Response: $HTTP_BODY${COLOR_RESET}" echo -e "${COLOR_RED}Failed to create user. HTTP status: $HTTP_STATUS. Response: $HTTP_BODY${COLOR_RESET}\n"
fi fi
} }
# Delete a user by username # Delete a user by username
delete_user() { delete_user() {
if [ -z "$USERNAME" ]; then if [ -z "$USERNAME" ]; then
echo " The --delete-user option requires a username." echo " 🗑️ The --host-delete-user option requires a 👤 username."
usage usage
fi fi
echo " Deleting user $USERNAME..." echo " 🗑️ Deleting user 👤 $USERNAME..."
# Fetch the user ID based on the username # Fetch the user ID based on the username
USER_ID=$(curl -s -X GET "$BASE_URL/users" \ USER_ID=$(curl -s -X GET "$BASE_URL/users" \
@ -662,22 +764,22 @@ delete_user() {
HTTP_STATUS=$(echo "$HTTP_RESPONSE" | tr -d '\n' | sed -e 's/.*HTTPSTATUS://') HTTP_STATUS=$(echo "$HTTP_RESPONSE" | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')
if [ "$HTTP_STATUS" -eq 200 ]; then if [ "$HTTP_STATUS" -eq 200 ]; then
echo -e "${COLOR_GREEN}User deleted successfully!${COLOR_RESET}" echo -e "${COLOR_GREEN}User deleted successfully!${COLOR_RESET}\n"
else else
echo -e "${COLOR_RED}Failed to delete user. HTTP status: $HTTP_STATUS. Response: $HTTP_BODY${COLOR_RESET}" echo -e "${COLOR_RED}Failed to delete user. HTTP status: $HTTP_STATUS. Response: $HTTP_BODY${COLOR_RESET}\n"
fi fi
else else
echo -e " ${COLOR_RED}User not found: $USERNAME${COLOR_RESET}" echo -e " ${COLOR_RED}User not found: $USERNAME${COLOR_RESET}\n"
fi fi
} }
# Enable a proxy host by ID # Enable a proxy host by ID
enable_proxy_host() { enable_proxy_host() {
if [ -z "$HOST_ID" ]; then if [ -z "$HOST_ID" ]; then
echo " The --enable-host option requires a host ID." echo -e "\n 💣 The --host-enable option requires a host ID."
usage usage
fi fi
echo " Enabling proxy host ID: $HOST_ID..." echo -e "\n ✅ Enabling 🌐 proxy host ID: $HOST_ID..."
# Check if the proxy host exists before enabling # Check if the proxy host exists before enabling
CHECK_RESPONSE=$(curl -s -X GET "$BASE_URL/nginx/proxy-hosts/$HOST_ID" \ CHECK_RESPONSE=$(curl -s -X GET "$BASE_URL/nginx/proxy-hosts/$HOST_ID" \
@ -697,22 +799,22 @@ enable_proxy_host() {
HTTP_STATUS=$(echo "$HTTP_RESPONSE" | tr -d '\n' | sed -e 's/.*HTTPSTATUS://') HTTP_STATUS=$(echo "$HTTP_RESPONSE" | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')
if [ "$HTTP_STATUS" -eq 200]; then if [ "$HTTP_STATUS" -eq 200]; then
echo -e "${COLOR_GREEN}Proxy host enabled successfully!${COLOR_RESET}" echo -e "${COLOR_GREEN}Proxy host enabled successfully!${COLOR_RESET}\n"
else else
echo -e "${COLOR_RED}Failed to enable proxy host. HTTP status: $HTTP_STATUS. Response: $HTTP_BODY${COLOR_RESET}" echo -e "${COLOR_RED}Failed to enable proxy host. HTTP status: $HTTP_STATUS. Response: $HTTP_BODY${COLOR_RESET}\n"
fi fi
else else
echo -e "${COLOR_RED}Proxy host with ID $HOST_ID does not exist.${COLOR_RESET}" echo -e "${COLOR_RED}Proxy host with ID $HOST_ID does not exist.${COLOR_RESET}\n"
fi fi
} }
# Disable a proxy host by ID # Disable a proxy host by ID
disable_proxy_host() { disable_proxy_host() {
if [ -z "$HOST_ID" ]; then if [ -z "$HOST_ID" ]; then
echo " The --disable-host option requires a host ID." echo -e "\n ❌ The --host-disable option requires a host ID."
usage usage
fi fi
echo " Disabling proxy host ID: $HOST_ID..." echo -e "\n ❌ Disabling 🌐 proxy host ID: $HOST_ID..."
# Check if the proxy host exists before disabling # Check if the proxy host exists before disabling
CHECK_RESPONSE=$(curl -s -X GET "$BASE_URL/nginx/proxy-hosts/$HOST_ID" \ CHECK_RESPONSE=$(curl -s -X GET "$BASE_URL/nginx/proxy-hosts/$HOST_ID" \
@ -732,19 +834,19 @@ disable_proxy_host() {
HTTP_STATUS=$(echo "$HTTP_RESPONSE" | tr -d '\n' | sed -e 's/.*HTTPSTATUS://') HTTP_STATUS=$(echo "$HTTP_RESPONSE" | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')
if [ "$HTTP_STATUS" -eq 200]; then if [ "$HTTP_STATUS" -eq 200]; then
echo -e "${COLOR_GREEN}Proxy host disabled successfully!${COLOR_RESET}" echo -e "${COLOR_GREEN}Proxy host disabled successfully!${COLOR_RESET}\n"
else else
echo -e "${COLOR_RED}Failed to disable proxy host. HTTP status: $HTTP_STATUS. Response: $HTTP_BODY${COLOR_RESET}" echo -e "${COLOR_RED}Failed to disable proxy host. HTTP status: $HTTP_STATUS. Response: $HTTP_BODY${COLOR_RESET}\n"
fi fi
else else
echo -e "${COLOR_RED}Proxy host with ID $HOST_ID does not exist.${COLOR_RESET}" echo -e "${COLOR_RED}Proxy host with ID $HOST_ID does not exist.${COLOR_RESET}\n"
fi fi
} }
# Generate Let's Encrypt certificate if not exists # Generate Let's Encrypt certificate if not exists
generate_certificate() { generate_certificate() {
if [ -z "$DOMAIN" ] || [ -z "$EMAIL" ]; then if [ -z "$DOMAIN" ] || [ -z "$EMAIL" ]; then
echo -e "\n 🛡️ The --generate-cert option requires a domain and email." echo -e "\n 🛡️ The --host-generate-cert option requires a domain and email."
usage usage
fi fi
echo -e "\n 👀 Checking if Let's Encrypt certificate for domain: $DOMAIN exists..." echo -e "\n 👀 Checking if Let's Encrypt certificate for domain: $DOMAIN exists..."
@ -782,21 +884,20 @@ generate_certificate() {
HTTP_STATUS=$(echo "$HTTP_RESPONSE" | tr -d '\n' | sed -e 's/.*HTTPSTATUS://') HTTP_STATUS=$(echo "$HTTP_RESPONSE" | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')
if [ "$HTTP_STATUS" -eq 201]; then if [ "$HTTP_STATUS" -eq 201]; then
echo -e "${COLOR_GREEN}Certificate generated successfully!${COLOR_RESET}" echo -e "${COLOR_GREEN}Certificate generated successfully!${COLOR_RESET}\n"
else else
echo " Data sent: $DATA" # Log the data sent echo " Data sent: $DATA" # Log the data sent
echo -e "${COLOR_RED}Failed to generate certificate. HTTP status: $HTTP_STATUS. Response: $HTTP_BODY${COLOR_RESET}" echo -e "${COLOR_RED}Failed to generate certificate. HTTP status: $HTTP_STATUS. Response: $HTTP_BODY${COLOR_RESET}\n"
fi fi
} }
# enable_ssl function # enable_ssl function
enable_ssl() { enable_ssl() {
if [ -z "$HOST_ID" ]; then if [ -z "$HOST_ID" ]; then
echo -e "\n 🛡️ The --ssl-host-enable option requires a host ID." echo -e "\n 🛡️ The --host-ssl-enable option requires a host ID."
usage usage
fi fi
echo -e "\n ✅ Enabling SSL, HTTP/2, and HSTS for proxy host ID: $HOST_ID..." echo -e "\n ✅ Enabling 🔒 SSL, HTTP/2, and HSTS for proxy host ID: $HOST_ID..."
# Check host details # Check host details
CHECK_RESPONSE=$(curl -s -X GET "$BASE_URL/nginx/proxy-hosts/$HOST_ID" \ CHECK_RESPONSE=$(curl -s -X GET "$BASE_URL/nginx/proxy-hosts/$HOST_ID" \
@ -847,15 +948,13 @@ enable_ssl() {
fi fi
} }
# Function to disable SSL for a proxy host # Function to disable SSL for a proxy host
disable_ssl() { disable_ssl() {
if [ -z "$HOST_ID" ]; then if [ -z "$HOST_ID" ]; then
echo -e "\n 🛡️ The --ssl-host-disable option requires a host ID." echo -e "\n 🛡️ The --host-ssl-disable option requires a host ID."
usage usage
fi fi
echo -e "\n 🚫 Disabling SSL for proxy host ID: $HOST_ID..." echo -e "\n 🚫 Disabling 🔓 SSL for proxy host ID: $HOST_ID..."
CHECK_RESPONSE=$(curl -s -X GET "$BASE_URL/nginx/proxy-hosts/$HOST_ID" \ CHECK_RESPONSE=$(curl -s -X GET "$BASE_URL/nginx/proxy-hosts/$HOST_ID" \
-H "Authorization: Bearer $(cat $TOKEN_FILE)") -H "Authorization: Bearer $(cat $TOKEN_FILE)")
@ -895,7 +994,7 @@ disable_ssl() {
# Function to show full details for a specific host by ID # Function to show full details for a specific host by ID
show_host() { show_host() {
if [ -z "$HOST_ID" ]; then if [ -z "$HOST_ID" ]; then
echo -e "\n ⛔ The --show-host option requires a host ID." echo -e "\n ⛔ The --host-show option requires a host ID."
usage usage
fi fi
echo -e "\n${COLOR_ORANGE} 👉 Full details for proxy host ID: $HOST_ID...${COLOR_RESET}\n" echo -e "\n${COLOR_ORANGE} 👉 Full details for proxy host ID: $HOST_ID...${COLOR_RESET}\n"
@ -903,6 +1002,7 @@ show_host() {
-H "Authorization: Bearer $(cat $TOKEN_FILE)") -H "Authorization: Bearer $(cat $TOKEN_FILE)")
echo "$RESPONSE" | jq . echo "$RESPONSE" | jq .
echo ""
} }
# Display default settings for creating hosts # Display default settings for creating hosts
@ -954,6 +1054,7 @@ full_backup() {
echo -e "${COLOR_GREEN}Full backup completed successfully in 📂 '$BACKUP_DIR' ${COLOR_RESET}" echo -e "${COLOR_GREEN}Full backup completed successfully in 📂 '$BACKUP_DIR' ${COLOR_RESET}"
} }
# Main logic # Main logic
if [ "$CREATE_USER" = true ]; then if [ "$CREATE_USER" = true ]; then
create_user create_user
@ -981,6 +1082,12 @@ elif [ "$CHECK_TOKEN" = true ]; then
validate_token validate_token
elif [ "$BACKUP" = true ]; then elif [ "$BACKUP" = true ]; then
full_backup full_backup
elif [ "$BACKUP_HOST" = true ]; then
backup_single_host
elif [ "$RESTORE" = true ]; then
restore_backup
elif [ "$RESTORE_HOST" = true]; then
restore_single_host
elif [ "$GENERATE_CERT" = true ]; then elif [ "$GENERATE_CERT" = true ]; then
generate_certificate generate_certificate
elif [ "$ENABLE_SSL" = true]; then elif [ "$ENABLE_SSL" = true]; then