#!/usr/bin/perl -w
# This script is intended to make packing file for fidogate from existing
# passwords fidogate file.
# May be useful for others but NO WARRANTY.
# License: GNU.
# Tested only w/ my configs. May work wrong w/ yours!
# (c) Olli (olli@digger.org.NOSPAMru,remove NOSPAM before mailing)
# greetz: i_L, Corvin, Vika
# Thanx : Peter V. Chernikoff (peter@digger.org.NOSPAMru,remove NOSPAM before mailing)
# for help in moving my node to Linux. =)
# I'd like to see email feedback - mail me if you use this.
$fg_dir="/usr/local/ftn";
$fg_etc="$fg_dir/etc";
$fg_lib="$fg_dir/lib";
$fg_passwd="$fg_etc/passwd";
$outdir="/tmp/fidogate";
$pack_file="$outdir/packing";
# arhivers: paths
$zip="/usr/bin/zip";
$rar="/usr/bin/rar";
# gate programme optinons
$gate_opts="-i -x";
# Default packer
$packer="rar";  # I don't use diffrent packers for links. :P
$mark="uplink"; # mark existing for each link in $fg_passwd .
local(@links);
############### proggie goes:
system `mkdir $outdir 2>/dev/null`;
open( PACKF, ">$pack_file" ) || die "Can't write to $pack_file: $!.\n";
open( FGPAS, "<$fg_passwd" ) || die "Can't read $fg_passwd: $!.\n";
print "Fidogate packing file will be in $pack_file\n";
print "\n\t\t\t.USE WITH CARE.\n\n";
print PACKF "\# Generated by make_packing.pl by Olli\n";
print PACKF "\# USE WITH CARE. \n";
print PACKF "arc\t\tzip\t\t\"$zip -9gkjq \%s \%s\"\n";
print PACKF "arc\t\trar\t\"$rar a -ep -ep1 -s -m5 -inull -cfg- -w/tmp \%s \%s\"\n\n";
print PACKF "prog\t\tgate\t\"$fg_lib/ftn2rfc $gate_opts $fg_lib/ftninpost -l \%s\"\n";
print PACKF "progn\t\tgate\t\"$fg_lib/ftn2rfc \%s\"\n\n";
print PACKF "EchoMail\n";
while(<FGPAS>) 
{
next if (/^\#/);
next if (/^\n/);
next unless (/$mark/);
chomp;
tr/\r//;
if (/^$mark\s+(\S+)/)
{push(@links,$1);}
} # EOF <FGPAS>
foreach $link (@links)
{print PACKF "pack\t\t$packer\t\t$link\n";
}
print PACKF "\#Other\n";
print PACKF "pack\t\trar\t\t*\n";
print PACKF "NetMail\n\n";
print PACKF "pack noar\n";
close(FGPAS);
close(PACKF);
exit;
