cmdref.net - Cheat Sheet and Example

cmdref.net is command references/cheat sheets/examples for system engineers.

User Tools

Site Tools


Sidebar








Cloud



Etc


Reference














.

programming:shell:deploy.html



Shell Script Cheat Sheet

Shell - Deploy

one server

#!/bin/sh
#./test.sh test1 192.168.0.1

command=$1
host=$2

test1 () {
    echo "$host test1"
    #ssh -n ${host} hostname
}

test2 () {
    echo "$host test2"
    #ssh -n ${host} hostname
}

${command}

./test.sh test1 192.168.0.1

multiple server

#!/bin/sh
#./test2.sh test1 host.lst

command=$1
hostlist=$2


test1 () {
    echo "$host test1"
    #ssh -n ${host} hostname
}

test2 () {
    echo "$host test2"
    #ssh -n ${host} hostname
}

for host in `cat ./${hostlist}`
do
    ${command}
done

# cat host.lst
192.168.0.1
192.168.0.2
# ./test2.sh test1 host.lst
192.168.0.1 test1
192.168.0.2 test1
#


ssh memo

ssh -n 192.168.0.10  sudo "bash -c 'sed s/192.168.100.10/192.168.50.10/g /etc/hosts > /etc/hosts.20121111' "
ssh -n 192.168.0.10 "sudo su - -c '/tmp/tmp.sh >> /tmp/2013052.txt && diff /tmp/20130501.txt /tmp/20130502.txt'"
ssh -t 127.0.0.1 sudo /etc/init.d/httpd restart




programming/shell/deploy.html.txt ยท Last modified: 2021/03/18 by admin

Page Tools