LibrePortal/scripts/cli/commands/ip/cli_ip_commands.sh
librelad 875a60f90f LibrePortal v0.1.0 — initial release
A free, open, self-hosted app platform (GNU AGPLv3): one-click app deploys,
Traefik reverse proxy with automatic SSL, rootless Docker support, gluetun
VPN routing, and a web dashboard to manage it all.

Free & open forever to self-host; optional paid hosted services fund it.
See PROMISE.md.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

Signed-off-by: librelad <librelad@digitalangels.vip>
2026-05-21 20:37:54 +01:00

116 lines
3.0 KiB
Bash
Executable File

#!/bin/bash
# IP Commands Handler
# Handles all IP subcommands by calling core functions
cliHandleIPCommands()
{
local command="$initial_command2"
local param1="$initial_command3"
local param2="$initial_command4"
if [[ -z "$command" ]]; then
cliShowIPHelp
fi
case "$command" in
"scan")
if [[ -z "$param1" ]]; then
isNotice "Scan type required."
cliShowIPHelp
else
scanIPs "$param1" "$param2"
fi
;;
"allocate")
if [[ -z "$param1" ]]; then
isQuestion "Enter app name to allocate IP: "
read -r app_name
else
app_name="$param1"
fi
if [[ -z "$param2" ]]; then
isQuestion "Enter IP to allocate: "
read -r ip_address
else
ip_address="$param2"
fi
allocateIP "$app_name" "$ip_address"
;;
"release")
if [[ -z "$param1" ]]; then
isQuestion "Enter app name to release IP: "
read -r app_name
else
app_name="$param1"
fi
releaseIP "$app_name"
;;
"status")
initializeIPAllocation
if [[ -n "$param1" ]]; then
local ip=$(getAppIP "$param1")
if [[ -n "$ip" ]]; then
isSuccessful "$param1 has IP: $ip"
else
isNotice "$param1 has no IP allocated"
fi
else
showIPAllocationStatus
fi
;;
"conflicts")
initializeIPAllocation
case "$param1" in
"detect")
detectIPConflicts
;;
"resolve")
resolveIPConflicts
;;
*)
echo "Usage: libreportal ip conflicts [detect|resolve]"
;;
esac
;;
"update-tags")
if [[ -z "$param1" ]]; then
isNotice "App name required."
cliShowIPHelp
else
updateIPAddressTags "$param1"
fi
;;
"validate")
if [[ -z "$param1" ]]; then
isNotice "App name required."
cliShowIPHelp
else
validateIPTags "$param1"
fi
;;
"report")
if [[ -z "$param1" ]]; then
isNotice "Report file required."
cliShowIPHelp
else
generateIPReport "$param1"
fi
;;
*)
isNotice "Invalid IP command: $command"
cliShowIPHelp
;;
esac
}