update remote updater
This commit is contained in:
parent
cccc81172f
commit
aab99cccc1
|
@ -1,5 +1,7 @@
|
||||||
# Bash Scripts collection
|
# Bash Scripts collection
|
||||||
|
|
||||||
|
wget -O init_scripts.sh https://git.studi7.com/roger/bashscripts/raw/branch/master/init_scripts.sh && chmod +x init_scripts.sh && ./init_scripts.sh
|
||||||
|
|
||||||
## gotifypush.sh
|
## gotifypush.sh
|
||||||
|
|
||||||
Send markdown notifications to gotify channel throught curl
|
Send markdown notifications to gotify channel throught curl
|
||||||
|
|
|
@ -49,7 +49,7 @@ fi
|
||||||
#echo $func_result
|
#echo $func_result
|
||||||
#set +f
|
#set +f
|
||||||
|
|
||||||
echo "/////////////////////////////////////"
|
echo "/////////////////////////////////////////"
|
||||||
echo "Benvingut a l'instalador d'Scripts"
|
echo "Benvingut a l'instalador d'Scripts"
|
||||||
echo -e "/////////////////////////////////////\n"
|
echo -e "/////////////////////////////////////\n"
|
||||||
|
|
||||||
|
|
|
@ -6,5 +6,72 @@ if [[ $EUID -ne 0 ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cat .ssh/config | grep -E "^Host [^\*\*]" | sed "s/Host //"
|
readonly OFFSET_OPTIONS=3
|
||||||
|
declare -a TARGETS
|
||||||
|
|
||||||
|
show_ssh_hosts () {
|
||||||
|
SSH_HOSTS_CONFIG_FILE="/root/.ssh/config"
|
||||||
|
|
||||||
|
if [ -f $SSH_HOSTS_CONFIG_FILE ]; then
|
||||||
|
TARGETS=($(cat $SSH_HOSTS_CONFIG_FILE | grep -E "^Host [^\*\*]" | sed "s/Host //"))
|
||||||
|
# get length of an array
|
||||||
|
length=${#TARGETS[@]}
|
||||||
|
for (( j=0; j<length; j++ ));
|
||||||
|
do
|
||||||
|
#printf "Current index %d with value %s\n" $j "${TARGETS[$j]}"
|
||||||
|
echo "$((j+$OFFSET_OPTIONS))) ${TARGETS[$j]}"
|
||||||
|
done
|
||||||
|
else
|
||||||
|
echo "NOTE: Config hosts file not found"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
#for i in "${targets[@]}"
|
||||||
|
#do
|
||||||
|
# :
|
||||||
|
# do whatever on "$i" here
|
||||||
|
# echo $i
|
||||||
|
|
||||||
|
|
||||||
|
echo "###################################"
|
||||||
|
echo "Auto Remote Updater"
|
||||||
|
echo -e "###################################\n"
|
||||||
|
|
||||||
|
finished=false
|
||||||
|
while [ "$finished" != "true" ]
|
||||||
|
do
|
||||||
|
|
||||||
|
# Choose script to install
|
||||||
|
echo "0) Sortir de l'script"
|
||||||
|
echo "1) current host: $(hostname)"
|
||||||
|
echo "2) custom host"
|
||||||
|
show_ssh_hosts
|
||||||
|
#echo -e "\n"
|
||||||
|
|
||||||
|
choosed=false
|
||||||
|
while [ "$choosed" != "true" ]
|
||||||
|
do
|
||||||
|
read -p 'Indica quin host vols actualitzar (0 per sortir): ' HOST
|
||||||
|
case $HOST in
|
||||||
|
("") echo "El número no pot ser buit";;
|
||||||
|
(*[!0-9]*) echo "Has d'introduir un número";;
|
||||||
|
(*) choosed=true #echo "just numeric";;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$HOST" = "0" ]; then
|
||||||
|
finished=true
|
||||||
|
exit 0
|
||||||
|
elif [ "$HOST" = "1" ]; then
|
||||||
|
echo -e "update now!\n"
|
||||||
|
elif [ "$HOST" = "2" ]; then
|
||||||
|
read -p 'Indica el host remot: ' CUSTOM
|
||||||
|
echo $CUSTOM
|
||||||
|
elif [ "$((HOST-OFFSET_OPTIONS))" -gt 7 ]; then
|
||||||
|
echo -e "Aquest número de host no existeix. Tornar a intentar-ho\n"
|
||||||
|
else
|
||||||
|
index=$((HOST-OFFSET_OPTIONS))
|
||||||
|
echo "${TARGETS[$index]}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
done
|
||||||
|
|
Loading…
Reference in New Issue