#!/bin/bash


### global variables ###


date=`date +%Y%m%d`

file="$2"

file_str=`echo "$2" | wc -c`

dir_input=`find /root/shell/ -name "$file" |grep $1 | awk '{print substr($1, 1, length($1) - '$file_str')}'`


echo "$dir_input"


### start funcion ### 


notice () {


clear


cat << __EOF__


[2014-09-26 TH] Server sctipts Update shell 


Notice : $0 [ api | en | upload | -> coming soon ...add server] updata_file


Not Exec scritps


__EOF__


}


api='/root/shell/admin/serverlist/api_server_list'

en='/root/shell/admin/serverlist/en_server_list'

upload='/root/shell/admin/serverlist/upload_server_list'


server_file="$1"


file_update () {


while read server_ip server_dir ;

do


# scripts update

        rsync -a -e ssh $dir_input/$file root@$server_ip:$server_dir

        echo "$server_ip $server_dir update ok"


done < /root/shell/admin/serverlist/$server_file\_server_list


}



### Main ###


file_input=`ls -l $dir_input | grep $file | awk '{print $9}'`


echo "$0 $1 $2"


if [ "$file" == "$file_input" ]; then

# start update shell scripts 

        case "$1" in

                api)

                        file_update

                        ;;

                en)

                        file_update

                        ;;

                upload)

                        file_update

                        ;;

                *)

                        notice

                        exit

        esac

else

        echo "File is not Found, Checking update file"

        notice

fi

'IT Study > script' 카테고리의 다른 글

nfs를 이용한 간단한 백업 스크립트  (0) 2016.02.19
tomcat 프로세스 재구동 스크립트  (0) 2016.02.19
check storage  (0) 2016.02.19
perl ssh 원격 명령 스크립트  (0) 2014.10.21
ssh원격 접속 명령  (0) 2014.10.21

#!/usr/bin/perl


my($host, $username, $password);

$host="서버IP";

$username="root";

#$password="";



use strict;

use Net::SSH::Perl;


my @KEYFILE = ("/root/.ssh/id_rsa");

my $ssh = Net::SSH::Perl->new($host, debug=>0, identity_files=>\@KEYFILE);

$ssh->login($username);


my($local_dir, $local_filename, $remote_dir, $remote_filename);

#$remote_dir = "/home/ruis";

#$remote_filename = "passwd";

$local_dir = "/root/perl";

$local_filename = "_httpd";


open FILE, "> $local_dir/$local_filename";

open FILE1, "> $local_dir/_uptime";


#print FILE ($ssh->cmd("cat $remote_dir/$remote_filename"))[0];

#print FILE ($ssh->cmd("cat /etc/sysconfig/network-scripts/ifcfg-eth0"))[0];

print FILE ($ssh->cmd("pstree"))[0];

print FILE1 ($ssh->cmd("uptime"))[0];


#$ssh->cmd("");


#### Perl ssh 원격접속 Test 파일 

#### 해당 파일을 기본골격으로 여러가지 원격 명령 Perl 파일이 생성가능


### Last version 20141021 ###


'IT Study > script' 카테고리의 다른 글

nfs를 이용한 간단한 백업 스크립트  (0) 2016.02.19
tomcat 프로세스 재구동 스크립트  (0) 2016.02.19
check storage  (0) 2016.02.19
서버 스크립트 자동 배포  (0) 2014.10.21
ssh원격 접속 명령  (0) 2014.10.21

+ Recent posts