2005/08/19(金) [n年前の日記]
#2 [vine][linux] まだ残ってる作業
namazu for hns の設定とか。hnsローカルミラーシステムの設定とか。
◎ namazu for hns の設定 :
_2004/05/17
、
_2004/05/18
あたりにも設定してたらしい。
念のため、インデックスを再作成。
ユーザのcrontabを設定。
ちなみに、crontab -e で編集されるファイルは、/var/spool/cron/ 以下にあるらしい。 _cron の設定ガイド というページが参考になりそう。メモ。
念のため、インデックスを再作成。
$ cd ~/diary/bin/ $ ./hns-index2 clean
ユーザのcrontabを設定。
$ crontab -eと打って、以下を追加。
30 5 * * * /bin/sh /home/ユーザ名/diary/bin/hns-index2
ちなみに、crontab -e で編集されるファイルは、/var/spool/cron/ 以下にあるらしい。 _cron の設定ガイド というページが参考になりそう。メモ。
◎ hnsローカルミラーシステムの設定 :
_2004/11/02
に設定してた。
必要なパッケージをインストール。
~/diary/bin/hns_linkarc.pl を実行すれば取得してくれるのか。crontab で設定。
一応念のため、自分の hns_linkarc.pl を晒しておこう…。追加したところは、
必要なパッケージをインストール。
# apt-get install perl-libwww-perl
~/diary/bin/hns_linkarc.pl を実行すれば取得してくれるのか。crontab で設定。
$ crontab -e
25 7 * * * /home/ユーザ名/diary/bin/hns_linkarc.pl…以前の設定ファイルと同じにしたけど。もしかして、
25 7 * * * /bin/sh /home/ユーザ名/diary/bin/hns_linkarc.plのほうがいいのだろうか?
一応念のため、自分の hns_linkarc.pl を晒しておこう…。追加したところは、
- mkdir でロック処理を入れた。
- ファイルが既に存在するときは新たに取得しない条件分岐を入れた。
- 既に存在してるファイルを表示するかしないかの条件分岐を入れた。
#!/usr/bin/perl
# Last updated: <2005/02/14 05:23:04 +0900>
#==============================================================================
# hns_linkarc.pl hnsファイルに現われるURLをアーカイブ
# $Id: hns_linkarc.pl,v 1.1.1.1 2003/09/17 14:25:40 kei Exp $
#==============================================================================
use strict;
use File::Find;
use LWP::Simple;
my $beskip = 0; # 0 = file exist not check / 1 = file exist check
my $benotdisp = 0; # 0 = exist file disp / 1 = exist file not disp
my $HNF_DIR = '/home/USERNAME/diary/';
my $ARCHIVE_DIR = '/home/USERNAME/public_html/archive';
my $LOCK_DIR = '/home/USERNAME/diary/log/hns_linkarc_lock';
my @EXCEPT_URL = (
'http://blawat2015.no-ip.com/',
'http://members.jcom.home.ne.jp/',
'http://www.google.com/search',
'http://2ch.ohayou.com/2ch.html',
'http://airmail.sakura.ne.jp/~komugi/gimp/bbs/treebbs.cgi',
'http://app.memorize.ne.jp/d/28/66930/2003/08/11',
'http://classical.ddo.jp/island/windows/program/autoping.html',
'http://east.portland.ne.jp/~sigekazu/css/ascii.htm',
'http://relax.dip.jp/archives/000160.php',
'http://sip.jtd.jp/top.html',
'http://vespa.cla.kagoshima-u.ac.jp/yakimono/other-lik/kanntou/MASIKO.HTM',
'http://www.ben-kyo.com/orca/tip.html',
'http://www.ingjapan.ne.jp/hori/',
'http://www.me.ics.saitama-u.ac.jp/~hira/emacs/howm/index-j.html',
'http://www.ohayou.com/2ch/main/',
'http://www.post1.com/home/hiyori13/friday.html',
'http://www.protoformproject.com/dvd/drawings/domocon.GIF',
'http://www2.halex.co.jp/yohoushi/co_edu1000/1_201091.htm',
'http://www.me.ics.saitama-u.ac.jp/~hira/emacs/howm/index-j.html',
'http://www.jsdlab.co.jp/~kei/xyzzy/xyzzy2.html',
'http://ash.or.jp/code/ctrltbl.htm',
'http://homepage2.nifty.com/m_kamada/di200501.htm',
);
my ($LastCheck, $Now, %Rlink);
my $retry = 5;
while (!mkdir($LOCK_DIR, 0755)) {
if (--$retry <= 0) {
print "BUSY\n";
exit(0);
}
sleep(1);
}
&main();
rmdir($LOCK_DIR);
exit(0);
sub main {
my (@stat, $last);
my ($lastfile);
$lastfile = "$ARCHIVE_DIR/.last_check";
if (! open(FILE, $lastfile)) {
$last = 0;
}
else {
$last = <FILE>;
chomp($last);
close(FILE);
}
$LastCheck = $last;
$Now = time();
open(FILE, "$HNF_DIR/conf/rlink.txt");
while(<FILE>) {
chomp;
if (/^([^\s]+)\s+(.+)$/) {
$Rlink{$1} = $2;
}
}
close(FILE);
find(\&hnf_check, $HNF_DIR);
open(FILE, "> $lastfile");
print FILE "$Now\n";
close(FILE);
}
sub hnf_check {
my (@stat, $last, $file);
my ($file);
$file = $_;
if ($file =~ /^d[0-9]+\.hnf$/) {
@stat = stat($file);
if ($stat[9] >= $LastCheck) {
hns_scan("$file");
}
}
}
sub hns_scan($) {
my ($file) = @_;
my ($savename, $url);
print "$file\n";
open(FILE, $file);
while (<FILE>) {
if ($_ =~ /^(LINK|LSUB|LNEW|LSTRIKE|LIMG)\s+((http:|ftp:)\S+)/) {
fetch($2);
}
elsif ($_ =~ /^(RLINK|RLSUB|RLNEW)\s+(\S+)\s+(\S+)/) {
$url = $Rlink{$2} . $3;
if ($url =~ m!^http://|ftp://!) {
fetch($url);
}
}
}
close(FILE);
}
sub fetch($) {
my ($url) = @_;
my ($hit, $savename);
$url =~ s/#.+$//;
$hit = 0;
foreach my $except (@EXCEPT_URL) {
if ($url =~ /$except/) {
$hit = 1;
last;
}
}
if (! $hit) {
$savename = $url;
$savename =~ s/\//!/g;
if ( $beskip ) {
if ( -e "$ARCHIVE_DIR/$savename" ) {
print "\t\t\t\t$url\n" unless $benotdisp;
} else {
print "\t$url\n";
mirror("$url", "$ARCHIVE_DIR/$savename");
}
} else {
print "\t$url\n";
mirror("$url", "$ARCHIVE_DIR/$savename");
}
}
}
[ ツッコむ ]
以上です。