Search

Ver.2

#!/bin/bash leo_hostname=`cut -f 2 -d '-' /etc/hostname`; leo_ip=`hostname -I | grep -e ^1 | awk '{print $1}'`; agx1_ip=`ip addr show | grep usb | grep inet | awk '{print $2}' | cut -c 1-12 | head -1` agx2_ip=`ip addr show | grep usb | grep inet | awk '{print $2}' | cut -c 1-12 | head -2 | tail -1`; password='alooh1234'; declare -A leo_info=([leo_hostname]=${leo_hostname} [leo_ip]=${leo_ip}); function info_writer(){ for i in ${!leo_info[@]} do echo ${i}=${leo_info[${i}]} done } info_writer > leo_info.txt echo ${password} | sudo -S apt install sshpass sshpass -p ${password} scp leo_info.txt setconfig.py alooh@${agx1_ip}:/home/alooh/ sshpass -p ${password} scp leo_info.txt setconfig.py alooh@${agx2_ip}:/home/alooh/ #원격명령 #net_ip : from leo-info #net_mask : from leo-info #sshpass -p ${password} ssh alooh@${agx1_ip} "sudo /sbin/ifconfig l4tbr0 ${net_ip1} netmask ${net_mask1}" #sshpass -p ${password} ssh alooh@${agx1_ip} "sudo /sbin/ifconfig l4tbr0 ${net_ip2} netmask ${net_mask2}" #sshpass -p ${password} ssh alooh@${agx2_ip} "python3 ~/Projects/safety-fence/setconfig.py" # update net_ip #sshpass -p alooh1234 ssh alooh@192.168.55.1 "sed -i 's/192.168.55/192.168.56/g' testip.txt"
Bash