Disabled default zelli
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
function fish_prompt --description Hydro
|
||||
echo -e "$_hydro_color_start$hydro_symbol_start$hydro_color_normal$_hydro_color_pwd$_hydro_pwd$hydro_color_normal $_hydro_color_git$$_hydro_git$hydro_color_normal$_hydro_color_duration$_hydro_cmd_duration$hydro_color_normal$_hydro_status$hydro_color_normal "
|
||||
end
|
||||
@@ -0,0 +1,62 @@
|
||||
|
||||
function mysql-reverse --description "Crea un tunnel SSH reverse per connettersi a MySQL" --argument-names ssh_host mysql_host password local_port
|
||||
# Verifica che tutti gli argomenti siano forniti
|
||||
if test (count $argv) -lt 3
|
||||
echo "Uso: mysql-reverse <ssh_host> <mysql_host> <password> [local_port]"
|
||||
echo ""
|
||||
echo "Argomenti:"
|
||||
echo " ssh_host - Host SSH per il tunnel (es: user@ssh.example.com)"
|
||||
echo " mysql_host - Host MySQL di destinazione (es: mysql1.example.com)"
|
||||
echo " password - Password per MySQL"
|
||||
echo " local_port - Porta locale per il tunnel (default: 3307)"
|
||||
return 1
|
||||
end
|
||||
|
||||
# Imposta la porta locale di default se non specificata
|
||||
set -l local_port $argv[4]
|
||||
if test -z "$local_port"
|
||||
set local_port 3307
|
||||
end
|
||||
|
||||
# Cerca una porta libera nel range di 10 porte
|
||||
set -l max_attempts 10
|
||||
set -l port_found 0
|
||||
set -l attempted_port $local_port
|
||||
|
||||
for i in (seq 0 (math $max_attempts - 1))
|
||||
set attempted_port (math $local_port + $i)
|
||||
|
||||
# Verifica se la porta è occupata usando netstat o ss
|
||||
if command -v ss >/dev/null
|
||||
ss -tuln | grep -q ":$attempted_port "
|
||||
set port_in_use $status
|
||||
else if command -v netstat >/dev/null
|
||||
netstat -tuln | grep -q ":$attempted_port "
|
||||
set port_in_use $status
|
||||
else
|
||||
# Se non ci sono strumenti disponibili, prova direttamente
|
||||
set port_in_use 1
|
||||
end
|
||||
|
||||
if test $port_in_use -ne 0
|
||||
# Porta libera trovata
|
||||
set port_found 1
|
||||
set local_port $attempted_port
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if test $port_found -eq 0
|
||||
echo "Errore: nessuna porta libera trovata"
|
||||
return 1
|
||||
end
|
||||
|
||||
echo "Usando porta locale: $local_port"
|
||||
|
||||
# Crea il tunnel SSH in background
|
||||
ssh -f $ssh_host -L $local_port:$mysql_host:3306 -N
|
||||
|
||||
# Connetti a MySQL attraverso il tunnel
|
||||
mysql -h 127.0.0.1 -P $local_port -p$password
|
||||
echo "Mysql reverse proxy on port $local_port"
|
||||
end
|
||||
Reference in New Issue
Block a user