adding
This commit is contained in:
+42
-1
@@ -1,19 +1,60 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
install_dependencies() {
|
install_dependencies() {
|
||||||
curl=$(which curl)
|
curl=$(which curl)
|
||||||
wget=$(which wget)
|
wget=$(which wget)
|
||||||
ssh=$(which ssh)
|
ssh=$(which ssh)
|
||||||
if [[ -z $curl || -z $wget ]]; then
|
if [[ -z $curl || -z $wget || -z $ssh ]]; then
|
||||||
echo "Instalando dependencias faltantes"
|
echo "Instalando dependencias faltantes"
|
||||||
|
apt-get update -y
|
||||||
|
apt-get install wget ssh curl -y
|
||||||
else
|
else
|
||||||
echo "Todas las dependencias encontradas"
|
echo "Todas las dependencias encontradas"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
install_cloudflared() {
|
||||||
|
echo "Instalando cloudflared para linux"
|
||||||
|
wget https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64
|
||||||
|
mv cloudflared-linux-amd64 cloudflared && chmod +x cloudflared
|
||||||
|
mv cloudflared /usr/local/bin
|
||||||
|
}
|
||||||
|
|
||||||
|
create_ssh_config(){
|
||||||
|
ssh_config_path="/home/$USER/.ssh"
|
||||||
|
if [[ -d ssh_config_path ]]; then
|
||||||
|
echo "Carpeta .ssh encontrada, la configuracion ssh se sobreescribira, seguro que quieres continuar? "
|
||||||
|
read "[y]es or [n]o" opc
|
||||||
|
case opc in
|
||||||
|
y)
|
||||||
|
echo -e "Host ssh1.karimlpg.net\nProxyCommand /usr/local/bin/cloudflared access ssh --hostname %h" >> $ssh_config_path/config
|
||||||
|
echo "Terminando configuracion"
|
||||||
|
;;
|
||||||
|
n)
|
||||||
|
echo "Terminando Programa"
|
||||||
|
exit 1 ;;
|
||||||
|
*)
|
||||||
|
echo "Valor no reconocido, saliendo del programa..."
|
||||||
|
exit 1 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
else
|
||||||
|
echo "Creando carpeta .ssh y configuracion"
|
||||||
|
mkdir -p /home/$USER/.ssh && echo -e "Host ssh1.karimlpg.net\nProxyCommand /usr/local/bin/cloudflared access ssh --hostname %h" >> $ssh_config_path/config
|
||||||
|
echo "Terminando configuracion"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
|
if [[ $UID != 0 ]]; then
|
||||||
|
echo "Necesitas usar sudo para ejecutar el script"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
install_dependencies
|
install_dependencies
|
||||||
|
install_cloudflared
|
||||||
|
create_ssh_config
|
||||||
}
|
}
|
||||||
|
|
||||||
main
|
main
|
||||||
|
|||||||
Reference in New Issue
Block a user