уже)Spike писал(а):напиши
(если на момент старта нет сети, синхронизация тупит до перезапуска сервиса),
grep -v «MobilePartner.sh» /etc/sudoers >/tmp/${TEMPFILE} 2>&1
DELETECOMMENT=«delete requiretty for hw_mobile»
REQUIRETTY=`grep "${DELETECOMMENT}" /tmp/${TEMPFILE}`
if [ «x${REQUIRETTY}» != «x» ]
then
REQUIRETTY=`echo "${REQUIRETTY}" | awk -F ',' '{printf $2}'`
else
REQUIRETTY=`grep «requiretty» /tmp/${TEMPFILE}`
if [ «x${REQUIRETTY}» != «x» ]
then
sed -i «s/${REQUIRETTY}/# ,${REQUIRETTY},${DELETECOMMENT}/g» /tmp/${TEMPFILE} 2>/dev/null
fi
fi# Shashank: Defect fix AJ2D13470: Begin
echo -e «ALL ALL=(ALL) NOPASSWD:ALL» >> /tmp/${TEMPFILE}
Spike писал(а):Вы бы уже скрипты что ли выложили и инструкцию как их использовать, раз рекламируете свой метод..
#!/usr/bin/perl
use Socket;
#SRV FILE TRANSPORT v1.1
my $securepath='/home/point/'; #разрешаем обмен тока с этой директорией
sub GetDate
{
($MIN, $HOUR, $DAY, $MONTH, $YEAR) = (localtime)[1,2,3,4,5];
$timename=($YEAR+1900).'-'.($MONTH+1).'-'.$DAY.' '.$HOUR.':'.$MIN;
return $timename;
}
$SIG{CHLD} = \&REAPER;
sub REAPER {
while ((my $waitedpid = waitpid(-1,&WNOHANG)) > 0) { print "kill zombie\n" }
$SIG{CHLD} = \&REAPER;
}
sub push_client($)
{
$pid=shift;
$kidpids{$pid}=time();
}
sub kill_clients
{
our %kidpids;
our $max_time_client;
my $t=time();
foreach $pid (keys %kidpids) {
print STDOUT $pid.":".($t - $kidpids{$pid}).";";
if (($t - $kidpids{$pid})>$max_time_client) {
print STDOUT "kill client $pid\n";
kill(15,$kidpids{$pid});
delete $kidpids{$pid};
}
}
print STDOUT "\n";
}
%kidpids=();
$max_time_client=300; # максимальное время конекта
$R_SIZE=4096;
$MyPort=3332; #порт сервера
socket(Server,PF_INET,SOCK_STREAM,getprotobyname("tcp"));
setsockopt(Server,SOL_SOCKET,SO_REUSEADDR,1); # для быстрого перезапуска
$myaddr = sockaddr_in($MyPort,INADDR_ANY);
bind(Server,$myaddr) or die "невозможно стать сервером на этом порту";
listen(Server,SOMAXCONN) or die "невозможно слушать порт";
$SIG{CHLD} = 'IGNORE';
$COUNT=0;
`echo $$ > srv_ft.pid`;
while (accept(Client,Server)){
$other_end=getpeername(Client) or print STDOUT "невозможно идентифицировать клиента";
($port,$iaddr) = unpack_sockaddr_in($other_end);
$ip = inet_ntoa($iaddr);
$claimed_hostname = gethostbyaddr($iaddr,AF_INET);
++$COUNT;
$curdate=GetDate();
print "$curdate: client :$COUNT: $ip\n";
if ($kidpid = fork) {
kill_clients();
push_client($kidpid);
close (Client);
next;
}
# дочерний процесс
defined ($kidpid) or die "no fork!!!";
close (Server);
select(Client); # нулевые значения
$|=1; # автовыгрузка буффера
$input = <Client>;chomp($input);
print STDOUT "m:$input\n";
if ($input eq ''){last;}
my @data=split(";",$input);
%hd=();
foreach $i (@data) { $i=~/^(.*?)=(.*?)$/; $hd{$1}=$2; print STDOUT "$1=$2 \n";}
binmode(Client);
if ($hd{'cmd'} eq 'put'){
print STDOUT "put ".$hd{'file'}."\n";
if (!open(RFILE,">",$hd{'file'})){print "cant create this file [".$hd{'file'}."]\n";close Client;exit;}
binmode(RFILE);
while( ($size=read(Client,$data,$R_SIZE))!=0 ) {
print RFILE $data;
#print STDOUT ".";
}
close(RFILE);
}
if ($hd{'cmd'} eq 'get')
{
print STDOUT "get ".$hd{'file'}."\n";
if (($hd{'file'}!~/$securepath/)or($hd{'file'}=~/\.\./)) {print STDOUT "warning!!! access denied!\n";}
else { #READ
if (!open(RFILE,"<",$hd{'file'})){print "cant open this file [".$hd{'file'}."]\n";close Client;exit;}
binmode(RFILE);
while( ($size=read(RFILE,$data,$R_SIZE))!=0 ) {
print Client $data;
print STDOUT ".";
}
close(RFILE);
} # END READ
}
close Client;
print STDOUT "close client number:$COUNT\n";
exit;
}
close(Server);
print "close server\n";
#!/usr/bin/perl
use Socket;
our $R_SIZE=4096;
sub readsets($){
$pathset=shift;
our $pswd,$ipserver,$skport;
open(FS,"<",$pathset);
while (<FS>) {
if (/^ipserver=(.*?)$/){$ipserver=$1;}
if (/^skport=(.*?)$/){$skport=$1;}
if (/^pswd=(.*?)$/){$pswd=$1;}
}
close(FS);
}
sub skopen(){
our $skopen=0;
$RemoteHost = $ipserver;
$RemotePort = $skport;
socket(Server,PF_INET,SOCK_STREAM,getprotobyname("tcp"));
if (! ($internet_addr = inet_aton($RemoteHost))) {print "not found skserver\n";return 0;}
$paddr = sockaddr_in($RemotePort,$internet_addr);
if (! (connect ( Server, $paddr))) { print "error connect socket\n";return 0;}
select ((select(Server),$|=1)[0]);
$skopen=1;
return 1;
}
sub get($$){
my $file=shift;
my $to=shift;
our $R_SIZE;
$head="cmd=get;file=$file\n";
if ($skopen){
if (!open(RFILE,">",$to)){print "cant create this file [".$to."]\n";return 0;exit;}
print Server $head;
binmode(RFILE);
binmode(Server);
while( ($size=read(Server,$data,$R_SIZE))!=0 ) {
print RFILE $data;
print STDOUT ".";
}
print STDOUT "get.ok.\n";
close(RFILE);
}
return 1;
}
sub put($$){
my $file=shift;
my $to=shift;
our $R_SIZE;
$head="cmd=put;file=$to\n";
if ($skopen){
if (!open(RFILE,"<",$file)){print "cant open this file [".$file."]\n";return 0;exit;}
print Server $head;
binmode(RFILE);
binmode(Server);
while( ($size=read(RFILE,$data,$R_SIZE))!=0 ) {
print Server $data;
print STDOUT ".";
}
print STDOUT "put.ok.\n";
close(RFILE);
}
return 1;
}
sub skclose(){
if ($skopen){
close (Server);
shutdown (Server,1);
}
}
readsets('.client_ft');
skopen();
print "open socket $ipserver:$skport\n";
if ($ARGV[0] eq 'get') {
get($ARGV[1],$ARGV[2]);
}
if ($ARGV[0] eq 'put') {
put($ARGV[1],$ARGV[2]);
}
print "close socket\n";
skclose();
ipserver=xxx.xxx.xxx.xxx
skport=3332
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 12