Skip to content

Instantly share code, notes, and snippets.

@renizgo
Last active August 3, 2017 23:44
Show Gist options
  • Save renizgo/4c39eb19e5dad6c39b2ab51e6e1348c9 to your computer and use it in GitHub Desktop.
Save renizgo/4c39eb19e5dad6c39b2ab51e6e1348c9 to your computer and use it in GitHub Desktop.
Adiciona linha em .bash_profile em servidores remotos.
#!/bin/bash
## bash.sh - Copia a linha contida no arquivo bash.txt no bash_profile do usuário definido na variavel de ambiente USER,
## em todos os servers do documento lista.txt.
## Obs: um servidor por linha
## Escrito por: Renato Diniz Marigo
## E-mail: renatocabelo@gmail.com
## Data: 03/08/2017
echo "#####################################"
echo "# Adicionando linha em bash_profile #"
echo "#####################################"
USER="renato.diniz"
for SERVER in $(cat lista.txt)
do
scp bash.txt $USER@$SERVER:/home/$USER/
ssh $USER@$SERVER << COMANDOS
cat bash.txt >> .bash_profile
rm bash.txt
COMANDOS
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment