diverses hinzu

This commit is contained in:
Marc Hoppe
2012-12-16 18:46:30 +01:00
parent 5cc14d382a
commit 650bd4c705
58 changed files with 6040 additions and 20 deletions

862
SyncPOD Executable file
View File

@@ -0,0 +1,862 @@
#!/usr/bin/perl -w
# (c) 2002 Armin Obersteiner <armin@xos.net>
# License: GPL v2
use MP3::Info;
use Unicode::String qw( latin1 utf16 );
use Shell qw ( find gzip );
use Getopt::Std;
use File::Copy;
use Filesys::DiskFree;
use Data::Dumper qw (Dumper);
use strict;
my $version="0.68";
#
# options & config
#
my %opt;
getopts("fcnh",\%opt);
if($opt{h}) {
print <<"EOF";
$0 [-c] [-f] [Search Pattern 1] [Search Pattern 2] ...
-c create: create directory structure on plain ipod before syncing
(default: you get a warning if there is no ipod structure)
-f force: rename ipod and use it with $0 before syncing
(default: an unknown ipod stays untouched)
-n name check: checks mp3 names for possible illegal characters
Search Patterns: for each search pattern a playlist is created
(case insensitive)
EOF
exit;
}
my $buffer = 5*1024*1024; # leave some MB free for iTunesDB
my @required = qw ( SYNCMODE PLAYLISTDIR IPODDIR BACKUPDIR );
my $rc=readrc("$ENV{HOME}/.ipod/config",\@required);
#print Dumper($rc);
#
# check ipod name
#
my ($ipod_name, $real_name, $computer_name)=get_ipodname($rc->{IPODDIR});
unless($ipod_name) {
die "IPOD dir not found: $rc->{IPODDIR}" unless $opt{c};
}
#
# check ipod dirs (recreate them if necessary)
#
mkdir "$rc->{IPODDIR}/iPod_Control",0755 unless(-d "$rc->{IPODDIR}/iPod_Control");
mkdir "$rc->{IPODDIR}/iPod_Control/Music",0755 unless(-d "$rc->{IPODDIR}/iPod_Control/Music");
mkdir "$rc->{IPODDIR}/iPod_Control/iTunes",0755 unless(-d "$rc->{IPODDIR}/iPod_Control/iTunes");
mkdir "$rc->{IPODDIR}/iPod_Control/Device",0755 unless(-d "$rc->{IPODDIR}/iPod_Control/Device");
for(0..19) {
my $d=sprintf "%.2d",$_;
mkdir "$rc->{IPODDIR}/iPod_Control/Music/F$d",0755 unless(-d "$rc->{IPODDIR}/iPod_Control/Music/F$d");
}
unless($opt{c}) {
print STDERR "IPOD name: $ipod_name\n";
print STDERR "Synced by: $real_name\n";
print STDERR "Synced on: $computer_name\n";
if($rc->{WRITEDEVICEINFO} && !$opt{f}) {
my $exit=0;
unless($rc->{IPODNAME} eq $ipod_name) {
$exit=1;
print STDERR "Your IPOD name: $rc->{IPODNAME}\n";
}
unless($rc->{REALNAME} eq $real_name) {
$exit=1;
print STDERR "Your real name: $rc->{REALNAME}\n";
}
unless($rc->{COMPUTERNAME} eq $computer_name) {
$exit=1;
print STDERR "Your computer: $rc->{COMPUTERNAME}\n";
}
die "names mismatch, use -f to override" if $exit;
}
print STDERR "\n";
}
#
# write ipod name
#
if($rc->{WRITEDEVICEINFO}) {
set_ipodname(
$rc->{IPODDIR},$rc->{BACKUPDIR},
$rc->{IPODNAME},$rc->{REALNAME},$rc->{COMPUTERNAME}
);
$ipod_name=$rc->{IPODNAME};
}
#
# check for songs
#
my %songs;
my %check;
my $dir;
$dir=$rc->{IPODDIR}."/iPod_Control/Music";
$dir=$rc->{SYNCDIR} if($rc->{SYNCMODE} >= 2);
my %tosync;
if(($rc->{SYNCLIST}) && ($rc->{SYNCMODE} == 2)) {
open IN,$rc->{SYNCLIST} or die "all-playlist: $rc->{SYNCLIST} not found";
while(<IN>) {
chomp;
$tosync{$_}=1;
}
close IN;
}
my @mp3s;
if(($rc->{SYNCMODE} == 3)) {
my @pl=find("$rc->{PLAYLISTDIR}/* 2>/dev/null");
my %test;
for my $p (@pl) {
chomp $p;
my ($n) = $p =~ /.*\/(.*?)$/;
open IN,$p or die "playlist: $p could not be opened";
while(<IN>) {
unless($test{$_}) {
push @mp3s,$_;
$test{$_}=1;
}
}
}
} else {
@mp3s=find($dir);
}
for(@mp3s) {
chomp $_;
next unless(/\.(m|M)(p|P)3$/);
my $name=$_;
if(keys %tosync) {
next unless($tosync{$name});
}
if($opt{n}) {
die "illegal character in filename [$name]\n" unless ($name =~ /^[A-Za-z0-9\.\-_\/\,]+$/);
}
s/\://g;
s/.*\///g;
$songs{$name}{name}=$_;
if($rc->{SYNCMODE} >= 2) {
$songs{$name}{dir}="F".hash($_);
} else {
($songs{$name}{dir}) = $name =~ /\/(F\d\d)\//;
}
{
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks) = stat($name);
$songs{$name}{size}=$size;
$songs{$name}{date}=$mtime;
}
my $tag;
$tag = get_mp3tag($name) unless($rc->{ALWAYSTEMPLATES});
my ($artist,$album,$title,$order,$_dummy_);
if($tag) {
# print Dumper($tag);
# YEAR ARTIST COMMENT TRACKNUM TITLE ALBUM GENRE
$artist=$tag->{ARTIST};
$album=$tag->{ALBUM};
$title=$tag->{TITLE};
$order=$tag->{TRACKNUM};
$order=$1 if($order =~ /(\d+)\s*\//);
} else {
for(sort {length($b) <=> length($a)} keys %{$rc->{FILETEMPLATES}}) {
if(my @x = $name =~ /$_/) {
my $c=0;
for my $x (@x) {
#print "\$$rc->{FILETEMPLATES}->{$_}->[$c]=\"$x\";\n";
eval "\$$rc->{FILETEMPLATES}->{$_}->[$c]=\"$x\";";
die "eval error: $@" if($@);
$c++;
}
last;
}
}
}
unless($title) {
die "no title found in: $name";
}
$title =~ s/_/ /g;
$artist =~ s/_/ /g;
$album =~ s/_/ /g;
$songs{$name}{title}=$title;
$songs{$name}{artist}="";
$songs{$name}{album}="";
$songs{$name}{order}=0;
$songs{$name}{artist}=$artist if $artist;
$songs{$name}{album}=$album if $album;
$songs{$name}{order}=$order if $order;
my $info = get_mp3info ($name);
$songs{$name}{size}=$info->{SIZE};
$songs{$name}{bitrate}=$info->{BITRATE};
$songs{$name}{duration}=int($info->{SECS}*1000);
$songs{$name}{vbr}=$info->{VBR};
#print Dumper($info);
my $n=$songs{$name}{dir}."/".$songs{$name}{name};
unless($check{$n}) {
$check{$n}=1;
} else {
die "songname: $songs{$name}{name} not unique";
}
}
#
# deleting unwanted songs
#
my %known;
for(keys %songs) {
$known{$songs{$_}{name}}=1;
}
#print Dumper(\%known);
my @ipod = find ("$rc->{IPODDIR}/iPod_Control/Music");
my @todel;
for(@ipod) {
next unless (/\.mp3$/i);
chomp;
my ($name) = $_ =~ /\/([^\/]+\.mp3)$/i;
unless($known{$name}) {
push @todel,$_;
}
}
my $del;
if($rc->{DELETEASK} && @todel) {
for(@todel) {
print "del: $_\n";
}
print "Do you really want to delete this songs? (y/N) ";
my $in=<STDIN>;
chomp $in;
$del=1 if($in =~ /^y$/i);
} else {
$del=1;
}
if($del) {
for(@todel) {
print STDERR "deleting: $_\n";
unlink($_);
}
}
#
# copy songs
#
my $main_sl="";
my $main_pl="";
my $index=500;
#print Dumper(\%songs);
my $df = new Filesys::DiskFree;
SONGS: for my $song (keys %songs) {
my $attr;
my $out="";
my $attr_c=3;
if($rc->{SYNCMODE} >= 2) {
my $to = "$rc->{IPODDIR}/iPod_Control/Music/$songs{$song}{dir}/$songs{$song}{name}";
#my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
# $atime,$mtime,$ctime,$blksize,$blocks) = stat($to);
#$size=0 unless $size;
#print "checking: $song [$songs{$song}{size}] -> $to [$size]\n";
#if($size != $songs{$song}{size}) {
unless(-e $to) {
print STDERR "syncing: $songs{$song}{name}\n";
# cp "\"$song\" \"$to\"";
$df->df();
my $free=$df->avail($rc->{IPODDIR});
if($free-$songs{$song}{size}-$buffer>0) {
copy($song,$to);
} else {
print STDERR "no space availiable for: $songs{$song}{name} [$songs{$song}{size}]\n";
delete $songs{$song};
next SONGS;
}
}
}
$songs{$song}{index}=$index;
$out.=create_mhod($songs{$song}{title},1);
if($songs{$song}{artist}) {
$attr_c++;
$out.=create_mhod($songs{$song}{artist},4);
}
if($songs{$song}{album}) {
$attr_c++;
$out.=create_mhod($songs{$song}{album},3);
}
$out.=create_mhod("MPEG audio file",6);
$out.=create_mhod(":iPod_Control:Music:".$songs{$song}{dir}.":".$songs{$song}{name},2);
$out=create_mhit(
$attr_c,length($out),$index,$songs{$song}{vbr},
$songs{$song}{date},$songs{$song}{size},
$songs{$song}{duration},$songs{$song}{order},
$songs{$song}{bitrate}
).$out;
$main_sl.=$out;
$main_pl.=create_mhod_mhip($songs{$song}{index});
$index++;
}
#print Dumper(\%songs);
my %playlists;
my @pl=find("$rc->{PLAYLISTDIR}/* 2>/dev/null");
for my $p (@pl) {
chomp $p;
my ($n) = $p =~ /.*\/(.*?)$/;
open IN,$p or die "playlist: $p could not be opened";
while(<IN>) {
my $song=$_;
chomp $song;
unless($songs{$song}) {
print STDERR "ignoring song in playlist [$p], [$song] does not exist in syncdir or ipod full\n";
} else {
$playlists{$n}{raw}.=create_mhod_mhip($songs{$song}{index});
$playlists{$n}{count}++;
}
}
close IN;
}
#
# creating search pattern playlists
#
for my $pattern (@ARGV) {
my @list;
for(keys %songs) {
push @list,$songs{$_}{index} if($_ =~ /$pattern/i);
}
unless(@list) {
print STDERR "nothing for searchpattern: $pattern found\n";
} else {
my ($name)=$pattern=~/(\S\S\S+)/;
unless(length($name)>=3) {
$name=$pattern;
$name =~ s/[^A-Za-z0-9]//g;
}
for(@list) {
$playlists{$name}{raw}.=create_mhod_mhip($_);
$playlists{$name}{count}++;
}
print STDERR @list." songs for searchpattern: $pattern found\n";
}
}
#print Dumper(\%playlists);
#
# build the pieces together
#
my $output;
my $song_c=keys %songs;
print STDERR "\nFound songs: $song_c\n";
my $tmp=create_mhlt($song_c).$main_sl;
$main_sl=create_mhsd(96+length($tmp),1).$tmp;
print STDERR "Songlist created\n";
my $pl_c=keys %playlists;
print STDERR "\nFound additional playlists: $pl_c\n";
$tmp=create_mhlp($pl_c+1).create_playlist_main($ipod_name,$song_c).$main_pl;
print STDERR "\nMain playlist created: $song_c songs\n\n";
for(keys %playlists) {
$tmp.=create_playlist($_,$playlists{$_}{count}).$playlists{$_}{raw};
print STDERR "Playlist \"$_\" created: $playlists{$_}{count} songs\n";
}
$main_pl=create_mhsd(96+length($tmp),2).$tmp;
$output=create_mhbd(104+length($main_sl.$main_pl)).$main_sl.$main_pl;
# backup old iTunesDB
if(-e "$rc->{IPODDIR}/iPod_Control/iTunes/iTunesDB") {
my $t=time();
copy("$rc->{IPODDIR}/iPod_Control/iTunes/iTunesDB","$rc->{BACKUPDIR}/iTunesDB_$t");
gzip("$rc->{BACKUPDIR}/iTunesDB_$t");
}
open OUT,">".$rc->{IPODDIR}."/iPod_Control/iTunes/iTunesDB" or die "cannot write iTunesDB";
print OUT $output;
close OUT;
print STDERR "\niTunesDB created.\n";
exit;
# END
#
# internal subroutines
#
sub create_mhbd {
my ($size) = @_;
my $r= "mhbd";
$r.= pack "V",104;
$r.= pack "V",$size;
$r.= pack "V",1;
$r.= pack "V",1;
$r.= pack "V",2;
for(1..20) {
$r.= pack "V",0;
}
return $r;
}
sub create_mhlp {
my ($count) = @_;
my $r= "mhlp";
$r.= pack "V",92;
$r.= pack "V",$count;
for(1..20) {
$r.= pack "V",0;
}
return $r;
}
sub create_playlist {
my ($name,$anz) = @_;
my $ipod_name=create_mhod($name,1);
my $r= "mhyp";
$r.= pack "V",108;
$r.= pack "V",108+648+length($ipod_name)+$anz*(76+44);
$r.= pack "V",2;
$r.= pack "V",$anz;
$r.= pack "V",0;
$r.= pack "V",3088620292;
$r.= pack "V",2317718671;
$r.= pack "V",3655876446;
for(1..18) {
$r.= pack "V",0;
}
$r.= "mhod";
$r.= pack "V",24;
$r.= pack "V",648;
$r.= pack "V",100;
for(1..3) {
$r.= pack "V",0;
}
$r.= pack "V",12714187; # ?? 12714187
$r.= pack "V",26215000;
$r.= pack "V",0;
$r.= pack "V",65736;
$r.= pack "V",1; # ?? 1
$r.= pack "V",6; # ?? 6
$r.= pack "V",0; # ?? 0
$r.= pack "V",2555905; # ?? 2555905
for(1..3) {
$r.= pack "V",0;
}
$r.= pack "V",13107202;
for(1..3) {
$r.= pack "V",0;
}
$r.= pack "V",3276813;
for(1..3) {
$r.= pack "V",0;
}
$r.= pack "V",8192004;
for(1..3) {
$r.= pack "V",0;
}
$r.= pack "V",8192003;
for(1..3) {
$r.= pack "V",0;
}
$r.= pack "V",5242888;
for(1..107) {
$r.= pack "V",0;
}
$r.= pack "V",140;
for(1..19) {
$r.= pack "V",0;
}
return $r.$ipod_name;
}
sub create_playlist_main {
my ($name,$anz) = @_;
my $ipod_name=create_mhod($name,1);
my $r= "mhyp";
$r.= pack "V",108;
$r.= pack "V",108+648+length($ipod_name)+$anz*(76+44);
$r.= pack "V",2;
$r.= pack "V",$anz;
$r.= pack "V",1;
$r.= pack "V",3087491191;
$r.= pack "V",837788566;
$r.= pack "V",62365;
for(1..18) {
$r.= pack "V",0;
}
$r.= "mhod";
$r.= pack "V",24;
$r.= pack "V",648;
$r.= pack "V",100;
for(1..3) {
$r.= pack "V",0;
}
$r.= pack "V",13172927; # ?? 12714187
$r.= pack "V",26215000;
$r.= pack "V",0;
$r.= pack "V",65736;
$r.= pack "V",5; # ?? 1
$r.= pack "V",6; # ?? 6
$r.= pack "V",3; # ?? 0
$r.= pack "V",1179649; # ?? 2555905
for(1..3) {
$r.= pack "V",0;
}
$r.= pack "V",13107202;
for(1..3) {
$r.= pack "V",0;
}
$r.= pack "V",3276813;
for(1..3) {
$r.= pack "V",0;
}
$r.= pack "V",8192004;
for(1..3) {
$r.= pack "V",0;
}
$r.= pack "V",8192003;
for(1..3) {
$r.= pack "V",0;
}
$r.= pack "V",5242888;
for(1..107) {
$r.= pack "V",0;
}
$r.= pack "V",140;
for(1..19) {
$r.= pack "V",0;
}
return $r.$ipod_name;
}
sub create_mhod_mhip {
my ($ref) = @_;
my $r= "mhip";
$r.= pack "V",76;
$r.= pack "V",76;
$r.= pack "V",1;
$r.= pack "V",0;
$r.= pack "V",$ref-1;
$r.= pack "V",$ref;
$r.= pack "V",3088619525;
for(1..11) {
$r.= pack "V",0;
}
$r.="mhod";
$r.= pack "V",24;
$r.= pack "V",44;
$r.= pack "V",100;
$r.= pack "V",0;
$r.= pack "V",0;
$r.= pack "V",$ref-1;
for(1..4) {
$r.= pack "V",0;
}
return $r;
}
sub create_mhsd {
my ($size,$type) = @_;
my $r="mhsd";
$r.= pack "V",96;
$r.= pack "V",$size;
$r.= pack "V",$type;
for(1..20) {
$r.= pack "V",0;
}
return $r;
}
sub create_mhlt {
my ($count) = @_;
my $r="mhlt";
$r.= pack "V",92;
$r.= pack "V",$count;
for(1..20) {
$r.= pack "V",0;
}
return $r;
}
sub create_mhit {
my ($arttr_c,$attr_s,$index,$vbr,$date,$size,$dur,$order,$bitrate) = @_;
my $r="mhit";
$r.= pack "V",156;
$r.= pack "V",156+$attr_s;
$r.= pack "V",$arttr_c;
$r.= pack "V",$index;
$r.= pack "V",1;
$r.= pack "V",0;
my $type=256;
$type+=1 if($vbr);
$r.= pack "V",$type;
$r.= pack "V",$date+2082844800;
$r.= pack "V",$size;
$r.= pack "V",$dur;
$r.= pack "V",$order;
$r.= pack "V",0;
$r.= pack "V",0;
$r.= pack "V",$bitrate;
$r.= pack "V",2890137600;
for(1..23) {
$r.= pack "V",0;
}
return $r;
}
sub create_mhod {
my ($string,$type) = @_;
my $len=length($string);
my $r="mhod";
$r.= pack "V",24;
$r.= pack "V",(40+2*$len);
$r.= pack "V",$type;
$r.= pack "V2",0;
$r.= pack "V",1;
$r.= pack "V",(2*$len);
$r.= pack "V2",0;
my $u=latin1($string);
$u->byteswap;
$r.= $u->utf16;
return $r;
}
sub set_ipodname {
my ($dev,$backup,$name,$real,$cpu)=@_;
$dev.="/iPod_Control/iTunes/DeviceInfo";
my $file;
for(1..384) {
$file.=pack "V",0;
}
my $l=length($name);
substr($file,0,2)=pack "v",$l;
my $u=latin1($name);
$u->byteswap;
substr($file,2,$l*2)=$u->utf16;
$l=length($real);
substr($file,512,2)=pack "v",$l;
$u=latin1($real);
$u->byteswap;
substr($file,514,$l*2)=$u->utf16;
$l=length($cpu);
substr($file,1024,2)=pack "v",$l;
$u=latin1($cpu);
$u->byteswap;
substr($file,1026,$l*2)=$u->utf16;
if(-e $dev) {
my $t=time();
copy($dev,"$backup/DeviceInfo_$t");
gzip("$backup/DeviceInfo_$t");
}
open IPOD,">$dev" or die "cannot write DeviceInfo";
print IPOD $file;
close IPOD;
}
sub get_ipodname {
my $dev=shift;
$dev.="/iPod_Control/iTunes/DeviceInfo";
my $file;
my $buff;
open IPOD,$dev or return undef;
while (read(IPOD, $buff, 8 * 2**10)) {
$file.=$buff;
}
close IPOD;
my $l=unpack "v",substr($file,0,2);
my $s=substr($file,2,$l*2);
my $u=utf16($s);
$u->byteswap;
my $name=$u->latin1;
$l=unpack "v",substr($file,512,2);
$s=substr($file,514,$l*2);
$u=utf16($s);
$u->byteswap;
my $realname=$u->latin1;
$l=unpack "v",substr($file,1024,2);
$s=substr($file,1026,$l*2);
$u=utf16($s);
$u->byteswap;
my $computername=$u->latin1;
return ($name,$realname,$computername);
}
sub hash {
my $string=shift;
my $key;
my $len=length($string);
for(my $j=$len-1 ; $j>1 ; $j--) {
$key+=ord(substr($string,$j,1));
}
return sprintf "%.2d",(substr($key,length($key)-2,2) % 20);
}
sub readrc {
my $file = shift;
my $req = shift;
my $rc;
my $sub;
open IN,$file or die "cannot open rc file: $file";
while(<IN>) {
next if /^\s*$/;
next if /^\s*#/;
if(/^\s*(\S+)\s*=\s*(.*?)\s*$/) {
my $k=$1;
my $n=$2;
($n) = $n =~ /^\"(.*?)\"$/ if($n =~ /\"/);
unless($sub) {
$rc->{$k}=$n;
} else {
($k) = $k =~ /^\"(.*?)\"$/ if($k =~ /\"/);
my @n=split /,/,$n;
for(@n) {
s/^\s+//g;
s/\s+$//g;
s/^\"//;
s/\"$//;
}
$rc->{$sub}->{$k}=\@n;
}
} elsif (/^\s*(\S+)\s*\{/) {
$sub=$1;
} elsif (/^\s*}/) {
$sub=undef;
}
}
if($rc->{SYNCMODE} == 2) {
push @$req,"SYNCDIR";
}
if($rc->{WRITEDEVICEINFO} == 1) {
push @$req,("IPODNAME","REALNAME","COMPUTERNAME");
}
if($rc->{ALWAYSTEMPLATES} == 1) {
push @$req,"FILETEMPLATES";
}
for my $d (keys %$rc) {
if($d =~ /DIR$/) {
$rc->{$d} =~ s/\~/$ENV{HOME}/;
}
}
$rc->{SYNCLIST} =~ s/\~/$ENV{HOME}/ if $rc->{SYNCLIST};
for(@$req) {
die "RC PARAMETER: $_ not found" unless($rc->{$_});
}
return $rc;
}

18
cd-blank Executable file
View File

@@ -0,0 +1,18 @@
#!/bin/sh
set -x
echo
echo "L<>schen einer CD-RW"
echo
. /etc/dvd-scripts.env
if [ "$1" == "all" ]
then
echo "Die CD-RW wird gr<67>ndlich gel<65>scht..."
cdrecord -v dev="$CD_DEVICE" -blank=all
else
echo "Die CD-RW wird schnell gel<65>scht..."
cdrecord -v dev="$CD_DEVICE" -blank=fast
fi

25
cd-burn-files Executable file
View File

@@ -0,0 +1,25 @@
#!/bin/sh
set -x
echo
echo "Brennen eins Verzeichnisses"
echo
. /etc/dvd-scripts.env
CD_IMAGE=$CD_IMAGE_TEMP
DATA_DIR=$1
label=`date '+%Y-%m-%d'`
echo "Das Image f<>r das Verzeichnis $DATA_DIR wird erzeugt..."
mkisofs -D -J -L -r -v -V "$label" -o "$CD_IMAGE" "$DATA_DIR"
if [ $? -eq 0 ]
then
cd-burn-image "$CD_IMAGE"
rm "$CD_IMAGE"
else
echo "Fehler beim erzeugen des Image."
fi

25
cd-burn-image Executable file
View File

@@ -0,0 +1,25 @@
#!/bin/sh
#set -x
echo
echo "Brennen eines CD-Images"
echo
. /etc/dvd-scripts.env
CD_IMAGE=$1
hdparm -u1 -d1 $CD_DEVICE_SCSI
if [ "$CD_IMAGE" == "" ]
then
echo "Usage: $0 image-file-to-burn"
elif [ -s "$CD_IMAGE" ]
then
echo "Das Image $CD_IMAGE wird gebrannt..."
cdrecord -v -eject dev="$CD_DEVICE_SCSI" -data "$CD_IMAGE"
else
echo "Das Image $CD_IMAGE existiert nicht !"
fi
echo

97
cd2mp3 Executable file
View File

@@ -0,0 +1,97 @@
#!/bin/bash
#
# /usr/local/bin/cdtomp3 -- CD rippen
#
#set -x
[ -f ~/.cd2mp3.conf ] && . ~/.cd2mp3.conf
[ -z $cdreader ] && cdreader="/dev/cdrom"
[ -z $bitrate ] && bitrate=192
[ -z $cddbdata ] && cddbdata=/tmp/cdtomp3.cddb
[ -z $grabber ] && grabber='cdparanoia -q -w $(expr $i + 1) -d $cdreader -'
[ -z $destdir ] && destdir=/dat/mp3Neu
[ -z $prio ] && prio=10
[ -z $SVDSVDRPSEND ] && SVDRPSEND=svdrpsend.pl
[ -z $LOGFILE ] && LOGFILE=/tmp/cd2mp3.log
if test -f $LOGFILE; then
rm $LOGFILE
fi
if test -s $cddbdata; then
rm $cddbdata
fi
#internetverbindung in de g<>nge bringen
#ping -c 2 www.heise.de
#sleep 15
cddb=$(echo $(disc-cover -t cddb -D $cdreader -o "$cddbdata") | awk -F'"' '{print $2}')
if test -s "$cddbdata"; then
subdir=$(grep "DTITLE" "$cddbdata" | awk -F= '{print $2}' | sed "s/ /_/g" | sed "s/[^[:alnum:]_-]//g")
echo "CDDB Eintrag gefunden: $subdir"
$SVDRPSEND MESG "CDDB Eintrag gefunden: $subdir"
else
subdir="UnbekannteCd"
fi
if ! test -d "$destdir/$subdir"; then
mkdir $destdir/$subdir
fi
cd $destdir/$subdir
if ! test -a fifo; then
mkfifo fifo
fi
## Jetzt geht's los, maximal 100 Titel auf einer CD
for(( i=0; i<=99; i++))
do
## Erst den Dateinamen des Tracks ermitteln
if test -s "$cddbdata"; then
trackname=$(grep "TITLE$(echo $(expr $i + 0))=" $cddbdata | awk -F= '{print $2}' | sed "s/ /_/g" | sed "s/[^[:alnum:]_-]//g")
if ! test "$trackname"; then
trackname="track"
fi
else
trackname="track"
fi
## Index hinzu; moegliche Namensgleichheiten beseitigen
let "i2 = $i + 1"
if [ $i2 -le 9 ] ; then
index=0$i2
else
index=$i2
fi
trackname=$index"-$trackname"
echo $trackname
## Get names for ID-Tags #################
titlename=$(grep "TITLE$(echo $(expr $i + 0))=" $cddbdata | awk -F= '{print $2}')
year=$(grep "DYEAR=" $cddbdata | awk -F= '{print $2}')
disktitle=$(grep "DTITLE=" $cddbdata | awk -F[=/] '{print $3}' | sed "s/^ *//")
diskartist=$(grep "DTITLE=" $cddbdata | awk -F[=/] '{print $2}')
#echo Jahr:$year
#echo Titel:$titlename
#echo Album:$disktitle
#echo Interpret:$diskartist
$SVDRPSEND MESG "'$trackname' wird gerippt"
## Grabber und Kodierer anwerfen ############
# Codieren beginnt sobald das erste Byte eintrifft ...
nice -n $prio lame --quiet --tt "$titlename" --ta "$diskartist" --tl "$disktitle" --ty "$year" --tn "$i2" --disptime 2 -b $bitrate -m s -h fifo "$trackname".mp3 > $LOGFILE &
eval "nice -n $prio $grabber" > fifo
# das ist der Fall, wenn der angegebene Track existiert ...
if test "$?" -ne 0; then
sleep 5
# Fehlercode des Grabbers -> reale Trackzahl ueberschritten
# oder Fehler des CD Laufwerks
#echo "FEHLER"
#echo "$trackname".mp3
rm "$trackname".mp3
break
fi
done
rm fifo
$SVDRPSEND MESG "Rippen fertig"
echo "Fertig !"

24
cda2hd Executable file
View File

@@ -0,0 +1,24 @@
#!/bin/sh
#
#
set -x
#scsidev="0,0,0"
cdreader="/dev/cdrom"
destdir=/dat/tmp/audio
driver=generic-mmc
logfile=/tmp/cda2hd.log
nicelevel=15
[ -d $destdir ] || mkdir -p $destdir
cd $destdir
# Datei cd.toc erzeugen
[ -f cd.toc ] && rm cd.toc
nice -n $nicelevel cdrdao read-toc --with-cddb --datafile data.raw --device $cdreader --driver $driver cd.toc > $logfile
# Grabben (cdparanoia hat eine bessere Kratzererkennung)
[ -f data.raw ] && rm data.raw
nice -n $nicelevel cdparanoia -v 1- -p data.raw -d $cdreader > $logfile
#cdrdao write --eject --speed $speed --device $scsidev --driver $driver cd.toc
eject $cdreader

56
convnow.sh Executable file
View File

@@ -0,0 +1,56 @@
#!/bin/bash
log=/tmp/convnow.log
#echo 0:$0 >> $log
#echo 1:$1 >> $log
#echo 2:$2 >> $log
viddir=\\/var\\/lib\\/video.00\\/
recdir=$2
recpath=$(echo $recdir | sed "s/$viddir//g")
#echo recpath: $recpath >> $log
#echo "2" >> $log
function cmd2nas {
local cmd=$1
local nasaddr=nas@nas
local naskey=nas
echo ssh -i ~/.ssh/$naskey $nasaddr "$cmd" >> $log
ssh -i ~/.ssh/$naskey $nasaddr "$cmd"
}
#echo recpath2: $recpath >> $log
for par in "$@"; do
#echo "xxx:$par" >> $log
case $par in
vdr2mp3)
#echo "vdr2mp3" >> $log
cmd2nas "nohup ruby ~/bin/vdr2mp3.rb '$recpath' >/tmp/test.log 2>&1 & "
;;
*)
;;
esac
done
#1:vdr2mp3dd
#2:/var/lib/video.00/%Dok_5_-_Das_Feature/2012-08-05.11.00.124-0.rec
exit
ssh -i /home/marc/.ssh/nas nas@nas "nohup ruby ~/bin/vdr2mp3.rb '%Dok_5_-_Das_Feature/2012-08-05.11.00.124-0.rec' > /tmp/test.log 2>&1 &"
set -x
. /etc/vdr/vdrconvert.env
if [ ! -z "$SERVER" ]
then
ssh $SERVER $0 $1 "'$2'"
else
printf "%s\n" "$2" >> $VCOQUEUEDIR/$1
fi

28
cp_packages.sh Normal file
View File

@@ -0,0 +1,28 @@
#scripts/feeds update
#make
cd ../ipk/ar71xx
#cp ../../base/bin/ar71xx/packages/fhem-enocean_eo_ar71xx.ipk .
#cp ../../base/bin/ar71xx/packages/fhem-trunk_trunk_ar71xx.ipk .
#cp ../../base/bin/ar71xx/packages/fhem-trunk_trunk_ar71xx.ipk .
cp ../../base/bin/ar71xx/packages/fhem*.ipk .
#perl-device-serialport_1.04-2_ar71xx.ipk
cp ../../base/bin/ar71xx/packages/perl-device-serialport_*.ipk .
#perl-weather_0.5.5-1_ar71xx.ipk
cp ../../base/bin/ar71xx/packages/perl-weather_*.ipk .
cp ../../base/bin/ar71xx/packages/eibd*.ipk .
cp ../../base/bin/ar71xx/packages/linknx*.ipk .
cp ../../base/bin/ar71xx/*.bin /home/marc/Dropbox-ipad/Public/
cp ../../base/bin/ar71xx/md5sums /home/marc/Dropbox-ipad/Public/
../../base/scripts/ipkg-make-index.sh . > Packages ; gzip -c Packages > Packages.gz
cp *.ipk /home/marc/Dropbox-ipad/Public/ipk/ar71xx/
cp Packages.gz /home/marc/Dropbox-ipad/Public/ipk/ar71xx/
cd -

140
create_omtb_garmin_img.sh Executable file
View File

@@ -0,0 +1,140 @@
#!/bin/zsh
# License: Creative Commons Share Alive 3.0
# Copyright: 2012, Bernhard Tittelbach <xro@realraum.at>
# Thanks to malenki on #osm-de@oftc.net for constructive input and nagging me into making this thing useable in the first place
# Required software:
# - zsh (obviously)
# - 7z
# - mkgmap (preferred) [http://www.mkgmap.org.uk/snapshots/] OR wine
# - gmt linux version [ http://www.anpo.republika.pl/download.html ] OR wine
#
setopt extendedglob
setopt cshnullglob
SCRIPT_NAME=${0:t}
usage()
{
print "\nUsage: $SCRIPT_NAME [options] <mtb*.exe|velo*.exe> <TYP-file or TYP-style>" > /dev/stderr
print " as TYP-style you can choose:" > /dev/stderr
print " clas: classic layout - optimized for Vista/Legend series" > /dev/stderr
print " thin: thinner tracks and pathes - optimized for Gpsmap60/76 series" > /dev/stderr
print " wide: high contrast layout, like classic but with white forest - optimized for Oregon/Colorado dull displays" > /dev/stderr
print " hike: like classic layout - but optimized for hiking (does not show mtb/bicycle informations)" > /dev/stderr
print " easy: similar to classic layout - but focussed on easy readability hence not showing mtb/bicycle information except routes" > /dev/stderr
print " velo: (comes with velomap files) Layout optimized for small GPS screen" > /dev/stderr
print " or give the path to your own .TYP style file" > /dev/stderr
print "\nOptions:" > /dev/stderr
print " -m <path/to/mkgmap.jar>" > /dev/stderr
print " -o <path/to/outputdir>\n" > /dev/stderr
exit 1
# descriptions taken from openmtbmap.org batch files
}
zparseopts -A ARGS_A -D -E -- "m:" "o:"
OMTB_EXE="$1"
TYPFILE="$2"
GMT_CMD==gmt
MKGMAP=( ${ARGS_A[-m]}(.N,@-.) /usr/share/mkgmap/mkgmap.jar(.N,@-.) /usr/local/share/mkgmap/mkgmap.jar(.N,@-.) ${^path}/mkgmap.jar(.N,@-.) )
MKGMAP="${MKGMAP[1]}"
if ! [[ -x $GMT_CMD ]] ; then
if ! [[ -x =wine ]] ; then
print "ERROR: You need to either install wine or the gmt linux binary !" > /dev/stderr
exit 3
fi
# use supplied gmt.exe with wine
GMT_CMD="wine ./gmt.exe"
fi
if ! [[ -x =7z ]]; then
print "\nERROR: 7z is not installed, but needed to extract openmtbmap downloads !"
exit 3
fi
[[ -z $TYPFILE || ! -f $OMTB_EXE ]] && usage
if [[ ${OMTB_EXE:t} == mtb* ]]; then
OMTBORVELO=openmtbmap
OMTB_NAME="${OMTB_EXE:t:r:s/mtb/}"
elif [[ ${OMTB_EXE:t} == velo* ]]; then
OMTBORVELO=openvelomap
OMTB_NAME="${OMTB_EXE:t:r:s/velo/}"
else
print "\nERROR: not a openmtbmap.org or openvelomap.org file ?"
usage
fi
DESC="${OMTBORVELO}_${OMTB_NAME}"
if [[ -d ${ARGS_A[-o]} ]]; then
DSTFILENAME="${ARGS_A[-o]:A}/${DESC}.img"
TMPDIR=${ARGS_A[-o]:A}/OMTB_tmp
else
DSTFILENAME="${OMTB_EXE:A:h}/${DESC}.img"
TMPDIR=${OMTB_EXE:A:h}/OMTB_tmp
[[ -n $ARGS_A[-o] ]] && {print "\nWarning: -o given but ${ARGS_A[-o]} is not a directory.\n Using ${OMTB_EXE:A:h} instead..\n"}
fi
if [[ -e $DSTFILENAME ]]; then
print "\nWarning: the script will create (overwrite) $DSTFILENAME"
print " but $DSTFILENAME already exists."
read -q "?Continue and overwrite ? [y/N] " || exit 0
print ""
fi
if [[ -e $TMPDIR ]] ; then
print "\nWarning: the script want's to create directory $TMPDIR, but it already exists."
if [[ -d $TMPDIR ]] ; then
print " If you press [y], $OMTB_EXE will be extracted"
print " to $TMPDIR regardless of it's contents."
print " That's fine if it was created during a previous abortet run of this script."
print " Otherwise you should say [n] and move $OMTB_EXE into a clean directory."
read -q "?Continue ? [y/N] " || exit 0
print ""
else
print " Please use another output directory and try again."
exit 1
fi
else
mkdir $TMPDIR || exit 1
fi
FIMG_a=(${TMPDIR}/6<000-999>0000.img(N))
if [[ -z $FIMG_a ]] ; then
print "Extracting $OMTB_EXE ..."
7z x -y -o$TMPDIR ${OMTB_EXE} &>/dev/null || exit 1
FIMG_a=(${TMPDIR}/6<000-999>0000.img(N[1]))
[[ -z $FIMG_a ]] && {print "\nERROR, could not find 6*.img file after extracting $OMTB_EXE" >/dev/stderr ; exit 1}
fi
if [[ -f $TYPFILE ]] ; then
TYPFILE="${TYPFILE:A}"
else
TYPFILE=( "${TMPDIR}/"(#i)${TYPFILE}*.typ(.N:A))
TYPFILE="${TYPFILE[1]}"
fi
trap "cd '$PWD'" EXIT
cd $TMPDIR || exit 5
if [[ -z $TYPFILE ]] ; then
print "\nERROR: TYP-file or -style not found" > /dev/stderr
print " please choose your own file or one of these styles: " *.(#l)TYP(.N:r) > /dev/stderr
exit 2
fi
print "using display-TYP-file: $TYPFILE"
cp $TYPFILE 01002468.TYP || exit 4
FID=${${FIMG_a:t}[1][1,4]}
print using FID $FID
$GMT_CMD -wy $FID 01002468.TYP
if [[ -n $MKGMAP ]]; then
print "using mkgmap, building address search index..."
#java -Xmx1000M -jar mkgmap.jar --family-id=$FID --index --description="$DESC" --series-name="$DESC" --family-name="$DESC" --show-profiles=1 --product-id=1 --gmapsupp 6*.img 7*.img 01002468.TYP
java -Xmx3000M -jar "$MKGMAP" --family-id=$FID --index --description="$DESC" --series-name="$DESC" --family-name="$DESC" --show-profiles=1 --product-id=1 --gmapsupp [67]*.img 01002468.TYP || exit 7
mv (#i)gmapsupp.img "${DSTFILENAME}" || exit 7
else
print "mkgmap not found, using gmt..."
$GMT_CMD -j -o "${DSTFILENAME}" -f $FID -m "$DESC" 6*.img 7*.img 01002468.TYP || exit 7
fi
rm -R "$TMPDIR"
print "\nSuccessfully created ${DSTFILENAME}"

1
create_opkg_index.sh Normal file
View File

@@ -0,0 +1 @@
../../base/scripts/ipkg-make-index.sh . > Packages ; gzip -c Packages > Packages.gz

9
createhdextlinks.sh Normal file
View File

@@ -0,0 +1,9 @@
#dirs=$(find .. -maxdepth 1 -type d ! -name "*.rec" -exec find {} -maxdepth 1 -name "*.rec" \;)
dirs=$(find .. -maxdepth 1 -type d -name "*.rec")
for i in $dirs; do
ln -s $i
echo $i
done

7
createhdextlinks.sh~ Normal file
View File

@@ -0,0 +1,7 @@
dirs=§(find .. -type d -maxdepth 1 ! -name "*.rec" -exec find {} -maxdepth 1 -name "*.rec"}
for i in $dirs do
echo $i
done

821
dropbox.py Executable file

File diff suppressed because one or more lines are too long

6
dvd-blank Executable file
View File

@@ -0,0 +1,6 @@
. /etc/dvd-scripts.env
dvd+rw-format -blank $DVD_DEVICE
echo Fertig.

24
dvd-burn-files Executable file
View File

@@ -0,0 +1,24 @@
set -x
. /etc/dvd-scripts.env
DVD_DIR=$1
echo "Verzeichnis $DVD_DIR auf DVD brennen..."
MAX_SIZE=4702989182
# DVD-Size 4,702,989,182
size=`du -sb "$DVD_DIR" | awk '{print $1}'`
#printf "size: %4d MB\n" `expr $size \/ 1024 \/ 1024`
printf "size: %4d MB\n" `echo "$size/1024/1024;" | bc `
if [ $size -gt $MAX_SIZE ]
then
printf "Zu Gro<72> (max: %4d MB) !!!\n" `expr $MAX_SIZE \/ 1024 \/ 1024`
else
growisofs -Z $DVD_DEVICE -R -J $DVD_DIR
fi
sleep 1
echo Fertig.
eject

15
dvd-burn-image Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/bash
set -x
. /etc/dvd-scripts.env
#/etc/init.d/hdparm restart
hdparm -u1 -d1 $DVD_DEVICE
DVD_IMAGE=$1
[ -r $DVD_IMAGE ] && growisofs -Z $DVD_DEVICE=$DVD_IMAGE
echo Fertig.
sleep 1
eject

16
dvd-burn-video Executable file
View File

@@ -0,0 +1,16 @@
#!/bin/sh
set -x
. /etc/dvd-scripts.env
#A/etc/init.d/hdparm restart
hdparm -d1 -u1 $DVD_DEVICE
DVD_DIR=$1
growisofs -Z $DVD_DEVICE -dvd-video $DVD_DIR
growisofs -lead-out $DVD_DEVICE
echo Fertig.
sleep 1
eject

17
dvd-check-size Executable file
View File

@@ -0,0 +1,17 @@
#set -x
. /etc/dvd-scripts.env
DVD_DIR=$1
MAX_DVD_SIZE=4702989182
# DVD-Size 4,702,989,182
size=`du -sb "$DVD_DIR" | awk '{print $1}'`
printf "Gr<47><72>e: %4d MB\n" `expr $size \/ 1024 \/ 1024`
if [ $size -gt $MAX_DVD_SIZE ]
then
printf "zu Gro<72> (max %4d MB)\n" `expr $MAX_DVD_SIZE \/ 1024 \/ 1024`
else
echo Pa<50>t.
fi

16
dvd-createdev Executable file
View File

@@ -0,0 +1,16 @@
#!/bin/sh
DVD_DEVICE=/dev/dvd
if [ -L $DVD_DEVICE ]
then
echo "Link l<>schen"
rm $DVD_DEVICE
else
echo "Altes Device l<>schen $DVD_DEVICE"
umount $DVD_DEVICE
rmdir $DVD_DEVICE
fi
echo "neuen device erstellen"
mkdir $DVD_DEVICE

6
dvd-format Executable file
View File

@@ -0,0 +1,6 @@
. /etc/dvd-scripts.env
dvd+rw-format -force $DVD_DEVICE
echo Fertig.

31
dvd-gen-movix Executable file
View File

@@ -0,0 +1,31 @@
set -x
. /etc/dvd-scripts.env
DVD_DIR=$1
FILES=$2
cd $DVD_DIR
echo "Movix DVD aus Dateien $DVD_DIR/$FILES erzeugen..."
#MAX_SIZE=4702989182
# DVD-Size 4,702,989,182
i#size=`du -sb "$DVD_DIR" | awk '{print $1}'`
#printf "size: %4d MB\n" `expr $size \/ 1024 \/ 1024`
#printf "size: %4d MB\n" `echo "$size/1024/1024;" | bc `
#if [ $size -gt $MAX_SIZE ]
#then
# printf "Zu Gro<72> (max: %4d MB) !!!\n" `expr $MAX_SIZE \/ 1024 \/ 1024`
#lse
# growisofs -Z $DVD_DEVICE -R -J $DVD_DIR
#fi
mkmovixiso $FILES
ln -s movix.iso last.iso
sleep 1
echo Fertig.
eject

17
dvd-rip-image Executable file
View File

@@ -0,0 +1,17 @@
#!/bin/sh
. /etc/dvd-scripts.env
DVD_IMAGE=$1
rm "$DVD_IMAGE"
rm /dat/dvd/last.iso
echo Image wird erstellt...
dd if=$DVD_DEVICE of="$DVD_IMAGE"
ln -s "$DVD_IMAGE" /dat/dvd/last.iso
echo Fertig.
eject

1378
dvd2vdr Executable file

File diff suppressed because it is too large Load Diff

86
dvdauthor_helperfunctions.sh Executable file
View File

@@ -0,0 +1,86 @@
#!/bin/sh
#
# (P) & (C) 2003 by Dr. Peter Bieringer <pb at bieringer dot de>
#
# Original site of publishing:
# ftp://ftp.bieringer.de/pub/linux/dvd/dvdauthor-addons/
#
# License: GPLv2
#
# Requires:
# - gozer, imlib2, netpbm-progs
#
# ChangeLog
# 20030510/PB: initial creation
# 20030511/PB: import info function
. ~/.vdrconvert/vdrconvert.env
##### Functions ######
# Put text into a bitmap
put_text() {
local file="$1"; shift
if [ ! -z "$PATH_FONTS" -a ! -z "$DVD_USE_FONT" ]
then
local font="$1"
shift
fi
local color_bg="$1"; shift
local color_fg="$1"; shift
local loc_x="$1"; shift
local loc_y="$1"; shift
local text="$1"; shift
local rest="$*"
local tmp_png="tmp-txt.png"
local tmp_pnm="tmp-txt.pnm"
local tmp_alphapnm="tmp-txt.alpha.pnm"
local tmp_output="tmp-output.pnm"
if [ ! -w "." ]; then
echo "ERR(put_text): file not writable: $file"
return 1
fi
[ ! -z "$RECODE" ] && rtext="`echo $text | $RECODE`" || rtext=$text
if [ -z "$PATH_FONTS" -o -z "$DVD_USE_FONT" ]
then
#set -x
gozer --background $color_bg --foreground $color_fg --text "$rtext" $rest $tmp_png
else
gozer --fontpath $PATH_FONTS --font $font --background $color_bg --foreground $color_fg --text "$rtext" $rest $tmp_png
#set +x
fi
pngtopnm $tmp_png >$tmp_pnm
pngtopnm -alpha $tmp_png >$tmp_alphapnm
pnmcomp -xoff=$loc_x -yoff=$loc_y -alpha=$tmp_alphapnm $tmp_pnm $file >$tmp_output
mv $tmp_output $file
rm -f $tmp_png $tmp_pnm $tmp_alphapnm $tmp_output
}
# Put a bitmap file into another bitmap file
put_file() {
local file=$1
local loc_x=$2
local loc_y=$3
local file2=$4
local tmp_pnm="tmp-txt.pnm"
if [ ! -w "." ]; then
echo "ERR(put_file): file not writable: $file"
return 1
fi
if [ ! -r "$file2" ]; then
echo "ERR(put_file): file not readable: $file2"
return 1
fi
pnmcomp -xoff=$loc_x -yoff=$loc_y $file2 $file >$tmp_pnm
mv $tmp_pnm $file
rm -f $tmp_pnm
}

41
dvddirdel Executable file
View File

@@ -0,0 +1,41 @@
#!/bin/sh
if [ -f /usr/local/etc/dvdauthor.conf ]; then
. /usr/local/etc/dvdauthor.conf
fi
if [ -f ~/.dvdauthorrc ]; then
. ~/.dvdauthorrc
fi
help=0
out=0
for i in "$@"; do
if [ $out = 1 ]; then
WORKDIR="$i"
out=0
elif [ "x$i" = "x-h" ]; then
help=1
elif [ "x$i" = "x-o" ]; then
out=1
fi
done
if [ $help = 1 -o "x$WORKDIR" = "x" ]; then
echo "DVDAuthor, version 0.6.18. Send bugs to <dvdauthor-users@lists.sourceforge.net>"
echo "syntax: dvddirdel [-o DIR]"
echo " deletes a previously authored DVD directory structure in DIR"
exit 1
fi
if [ -d "$WORKDIR" ]; then
rm -f "$WORKDIR/VIDEO_TS"/VIDEO_TS.VOB
rm -f "$WORKDIR/VIDEO_TS"/VIDEO_TS.IFO
rm -f "$WORKDIR/VIDEO_TS"/VIDEO_TS.BUP
rm -f "$WORKDIR/VIDEO_TS"/VTS_??_?.VOB
rm -f "$WORKDIR/VIDEO_TS"/VTS_??_0.IFO
rm -f "$WORKDIR/VIDEO_TS"/VTS_??_0.BUP
rmdir "$WORKDIR/VIDEO_TS"
rmdir "$WORKDIR/AUDIO_TS"
rmdir "$WORKDIR"
fi

BIN
dvdunauthor Executable file

Binary file not shown.

5
fv_html Executable file
View File

@@ -0,0 +1,5 @@
#!/bin/bash
arg=$1
/home/marc/bin/fv $1 | awk '{printf("<p>%s</p>\n", $0);}'

18
getrecnames.sh Normal file
View File

@@ -0,0 +1,18 @@
hd=/media/test
videodir=/video/
recdirs=$(find . -name "*.rec")
echo $recdirs
for i in $recdirs
do
echo rec:$i
recdir=$(basename "$i")
dirv=$(find $videodir -name "$recdir")
d=$(echo $dirv | awk -F/ '{print $(NF-1)}')
echo "$dirv = $d"
mkdir -p $hd/$d
mv $i $hd/$d
done

707
git-prompt.sh Executable file
View File

@@ -0,0 +1,707 @@
# don't set prompt if this is not interactive shell
[[ $- != *i* ]] && return
################################################################### CONFIG
##### read config file if any.
unset dir_color rc_color user_id_color root_id_color init_vcs_color clean_vcs_color
unset modified_vcs_color added_vcs_color addmoded_vcs_color untracked_vcs_color op_vcs_color detached_vcs_color hex_vcs_color
unset rawhex_len
conf=git-prompt.conf; [[ -r $conf ]] && . $conf
conf=/etc/git-prompt.conf; [[ -r $conf ]] && . $conf
conf=~/.git-prompt.conf; [[ -r $conf ]] && . $conf
conf=~/.config/git-prompt.conf; [[ -r $conf ]] && . $conf
unset conf
##### set defaults if not set
git_module=${git_module:-on}
svn_module=${svn_module:-off}
hg_module=${hg_module:-on}
vim_module=${vim_module:-on}
error_bell=${error_bell:-off}
cwd_cmd=${cwd_cmd:-\\w}
#### dir, rc, root color
cols=`tput colors` # in emacs shell-mode tput colors returns -1
if [[ -n "$cols" && $cols -ge 8 ]]; then # if terminal supports colors
dir_color=${dir_color:-CYAN}
rc_color=${rc_color:-red}
user_id_color=${user_id_color:-blue}
root_id_color=${root_id_color:-magenta}
else # only B/W
dir_color=${dir_color:-bw_bold}
rc_color=${rc_color:-bw_bold}
fi
unset cols
#### prompt character, for root/non-root
prompt_char=${prompt_char:-'>'}
root_prompt_char=${root_prompt_char:-'>'}
#### vcs colors
init_vcs_color=${init_vcs_color:-WHITE} # initial
clean_vcs_color=${clean_vcs_color:-blue} # nothing to commit (working directory clean)
modified_vcs_color=${modified_vcs_color:-red} # Changed but not updated:
added_vcs_color=${added_vcs_color:-green} # Changes to be committed:
addmoded_vcs_color=${addmoded_vcs_color:-yellow}
untracked_vcs_color=${untracked_vcs_color:-BLUE} # Untracked files:
op_vcs_color=${op_vcs_color:-MAGENTA}
detached_vcs_color=${detached_vcs_color:-RED}
hex_vcs_color=${hex_vcs_color:-BLACK} # gray
max_file_list_length=${max_file_list_length:-100}
short_hostname=${short_hostname:-off}
upcase_hostname=${upcase_hostname:-on}
count_only=${count_only:-off}
rawhex_len=${rawhex_len:-5}
aj_max=20
##################################################################### post config
################# make PARSE_VCS_STATUS
unset PARSE_VCS_STATUS
[[ $git_module = "on" ]] && type git >&/dev/null && PARSE_VCS_STATUS+="parse_git_status"
[[ $svn_module = "on" ]] && type svn >&/dev/null && PARSE_VCS_STATUS+="${PARSE_VCS_STATUS+||}parse_svn_status"
[[ $hg_module = "on" ]] && type hg >&/dev/null && PARSE_VCS_STATUS+="${PARSE_VCS_STATUS+||}parse_hg_status"
PARSE_VCS_STATUS+="${PARSE_VCS_STATUS+||}return"
################# terminfo colors-16
#
# black? 0 8
# red 1 9
# green 2 10
# yellow 3 11
# blue 4 12
# magenta 5 13
# cyan 6 14
# white 7 15
#
# terminfo setaf/setab - sets ansi foreground/background
# terminfo sgr0 - resets all attributes
# terminfo colors - number of colors
#
################# Colors-256
# To use foreground and background colors:
# Set the foreground color to index N: \033[38;5;${N}m
# Set the background color to index M: \033[48;5;${M}m
# To make vim aware of a present 256 color extension, you can either set
# the $TERM environment variable to xterm-256color or use vim's -T option
# to set the terminal. I'm using an alias in my bashrc to do this. At the
# moment I only know of two color schemes which is made for multi-color
# terminals like urxvt (88 colors) or xterm: inkpot and desert256,
### if term support colors, then use color prompt, else bold
black='\['`tput sgr0; tput setaf 0`'\]'
red='\['`tput sgr0; tput setaf 1`'\]'
green='\['`tput sgr0; tput setaf 2`'\]'
yellow='\['`tput sgr0; tput setaf 3`'\]'
blue='\['`tput sgr0; tput setaf 4`'\]'
magenta='\['`tput sgr0; tput setaf 5`'\]'
cyan='\['`tput sgr0; tput setaf 6`'\]'
white='\['`tput sgr0; tput setaf 7`'\]'
BLACK='\['`tput setaf 0; tput bold`'\]'
RED='\['`tput setaf 1; tput bold`'\]'
GREEN='\['`tput setaf 2; tput bold`'\]'
YELLOW='\['`tput setaf 3; tput bold`'\]'
BLUE='\['`tput setaf 4; tput bold`'\]'
MAGENTA='\['`tput setaf 5; tput bold`'\]'
CYAN='\['`tput setaf 6; tput bold`'\]'
WHITE='\['`tput setaf 7; tput bold`'\]'
dim='\['`tput sgr0; tput setaf p1`'\]' # half-bright
bw_bold='\['`tput bold`'\]'
on=''
off=': '
bell="\[`eval ${!error_bell} tput bel`\]"
colors_reset='\['`tput sgr0`'\]'
# replace symbolic colors names to raw treminfo strings
init_vcs_color=${!init_vcs_color}
modified_vcs_color=${!modified_vcs_color}
untracked_vcs_color=${!untracked_vcs_color}
clean_vcs_color=${!clean_vcs_color}
added_vcs_color=${!added_vcs_color}
op_vcs_color=${!op_vcs_color}
addmoded_vcs_color=${!addmoded_vcs_color}
detached_vcs_color=${!detached_vcs_color}
hex_vcs_color=${!hex_vcs_color}
unset PROMPT_COMMAND
####### work around for MC bug.
####### specifically exclude emacs, want full when running inside emacs
if [[ -z "$TERM" || ("$TERM" = "dumb" && -z "$INSIDE_EMACS") || -n "$MC_SID" ]]; then
unset PROMPT_COMMAND
PS1="\w$prompt_char "
return 0
fi
#################################################################### MARKERS
screen_marker="sCRn"
if [[ $LC_CTYPE =~ "UTF" && $TERM != "linux" ]]; then
elipses_marker="…"
else
elipses_marker="..."
fi
export who_where
cwd_truncate() {
# based on: https://www.blog.montgomerie.net/pwd-in-the-title-bar-or-a-regex-adventure-in-bash
# arg1: max path lenght
# returns abbrivated $PWD in public "cwd" var
cwd=${PWD/$HOME/\~} # substitute "~"
case $1 in
full)
return
;;
last)
cwd=${PWD##/*/}
[[ $PWD == $HOME ]] && cwd="~"
return
;;
*)
# if bash < v3.2 then don't truncate
if [[ ${BASH_VERSINFO[0]} -eq 3 && ${BASH_VERSINFO[1]} -le 1 || ${BASH_VERSINFO[0]} -lt 3 ]] ; then
return
fi
;;
esac
# split path into: head='~/', truncateble middle, last_dir
local cwd_max_length=$1
# expression which bash-3.1 or older can not understand, so we wrap it in eval
exp31='[[ "$cwd" =~ (~?/)(.*/)([^/]*)$ ]]'
if eval $exp31 ; then # only valid if path have more then 1 dir
local path_head=${BASH_REMATCH[1]}
local path_middle=${BASH_REMATCH[2]}
local path_last_dir=${BASH_REMATCH[3]}
local cwd_middle_max=$(( $cwd_max_length - ${#path_last_dir} ))
[[ $cwd_middle_max < 0 ]] && cwd_middle_max=0
# trunc middle if over limit
if [[ ${#path_middle} -gt $(( $cwd_middle_max + ${#elipses_marker} + 5 )) ]]; then
# truncate
middle_tail=${path_middle:${#path_middle}-${cwd_middle_max}}
# trunc on dir boundary (trunc 1st, probably tuncated dir)
exp31='[[ $middle_tail =~ [^/]*/(.*)$ ]]'
eval $exp31
middle_tail=${BASH_REMATCH[1]}
# use truncated only if we cut at least 4 chars
if [[ $(( ${#path_middle} - ${#middle_tail})) -gt 4 ]]; then
cwd=$path_head$elipses_marker$middle_tail$path_last_dir
fi
fi
fi
return
}
set_shell_label() {
xterm_label() {
local args="$*"
echo -n "]2;${args:0:200}" ; # FIXME: replace hardcodes with terminfo codes
}
screen_label() {
# FIXME: run this only if screen is in xterm (how to test for this?)
xterm_label "$screen_marker $plain_who_where $@"
# FIXME $STY not inherited though "su -"
[ "$STY" ] && screen -S $STY -X title "$*"
}
if [[ -n "$STY" ]]; then
screen_label "$*"
else
case $TERM in
screen*)
screen_label "$*"
;;
xterm* | rxvt* | gnome-terminal | konsole | eterm | wterm )
# is there a capability which we can to test
# for "set term title-bar" and its escapes?
xterm_label "$plain_who_where $@"
;;
*)
;;
esac
fi
}
export -f set_shell_label
###################################################### ID (user name)
id=`id -un`
id=${id#$default_user}
########################################################### TTY
tty=`tty`
tty=`echo $tty | sed "s:/dev/pts/:p:; s:/dev/tty::" ` # RH tty devs
tty=`echo $tty | sed "s:/dev/vc/:vc:" ` # gentoo tty devs
if [[ "$TERM" = "screen" ]] ; then
# [ "$WINDOW" = "" ] && WINDOW="?"
#
# # if under screen then make tty name look like s1-p2
# # tty="${WINDOW:+s}$WINDOW${WINDOW:+-}$tty"
# tty="${WINDOW:+s}$WINDOW" # replace tty name with screen number
tty="$WINDOW" # replace tty name with screen number
fi
# we don't need tty name under X11
case $TERM in
xterm* | rxvt* | gnome-terminal | konsole | eterm* | wterm | cygwin) unset tty ;;
*);;
esac
dir_color=${!dir_color}
rc_color=${!rc_color}
user_id_color=${!user_id_color}
root_id_color=${!root_id_color}
########################################################### HOST
### we don't display home host/domain $SSH_* set by SSHD or keychain
# How to find out if session is local or remote? Working with "su -", ssh-agent, and so on ?
## is sshd our parent?
# if { for ((pid=$$; $pid != 1 ; pid=`ps h -o pid --ppid $pid`)); do ps h -o command -p $pid; done | grep -q sshd && echo == REMOTE ==; }
#then
host=${HOSTNAME}
if [[ $short_hostname = "on" ]]; then
host=`hostname -s`
fi
host=${host#$default_host}
uphost=`echo ${host} | tr a-z A-Z`
if [[ $upcase_hostname = "on" ]]; then
host=${uphost}
fi
host_color=${uphost}_host_color
host_color=${!host_color}
if [[ -z $host_color && -x /usr/bin/cksum ]] ; then
cksum_color_no=`echo $uphost | cksum | awk '{print $1%7}'`
color_index=(green yellow blue magenta cyan white) # FIXME: bw, color-256
host_color=${color_index[cksum_color_no]}
fi
host_color=${!host_color}
# we might already have short host name
host=${host%.$default_domain}
#################################################################### WHO_WHERE
# [[user@]host[-tty]]
if [[ -n $id || -n $host ]] ; then
[[ -n $id && -n $host ]] && at='@' || at=''
color_who_where="${id}${host:+$host_color$at$host}${tty:+ $tty}"
plain_who_where="${id}$at$host"
# add trailing " "
color_who_where="$color_who_where "
plain_who_where="$plain_who_where "
# if root then make it root_color
if [ "$id" == "root" ] ; then
user_id_color=$root_id_color
prompt_char="$root_prompt_char"
fi
color_who_where="$user_id_color$color_who_where$colors_reset"
else
color_who_where=''
fi
parse_svn_status() {
[[ -d .svn ]] || return 1
vcs=svn
### get rev
eval `
svn info |
sed -n "
s@^URL[^/]*//@repo_dir=@p
s/^Revision: /rev=/p
"
`
### get status
unset status modified added clean init added mixed untracked op detached
eval `svn status 2>/dev/null |
sed -n '
s/^A... \([^.].*\)/modified=modified; modified_files[${#modified_files[@]}]=\"\1\";/p
s/^M... \([^.].*\)/modified=modified; modified_files[${#modified_files[@]}]=\"\1\";/p
s/^\?... \([^.].*\)/untracked=untracked; untracked_files[${#untracked_files[@]}]=\"\1\";/p
'
`
# TODO branch detection if standard repo layout
[[ -z $modified ]] && [[ -z $untracked ]] && clean=clean
vcs_info=svn:r$rev
}
parse_hg_status() {
# ☿
[[ -d ./.hg/ ]] || return 1
vcs=hg
### get status
unset status modified added clean init added mixed untracked op detached
eval `hg status 2>/dev/null |
sed -n '
s/^M \([^.].*\)/modified=modified; modified_files[${#modified_files[@]}]=\"\1\";/p
s/^A \([^.].*\)/added=added; added_files[${#added_files[@]}]=\"\1\";/p
s/^R \([^.].*\)/added=added;/p
s/^! \([^.].*\)/modified=modified;/p
s/^? \([^.].*\)/untracked=untracked; untracked_files[${#untracked_files[@]}]=\\"\1\\";/p
'`
branch=`hg branch 2> /dev/null`
[[ -z $modified ]] && [[ -z $untracked ]] && [[ -z $added ]] && clean=clean
vcs_info=${branch/default/D}
}
parse_git_status() {
# TODO add status: LOCKED (.git/index.lock)
git_dir=`[[ $git_module = "on" ]] && git rev-parse --git-dir 2> /dev/null`
#git_dir=`eval \$$git_module git rev-parse --git-dir 2> /dev/null`
#git_dir=` git rev-parse --git-dir 2> /dev/null`
[[ -n ${git_dir/./} ]] || return 1
vcs=git
########################################################## GIT STATUS
file_regex='\([^/ ]*\/\{0,1\}\).*'
added_files=()
modified_files=()
untracked_files=()
freshness="$dim"
unset branch status modified added clean init added mixed untracked op detached
# quoting hell
eval " $(
git status 2>/dev/null |
sed -n '
s/^# On branch /branch=/p
s/^nothing to commi.*/clean=clean/p
s/^# Initial commi.*/init=init/p
s/^# Your branch is ahead of .[/[:alnum:]]\+. by [[:digit:]]\+ commit.*/freshness=${WHITE}↑/p
s/^# Your branch is behind .[/[:alnum:]]\+. by [[:digit:]]\+ commit.*/freshness=${YELLOW}↓/p
s/^# Your branch and .[/[:alnum:]]\+. have diverged.*/freshness=${YELLOW}↕/p
/^# Changes to be committed:/,/^# [A-Z]/ {
s/^# Changes to be committed:/added=added;/p
s/^# modified: '"$file_regex"'/ [[ \" ${added_files[*]} \" =~ \" \1 \" ]] || added_files[${#added_files[@]}]=\"\1\"/p
s/^# new file: '"$file_regex"'/ [[ \" ${added_files[*]} \" =~ \" \1 \" ]] || added_files[${#added_files[@]}]=\"\1\"/p
s/^# renamed:[^>]*> '"$file_regex"'/ [[ \" ${added_files[*]} \" =~ \" \1 \" ]] || added_files[${#added_files[@]}]=\"\1\"/p
s/^# copied:[^>]*> '"$file_regex"'/ [[ \" ${added_files[*]} \" =~ \" \1 \" ]] || added_files[${#added_files[@]}]=\"\1\"/p
}
/^# Changed but not updated:/,/^# [A-Z]/ {
s/^# Changed but not updated:/modified=modified;/p
s/^# modified: '"$file_regex"'/ [[ \" ${modified_files[*]} \" =~ \" \1 \" ]] || modified_files[${#modified_files[@]}]=\"\1\"/p
s/^# unmerged: '"$file_regex"'/ [[ \" ${modified_files[*]} \" =~ \" \1 \" ]] || modified_files[${#modified_files[@]}]=\"\1\"/p
}
/^# Changes not staged for commit:/,/^# [A-Z]/ {
s/^# Changes not staged for commit:/modified=modified;/p
s/^# modified: '"$file_regex"'/ [[ \" ${modified_files[*]} \" =~ \" \1 \" ]] || modified_files[${#modified_files[@]}]=\"\1\"/p
s/^# unmerged: '"$file_regex"'/ [[ \" ${modified_files[*]} \" =~ \" \1 \" ]] || modified_files[${#modified_files[@]}]=\"\1\"/p
}
/^# Unmerged paths:/,/^[^#]/ {
s/^# Unmerged paths:/modified=modified;/p
s/^# both modified:\s*'"$file_regex"'/ [[ \" ${modified_files[*]} \" =~ \" \1 \" ]] || modified_files[${#modified_files[@]}]=\"\1\"/p
}
/^# Untracked files:/,/^[^#]/{
s/^# Untracked files:/untracked=untracked;/p
s/^# '"$file_regex"'/ [[ \" ${untracked_files[*]} ${modified_files[*]} ${added_files[*]} \" =~ \" \1 \" ]] || untracked_files[${#untracked_files[@]}]=\"\1\"/p
}
'
)"
if ! grep -q "^ref:" $git_dir/HEAD 2>/dev/null; then
detached=detached
fi
################# GET GIT OP
unset op
if [[ -d "$git_dir/.dotest" ]] ; then
if [[ -f "$git_dir/.dotest/rebasing" ]] ; then
op="rebase"
elif [[ -f "$git_dir/.dotest/applying" ]] ; then
op="am"
else
op="am/rebase"
fi
elif [[ -f "$git_dir/.dotest-merge/interactive" ]] ; then
op="rebase -i"
# ??? branch="$(cat "$git_dir/.dotest-merge/head-name")"
elif [[ -d "$git_dir/.dotest-merge" ]] ; then
op="rebase -m"
# ??? branch="$(cat "$git_dir/.dotest-merge/head-name")"
# lvv: not always works. Should ./.dotest be used instead?
elif [[ -f "$git_dir/MERGE_HEAD" ]] ; then
op="merge"
# ??? branch="$(git symbolic-ref HEAD 2>/dev/null)"
elif [[ -f "$git_dir/index.lock" ]] ; then
op="locked"
else
[[ -f "$git_dir/BISECT_LOG" ]] && op="bisect"
# ??? branch="$(git symbolic-ref HEAD 2>/dev/null)" || \
# branch="$(git describe --exact-match HEAD 2>/dev/null)" || \
# branch="$(cut -c1-7 "$git_dir/HEAD")..."
fi
#### GET GIT HEX-REVISION
if [[ $rawhex_len -gt 0 ]] ; then
rawhex=`git rev-parse HEAD 2>/dev/null`
rawhex=${rawhex/HEAD/}
rawhex="=$hex_vcs_color${rawhex:0:$rawhex_len}"
else
rawhex=""
fi
#### branch
branch=${branch/master/M}
# another method of above:
# branch=$(git symbolic-ref -q HEAD || { echo -n "detached:" ; git name-rev --name-only HEAD 2>/dev/null; } )
# branch=${branch#refs/heads/}
### compose vcs_info
if [[ $init ]]; then
vcs_info=${white}init
else
if [[ "$detached" ]] ; then
branch="<detached:`git name-rev --name-only HEAD 2>/dev/null`"
elif [[ "$op" ]]; then
branch="$op:$branch"
if [[ "$op" == "merge" ]] ; then
branch+="<--$(git name-rev --name-only $(<$git_dir/MERGE_HEAD))"
fi
#branch="<$branch>"
fi
vcs_info="$branch$freshness$rawhex"
fi
}
parse_vcs_status() {
unset file_list modified_files untracked_files added_files
unset vcs vcs_info
unset status modified untracked added init detached
unset file_list modified_files untracked_files added_files
[[ $vcs_ignore_dir_list =~ $PWD ]] && return
eval $PARSE_VCS_STATUS
### status: choose primary (for branch color)
unset status
status=${op:+op}
status=${status:-$detached}
status=${status:-$clean}
status=${status:-$modified}
status=${status:-$added}
status=${status:-$untracked}
status=${status:-$init}
# at least one should be set
: ${status?prompt internal error: git status}
eval vcs_color="\${${status}_vcs_color}"
# no def: vcs_color=${vcs_color:-$WHITE} # default
### VIM
if [[ $vim_module = "on" ]] ; then
# equivalent to vim_glob=`ls .*.vim` but without running ls
unset vim_glob vim_file vim_files
old_nullglob=`shopt -p nullglob`
shopt -s nullglob
vim_glob=`echo .*.sw?`
eval $old_nullglob
if [[ $vim_glob ]]; then
set $vim_glob
#vim_file=${vim_glob#.}
if [[ $# > 1 ]] ; then
vim_files="*"
else
vim_file=${1#.}
vim_file=${vim_file/.sw?/}
[[ .${vim_file}.swp -nt $vim_file ]] && vim_files=$vim_file
fi
# if swap is newer, then this is unsaved vim session
# [temoto custom] if swap is older, then it must be deleted, so show all swaps.
fi
fi
### file list
unset file_list
if [[ $count_only = "on" ]] ; then
[[ ${added_files[0]} ]] && file_list+=" "${added_vcs_color}+${#added_files[@]}
[[ ${modified_files[0]} ]] && file_list+=" "${modified_vcs_color}*${#modified_files[@]}
[[ ${untracked_files[0]} ]] && file_list+=" "${untracked_vcs_color}?${#untracked_files[@]}
else
[[ ${added_files[0]} ]] && file_list+=" "$added_vcs_color${added_files[@]}
[[ ${modified_files[0]} ]] && file_list+=" "$modified_vcs_color${modified_files[@]}
[[ ${untracked_files[0]} ]] && file_list+=" "$untracked_vcs_color${untracked_files[@]}
fi
[[ ${vim_files} ]] && file_list+=" "${MAGENTA}vim:${vim_files}
if [[ ${#file_list} -gt $max_file_list_length ]] ; then
file_list=${file_list:0:$max_file_list_length}
if [[ $max_file_list_length -gt 0 ]] ; then
file_list="${file_list% *} $elipses_marker"
fi
fi
head_local="$vcs_color(${vcs_info}$vcs_color${file_list}$vcs_color)"
### fringes
head_local="${head_local+$vcs_color$head_local }"
#above_local="${head_local+$vcs_color$head_local\n}"
#tail_local="${tail_local+$vcs_color $tail_local}${dir_color}"
}
disable_set_shell_label() {
trap - DEBUG >& /dev/null
}
# show currently executed command in label
enable_set_shell_label() {
disable_set_shell_label
# check for BASH_SOURCE being empty, no point running set_shell_label on every line of .bashrc
trap '[[ -z "$BASH_SOURCE" && ($BASH_COMMAND != prompt_command_function) ]] &&
set_shell_label $BASH_COMMAND' DEBUG >& /dev/null
}
declare -ft disable_set_shell_label
declare -ft enable_set_shell_label
# autojump (see http://wiki.github.com/joelthelion/autojump)
# TODO reverse the line order of a file
#awk ' { line[NR] = $0 }
# END { for (i=NR;i>0;i--)
# print line[i] }' listlogs
j (){
: ${1? usage: j dir-beginning}
# go in ring buffer starting from current index. cd to first matching dir
for (( i=(aj_idx-1)%aj_max; i != aj_idx%aj_max; i=(--i+aj_max)%aj_max )) ; do
if [[ ${aj_dir_list[$i]} =~ ^.*/$1[^/]*$ ]] ; then
cd "${aj_dir_list[$i]}"
return
fi
done
echo '?'
}
alias jumpstart='echo ${aj_dir_list[@]}'
###################################################################### PROMPT_COMMAND
prompt_command_function() {
rc="$?"
if [[ "$rc" == "0" ]]; then
rc=""
else
rc="$rc_color$rc$colors_reset$bell "
fi
cwd=${PWD/$HOME/\~} # substitute "~"
set_shell_label "${cwd##[/~]*/}/" # default label - path last dir
parse_vcs_status
# autojump
if [[ ${aj_dir_list[aj_idx%aj_max]} != $PWD ]] ; then
aj_dir_list[++aj_idx%aj_max]="$PWD"
fi
# if cwd_cmd have back-slash, then assign it value to cwd
# else eval cwd_cmd, cwd should have path after exection
eval "${cwd_cmd/\\/cwd=\\\\}"
PS1="$colors_reset$rc$head_local$color_who_where$dir_color$cwd$tail_local$dir_color$prompt_char $colors_reset"
unset head_local tail_local pwd
}
PROMPT_COMMAND=prompt_command_function
enable_set_shell_label
unset rc id tty modified_files file_list
# vim: set ft=sh ts=8 sw=8 et:

View File

@@ -4,7 +4,7 @@ set -x
VARTEMP=/tmp/var VARTEMP=/tmp/var
VARPERSISTENT=/var VARPERSISTENT=/var
VARDIRS="cache" VARDIRS="cache log/fhem"
BINDDIRS="cache lock run" BINDDIRS="cache lock run"
case $1 in case $1 in
@@ -14,7 +14,8 @@ case $1 in
for f in $VARDIRS for f in $VARDIRS
do do
rsync -av $VARPERSISTENT/$f.bak/ $VARTEMP/$f fbase=$(basename $f)
rsync -av $VARPERSISTENT/$fbase.bak/ $VARTEMP/$f
done done
for f in $BINDDIRS for f in $BINDDIRS
@@ -27,7 +28,8 @@ case $1 in
echo "saving var-directory from temp to flash" echo "saving var-directory from temp to flash"
for f in $VARDIRS for f in $VARDIRS
do do
[ -d $VARTEMP/$f ] && rsync -av $VARTEMP/$f/ $VARPERSISTENT/$f.bak fbase=$(basename $f)
[ -d $VARTEMP/$f ] && rsync -av $VARTEMP/$f/ $VARPERSISTENT/$fbase.bak
done done
;; ;;
esac esac

10
instapaper_epub.sh Normal file
View File

@@ -0,0 +1,10 @@
#!/bin/bash
Username="MarcHoppe@gmx.de"
Password="insta0815"
Docs=~/Documents
OutputDir=~/Documents/ePub
curl --cookie-jar ${Docs}/cjar --data "username=$Username" -d "password=${Password}" --output ${Docs}/insta.html http://www.instapaper.com/user/login
curl -b ${Docs}/cjar --output ${OutputDir}/insta.epub http://www.instapaper.com/epub
rm -f ${Docs}/cjar ${Docs}/insta.html

12
ipad.sh
View File

@@ -1,3 +1,5 @@
#!/bin/bash
ipaddir=/dat/ipad ipaddir=/dat/ipad
@@ -40,9 +42,9 @@ do
done done
# Podcasts # Podcasts
filedir="/dat/mp3/podcast/cache" #filedir="/dat/mp3/podcast/cache"
dstdir=$ipaddir/ #dstdir=$ipaddir/
ln -s $filedir $dstdir/podcast #ln -s $filedir $dstdir/podcast
# Musik # Musik
linkdir=$ipaddir/music linkdir=$ipaddir/music
@@ -90,7 +92,7 @@ done
dstdir=$ipaddir/bilder dstdir=$ipaddir/bilder
srcdir=/dat/bilder srcdir=/dat/bilder
#[ -d $dstdir ] || mkdir -p $dstdir [ -d $dstdir ] || mkdir -p $dstdir
cd $dstdir || exit cd $dstdir || exit
[ "$dstdir" != "" ] && rm -r * [ "$dstdir" != "" ] && rm -r *
@@ -99,6 +101,8 @@ find $srcdir -name ipad -print0 | while read -d $'\0' f
do do
fileindir=$f fileindir=$f
linkdest=$(dirname "$fileindir") linkdest=$(dirname "$fileindir")
echo "adding: $f"
ln -s "$linkdest"
#[ -x "$artist/$album" ] || ln -s "$linkdest" "$artist/$album" #[ -x "$artist/$album" ] || ln -s "$linkdest" "$artist/$album"
done done

10
iso2utf.sh Executable file
View File

@@ -0,0 +1,10 @@
#!/bin/bash
set -x
file_iso=$1
file_utf=${file_iso}.utf8
[ -f $file_iso ] || exit
iconv --from-code=ISO-8859-1 --to-code=UTF-8 $file_iso > $file_utf

25
m4a2ogg.sh Normal file
View File

@@ -0,0 +1,25 @@
#!/bin/bash
#
# m4a to ogg
i=$1
tmp=$(mktemp)
y=`echo "$i"|sed -e 's/.m4a/.ogg/'`
faad -i "$i" 1>/dev/null 2>"$tmp"
if [ $? -ne 0 ] ; then
rm "$tmp"
echo "failed to get information from $i"
continue
fi
title=`grep 'title: ' "$tmp"|sed -e 's/title: //'`
artist=`grep 'artist: ' "$tmp"|sed -e 's/artist: //'`
album=`grep 'album: ' "$tmp"|sed -e 's/album: //'`
genre=`grep 'genre: ' "$tmp"|sed -e 's/genre: //'`
track=`grep 'track: ' "$tmp"|sed -e 's/track: //'`
year=`grep 'year: ' "$tmp"|sed -e 's/date: //'`
faad "$i" -o - | oggenc -q 4 -t "$title" -a "$artist" -l "$album" -G "$genre" -N "$track" -d "$year" -o "$y" -
if [ $? -ne 0 ] ; then
echo "failed to encode $i"
fi
rm "$tmp"

15
mirrors.update Normal file
View File

@@ -0,0 +1,15 @@
#!/bin/bash
fhemdir=/home/marc/src/fhem
fhem_mirror=$fhemdir/fhem-git
myfhem=$fhemdir/my
cd $fhem_mirror
git svn rebase
#git merge remotes/git-svn
git push github master
#cd $myfhem
#git fetch origin
#git push github master

29
mkosm.sh Normal file
View File

@@ -0,0 +1,29 @@
#!/bin/bash
set -x
mapfile=$1
splitter=../splitter.jar
mkgmap=../mkgmap.jar
mapid=65241345
country_name=greece
sudo swapon /dat/tmp/swap.img
#wget http://download.geofabrik.de/osm/europe/germany/$mapfile.bz2
#bunzip $mapfile.bz2
mkdir tiles
rm -r tiles/*
cd tiles/
java -Xmx5000M -jar $splitter --mapid=$mapid --max-nodes=500000 ../$mapfile
cd ..
mkdir gbasemap
rm -r gbasemap/*
cd gbasemap
java -Xmx5000M -jar $mkgmap --style-file=../styles/masterstyle --description='Openstreetmap' --country-name=$country_name --country-abbr=GR --family-id=3 --product-id=45 --series-name='master-edition' --family-name=OSM --area-name=GR --latin1 --lower-case --mapname=$mapid --draw-priority=10 --add-pois-to-areas --road-name-pois --net --route --gmapsupp ../tiles/*.osm.gz /home/marc/osm/styles/master.TYP
sudo swapoff /dat/tmp/swap.img

7
mkvdrrecdir.sh Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/bash
#set -x
RECORDING_LIFETIME=99
RECORDING="$(date +%Y-%m-%d.%H.%M).99.$RECORDING_LIFETIME.rec"
mkdir $RECORDING

85
mp32wav Executable file
View File

@@ -0,0 +1,85 @@
#!/bin/bash
#
# /usr/local/bin/mp3tocd -- mp3-Files nach wav oder au umwandeln
# und brennen.
# Das Format 44100 Hz, 16Bit Stereo ist notwendig, siehe Text
#
# mp32wav mp3dir wavdir
set -x
function usage ()
{
echo "
mp32wav mp3dir wavdir
mp3dir: Verzeichnis, in dem die mp3-Dateien gepseichert sind.
wavdir: Verzeichnis, in das die erzeugten wave-Dateien geschrieben werden"
}
function yesno ()
{
while true; do
read ans
case "$ans" in
y|Y|j|J|[yY]es|[jJ]a)
return 1
;;
n|N|[nN]o|[nN]ein)
return 0
;;
*)
echo -e '\a\nVertipper. (j,ja,y,yes/n,nein,no)'
;;
esac
done
}
if ! test -d "$1"; then
usage
fi
if ! test -d "$2"; then
usage
fi
mp3dir="$1"
wavdir="$2"
#pushd $destdir > /dev/null
let count=0
for i in "$mp3dir"/*.mp3; do
echo "$i wird decodiert"
## Der Umstand mit der fuehrenden Null in der 'if'-Abfrage bewirkt,
## dass (maximal) 100 Tracks in der richtigen Reihenfolge gebrannt
## werden
if test "$count" -le 9; then
track=""0$count"track.wav"
else
track=""$count"track.wav"
fi
trakfile="$i"
echo Datei1 "$trakfile"
track=$(basename "$i" .mp3).wav
echo Datei2 "$track"
mpg123 -v -s -r 44100 --stereo --wav "$wavdir"/"$track" "$i"
let count=$(expr $count + 1)
done
echo -e "\n erzeugte Tracks:"
ls -l "$wavdir"/[0-9][0-9]*.wav
echo "KByte insgesamt: $(du -kc "$wavdir"/[0-9][0-9]*.wav | tail -n 1 | awk '{print $1}')"
#echo "
#Brennen durchfuehren (j,y,ja,yes/n,nein,no)?"
#if ! yesno; then
#cdrecord -v -speed=$speed $blank -pad dev=$wdev -audio [0-9][0-9]track.$format
# popd > /dev/null
# rm -R $destdir
#else
# echo "Die Tracks in $destdir wurden nicht geloescht"
#fi

13
podcastupdate.sh Executable file
View File

@@ -0,0 +1,13 @@
#!/bin/sh
LOGFILE=/tmp/podcatcher.log
set -x
sleep
#swapon /dat/tmp/swap.img
svdrpsend MESG "Podcasts aktualisieren-gestarted"
cd /mp3/podcast
echo "start ----------------------------" >> $LOGFILE
date >> $LOGFILE
./catch.sh >> $LOGFILE 2>&1
svdrpsend MESG "Podcasts aktualisiert"
#swapoff /dat/tmp/swap.img

3
podcastupdated.sh Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/sh
echo "/usr/local/bin/podcastupdate.sh" | at now

16
queue Executable file
View File

@@ -0,0 +1,16 @@
#!/bin/bash
qfile=/tmp/queue.commands
if [ "$1" = "-list" ]; then
cat $qfile
exit
fi
echo $* >> $qfile
lines=$(cat $qfile | wc -l)
if [ $lines -eq 1 ]; then
nohup /usr/local/bin/unqueue $qfile &
fi

5
recwebradio.sh Normal file
View File

@@ -0,0 +1,5 @@
#!/bin/bash
t1=$1
t2=$2

17
rmdvbmodules.sh Normal file
View File

@@ -0,0 +1,17 @@
#!/bin/bash
sudo rmmod budget_ci
sudo rmmod tda1004x
sudo rmmod dvb_ttpci
sudo rmmod stv0299
sudo rmmod ves1x93
sudo rmmod rc_hauppauge
sudo rmmod saa7146_vv
sudo rmmod videodev
sudo rmmod budget_core
sudo rmmod dvb_core
sudo rmmod v4l2_compat_ioctl32
sudo rmmod videobuf_dma_sg
sudo rmmod saa7146
sudo rmmod ttpci_eeprom
sudo rmmod v4l1_compat

1
start_dropbox.sh Normal file
View File

@@ -0,0 +1 @@
HOME=/home/marc/.dropbox-ipad/ nohup .dropbox-dist/dropbox start

862
sync_pod.pl Executable file
View File

@@ -0,0 +1,862 @@
#!/usr/bin/perl -w
# (c) 2002 Armin Obersteiner <armin@xos.net>
# License: GPL v2
use MP3::Info;
use Unicode::String qw( latin1 utf16 );
use Shell qw ( find gzip );
use Getopt::Std;
use File::Copy;
use Filesys::DiskFree;
use Data::Dumper qw (Dumper);
use strict;
my $version="0.68";
#
# options & config
#
my %opt;
getopts("fcnh",\%opt);
if($opt{h}) {
print <<"EOF";
$0 [-c] [-f] [Search Pattern 1] [Search Pattern 2] ...
-c create: create directory structure on plain ipod before syncing
(default: you get a warning if there is no ipod structure)
-f force: rename ipod and use it with $0 before syncing
(default: an unknown ipod stays untouched)
-n name check: checks mp3 names for possible illegal characters
Search Patterns: for each search pattern a playlist is created
(case insensitive)
EOF
exit;
}
my $buffer = 5*1024*1024; # leave some MB free for iTunesDB
my @required = qw ( SYNCMODE PLAYLISTDIR IPODDIR BACKUPDIR );
my $rc=readrc("$ENV{HOME}/.ipod/config",\@required);
#print Dumper($rc);
#
# check ipod name
#
my ($ipod_name, $real_name, $computer_name)=get_ipodname($rc->{IPODDIR});
unless($ipod_name) {
die "IPOD dir not found: $rc->{IPODDIR}" unless $opt{c};
}
#
# check ipod dirs (recreate them if necessary)
#
mkdir "$rc->{IPODDIR}/iPod_Control",0755 unless(-d "$rc->{IPODDIR}/iPod_Control");
mkdir "$rc->{IPODDIR}/iPod_Control/Music",0755 unless(-d "$rc->{IPODDIR}/iPod_Control/Music");
mkdir "$rc->{IPODDIR}/iPod_Control/iTunes",0755 unless(-d "$rc->{IPODDIR}/iPod_Control/iTunes");
mkdir "$rc->{IPODDIR}/iPod_Control/Device",0755 unless(-d "$rc->{IPODDIR}/iPod_Control/Device");
for(0..19) {
my $d=sprintf "%.2d",$_;
mkdir "$rc->{IPODDIR}/iPod_Control/Music/F$d",0755 unless(-d "$rc->{IPODDIR}/iPod_Control/Music/F$d");
}
unless($opt{c}) {
print STDERR "IPOD name: $ipod_name\n";
print STDERR "Synced by: $real_name\n";
print STDERR "Synced on: $computer_name\n";
if($rc->{WRITEDEVICEINFO} && !$opt{f}) {
my $exit=0;
unless($rc->{IPODNAME} eq $ipod_name) {
$exit=1;
print STDERR "Your IPOD name: $rc->{IPODNAME}\n";
}
unless($rc->{REALNAME} eq $real_name) {
$exit=1;
print STDERR "Your real name: $rc->{REALNAME}\n";
}
unless($rc->{COMPUTERNAME} eq $computer_name) {
$exit=1;
print STDERR "Your computer: $rc->{COMPUTERNAME}\n";
}
die "names mismatch, use -f to override" if $exit;
}
print STDERR "\n";
}
#
# write ipod name
#
if($rc->{WRITEDEVICEINFO}) {
set_ipodname(
$rc->{IPODDIR},$rc->{BACKUPDIR},
$rc->{IPODNAME},$rc->{REALNAME},$rc->{COMPUTERNAME}
);
$ipod_name=$rc->{IPODNAME};
}
#
# check for songs
#
my %songs;
my %check;
my $dir;
$dir=$rc->{IPODDIR}."/iPod_Control/Music";
$dir=$rc->{SYNCDIR} if($rc->{SYNCMODE} >= 2);
my %tosync;
if(($rc->{SYNCLIST}) && ($rc->{SYNCMODE} == 2)) {
open IN,$rc->{SYNCLIST} or die "all-playlist: $rc->{SYNCLIST} not found";
while(<IN>) {
chomp;
$tosync{$_}=1;
}
close IN;
}
my @mp3s;
if(($rc->{SYNCMODE} == 3)) {
my @pl=find("$rc->{PLAYLISTDIR}/* 2>/dev/null");
my %test;
for my $p (@pl) {
chomp $p;
my ($n) = $p =~ /.*\/(.*?)$/;
open IN,$p or die "playlist: $p could not be opened";
while(<IN>) {
unless($test{$_}) {
push @mp3s,$_;
$test{$_}=1;
}
}
}
} else {
@mp3s=find($dir);
}
for(@mp3s) {
chomp $_;
next unless(/\.(m|M)(p|P)3$/);
my $name=$_;
if(keys %tosync) {
next unless($tosync{$name});
}
if($opt{n}) {
die "illegal character in filename [$name]\n" unless ($name =~ /^[A-Za-z0-9\.\-_\/\,]+$/);
}
s/\://g;
s/.*\///g;
$songs{$name}{name}=$_;
if($rc->{SYNCMODE} >= 2) {
$songs{$name}{dir}="F".hash($_);
} else {
($songs{$name}{dir}) = $name =~ /\/(F\d\d)\//;
}
{
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks) = stat($name);
$songs{$name}{size}=$size;
$songs{$name}{date}=$mtime;
}
my $tag;
$tag = get_mp3tag($name) unless($rc->{ALWAYSTEMPLATES});
my ($artist,$album,$title,$order,$_dummy_);
if($tag) {
# print Dumper($tag);
# YEAR ARTIST COMMENT TRACKNUM TITLE ALBUM GENRE
$artist=$tag->{ARTIST};
$album=$tag->{ALBUM};
$title=$tag->{TITLE};
$order=$tag->{TRACKNUM};
$order=$1 if($order =~ /(\d+)\s*\//);
} else {
for(sort {length($b) <=> length($a)} keys %{$rc->{FILETEMPLATES}}) {
if(my @x = $name =~ /$_/) {
my $c=0;
for my $x (@x) {
#print "\$$rc->{FILETEMPLATES}->{$_}->[$c]=\"$x\";\n";
eval "\$$rc->{FILETEMPLATES}->{$_}->[$c]=\"$x\";";
die "eval error: $@" if($@);
$c++;
}
last;
}
}
}
unless($title) {
die "no title found in: $name";
}
$title =~ s/_/ /g;
$artist =~ s/_/ /g;
$album =~ s/_/ /g;
$songs{$name}{title}=$title;
$songs{$name}{artist}="";
$songs{$name}{album}="";
$songs{$name}{order}=0;
$songs{$name}{artist}=$artist if $artist;
$songs{$name}{album}=$album if $album;
$songs{$name}{order}=$order if $order;
my $info = get_mp3info ($name);
$songs{$name}{size}=$info->{SIZE};
$songs{$name}{bitrate}=$info->{BITRATE};
$songs{$name}{duration}=int($info->{SECS}*1000);
$songs{$name}{vbr}=$info->{VBR};
#print Dumper($info);
my $n=$songs{$name}{dir}."/".$songs{$name}{name};
unless($check{$n}) {
$check{$n}=1;
} else {
die "songname: $songs{$name}{name} not unique";
}
}
#
# deleting unwanted songs
#
my %known;
for(keys %songs) {
$known{$songs{$_}{name}}=1;
}
#print Dumper(\%known);
my @ipod = find ("$rc->{IPODDIR}/iPod_Control/Music");
my @todel;
for(@ipod) {
next unless (/\.mp3$/i);
chomp;
my ($name) = $_ =~ /\/([^\/]+\.mp3)$/i;
unless($known{$name}) {
push @todel,$_;
}
}
my $del;
if($rc->{DELETEASK} && @todel) {
for(@todel) {
print "del: $_\n";
}
print "Do you really want to delete this songs? (y/N) ";
my $in=<STDIN>;
chomp $in;
$del=1 if($in =~ /^y$/i);
} else {
$del=1;
}
if($del) {
for(@todel) {
print STDERR "deleting: $_\n";
unlink($_);
}
}
#
# copy songs
#
my $main_sl="";
my $main_pl="";
my $index=500;
#print Dumper(\%songs);
my $df = new Filesys::DiskFree;
SONGS: for my $song (keys %songs) {
my $attr;
my $out="";
my $attr_c=3;
if($rc->{SYNCMODE} >= 2) {
my $to = "$rc->{IPODDIR}/iPod_Control/Music/$songs{$song}{dir}/$songs{$song}{name}";
#my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
# $atime,$mtime,$ctime,$blksize,$blocks) = stat($to);
#$size=0 unless $size;
#print "checking: $song [$songs{$song}{size}] -> $to [$size]\n";
#if($size != $songs{$song}{size}) {
unless(-e $to) {
print STDERR "syncing: $songs{$song}{name}\n";
# cp "\"$song\" \"$to\"";
$df->df();
my $free=$df->avail($rc->{IPODDIR});
if($free-$songs{$song}{size}-$buffer>0) {
copy($song,$to);
} else {
print STDERR "no space availiable for: $songs{$song}{name} [$songs{$song}{size}]\n";
delete $songs{$song};
next SONGS;
}
}
}
$songs{$song}{index}=$index;
$out.=create_mhod($songs{$song}{title},1);
if($songs{$song}{artist}) {
$attr_c++;
$out.=create_mhod($songs{$song}{artist},4);
}
if($songs{$song}{album}) {
$attr_c++;
$out.=create_mhod($songs{$song}{album},3);
}
$out.=create_mhod("MPEG audio file",6);
$out.=create_mhod(":iPod_Control:Music:".$songs{$song}{dir}.":".$songs{$song}{name},2);
$out=create_mhit(
$attr_c,length($out),$index,$songs{$song}{vbr},
$songs{$song}{date},$songs{$song}{size},
$songs{$song}{duration},$songs{$song}{order},
$songs{$song}{bitrate}
).$out;
$main_sl.=$out;
$main_pl.=create_mhod_mhip($songs{$song}{index});
$index++;
}
#print Dumper(\%songs);
my %playlists;
my @pl=find("$rc->{PLAYLISTDIR}/* 2>/dev/null");
for my $p (@pl) {
chomp $p;
my ($n) = $p =~ /.*\/(.*?)$/;
open IN,$p or die "playlist: $p could not be opened";
while(<IN>) {
my $song=$_;
chomp $song;
unless($songs{$song}) {
print STDERR "ignoring song in playlist [$p], [$song] does not exist in syncdir or ipod full\n";
} else {
$playlists{$n}{raw}.=create_mhod_mhip($songs{$song}{index});
$playlists{$n}{count}++;
}
}
close IN;
}
#
# creating search pattern playlists
#
for my $pattern (@ARGV) {
my @list;
for(keys %songs) {
push @list,$songs{$_}{index} if($_ =~ /$pattern/i);
}
unless(@list) {
print STDERR "nothing for searchpattern: $pattern found\n";
} else {
my ($name)=$pattern=~/(\S\S\S+)/;
unless(length($name)>=3) {
$name=$pattern;
$name =~ s/[^A-Za-z0-9]//g;
}
for(@list) {
$playlists{$name}{raw}.=create_mhod_mhip($_);
$playlists{$name}{count}++;
}
print STDERR @list." songs for searchpattern: $pattern found\n";
}
}
#print Dumper(\%playlists);
#
# build the pieces together
#
my $output;
my $song_c=keys %songs;
print STDERR "\nFound songs: $song_c\n";
my $tmp=create_mhlt($song_c).$main_sl;
$main_sl=create_mhsd(96+length($tmp),1).$tmp;
print STDERR "Songlist created\n";
my $pl_c=keys %playlists;
print STDERR "\nFound additional playlists: $pl_c\n";
$tmp=create_mhlp($pl_c+1).create_playlist_main($ipod_name,$song_c).$main_pl;
print STDERR "\nMain playlist created: $song_c songs\n\n";
for(keys %playlists) {
$tmp.=create_playlist($_,$playlists{$_}{count}).$playlists{$_}{raw};
print STDERR "Playlist \"$_\" created: $playlists{$_}{count} songs\n";
}
$main_pl=create_mhsd(96+length($tmp),2).$tmp;
$output=create_mhbd(104+length($main_sl.$main_pl)).$main_sl.$main_pl;
# backup old iTunesDB
if(-e "$rc->{IPODDIR}/iPod_Control/iTunes/iTunesDB") {
my $t=time();
copy("$rc->{IPODDIR}/iPod_Control/iTunes/iTunesDB","$rc->{BACKUPDIR}/iTunesDB_$t");
gzip("$rc->{BACKUPDIR}/iTunesDB_$t");
}
open OUT,">".$rc->{IPODDIR}."/iPod_Control/iTunes/iTunesDB" or die "cannot write iTunesDB";
print OUT $output;
close OUT;
print STDERR "\niTunesDB created.\n";
exit;
# END
#
# internal subroutines
#
sub create_mhbd {
my ($size) = @_;
my $r= "mhbd";
$r.= pack "V",104;
$r.= pack "V",$size;
$r.= pack "V",1;
$r.= pack "V",1;
$r.= pack "V",2;
for(1..20) {
$r.= pack "V",0;
}
return $r;
}
sub create_mhlp {
my ($count) = @_;
my $r= "mhlp";
$r.= pack "V",92;
$r.= pack "V",$count;
for(1..20) {
$r.= pack "V",0;
}
return $r;
}
sub create_playlist {
my ($name,$anz) = @_;
my $ipod_name=create_mhod($name,1);
my $r= "mhyp";
$r.= pack "V",108;
$r.= pack "V",108+648+length($ipod_name)+$anz*(76+44);
$r.= pack "V",2;
$r.= pack "V",$anz;
$r.= pack "V",0;
$r.= pack "V",3088620292;
$r.= pack "V",2317718671;
$r.= pack "V",3655876446;
for(1..18) {
$r.= pack "V",0;
}
$r.= "mhod";
$r.= pack "V",24;
$r.= pack "V",648;
$r.= pack "V",100;
for(1..3) {
$r.= pack "V",0;
}
$r.= pack "V",12714187; # ?? 12714187
$r.= pack "V",26215000;
$r.= pack "V",0;
$r.= pack "V",65736;
$r.= pack "V",1; # ?? 1
$r.= pack "V",6; # ?? 6
$r.= pack "V",0; # ?? 0
$r.= pack "V",2555905; # ?? 2555905
for(1..3) {
$r.= pack "V",0;
}
$r.= pack "V",13107202;
for(1..3) {
$r.= pack "V",0;
}
$r.= pack "V",3276813;
for(1..3) {
$r.= pack "V",0;
}
$r.= pack "V",8192004;
for(1..3) {
$r.= pack "V",0;
}
$r.= pack "V",8192003;
for(1..3) {
$r.= pack "V",0;
}
$r.= pack "V",5242888;
for(1..107) {
$r.= pack "V",0;
}
$r.= pack "V",140;
for(1..19) {
$r.= pack "V",0;
}
return $r.$ipod_name;
}
sub create_playlist_main {
my ($name,$anz) = @_;
my $ipod_name=create_mhod($name,1);
my $r= "mhyp";
$r.= pack "V",108;
$r.= pack "V",108+648+length($ipod_name)+$anz*(76+44);
$r.= pack "V",2;
$r.= pack "V",$anz;
$r.= pack "V",1;
$r.= pack "V",3087491191;
$r.= pack "V",837788566;
$r.= pack "V",62365;
for(1..18) {
$r.= pack "V",0;
}
$r.= "mhod";
$r.= pack "V",24;
$r.= pack "V",648;
$r.= pack "V",100;
for(1..3) {
$r.= pack "V",0;
}
$r.= pack "V",13172927; # ?? 12714187
$r.= pack "V",26215000;
$r.= pack "V",0;
$r.= pack "V",65736;
$r.= pack "V",5; # ?? 1
$r.= pack "V",6; # ?? 6
$r.= pack "V",3; # ?? 0
$r.= pack "V",1179649; # ?? 2555905
for(1..3) {
$r.= pack "V",0;
}
$r.= pack "V",13107202;
for(1..3) {
$r.= pack "V",0;
}
$r.= pack "V",3276813;
for(1..3) {
$r.= pack "V",0;
}
$r.= pack "V",8192004;
for(1..3) {
$r.= pack "V",0;
}
$r.= pack "V",8192003;
for(1..3) {
$r.= pack "V",0;
}
$r.= pack "V",5242888;
for(1..107) {
$r.= pack "V",0;
}
$r.= pack "V",140;
for(1..19) {
$r.= pack "V",0;
}
return $r.$ipod_name;
}
sub create_mhod_mhip {
my ($ref) = @_;
my $r= "mhip";
$r.= pack "V",76;
$r.= pack "V",76;
$r.= pack "V",1;
$r.= pack "V",0;
$r.= pack "V",$ref-1;
$r.= pack "V",$ref;
$r.= pack "V",3088619525;
for(1..11) {
$r.= pack "V",0;
}
$r.="mhod";
$r.= pack "V",24;
$r.= pack "V",44;
$r.= pack "V",100;
$r.= pack "V",0;
$r.= pack "V",0;
$r.= pack "V",$ref-1;
for(1..4) {
$r.= pack "V",0;
}
return $r;
}
sub create_mhsd {
my ($size,$type) = @_;
my $r="mhsd";
$r.= pack "V",96;
$r.= pack "V",$size;
$r.= pack "V",$type;
for(1..20) {
$r.= pack "V",0;
}
return $r;
}
sub create_mhlt {
my ($count) = @_;
my $r="mhlt";
$r.= pack "V",92;
$r.= pack "V",$count;
for(1..20) {
$r.= pack "V",0;
}
return $r;
}
sub create_mhit {
my ($arttr_c,$attr_s,$index,$vbr,$date,$size,$dur,$order,$bitrate) = @_;
my $r="mhit";
$r.= pack "V",156;
$r.= pack "V",156+$attr_s;
$r.= pack "V",$arttr_c;
$r.= pack "V",$index;
$r.= pack "V",1;
$r.= pack "V",0;
my $type=256;
$type+=1 if($vbr);
$r.= pack "V",$type;
$r.= pack "V",$date+2082844800;
$r.= pack "V",$size;
$r.= pack "V",$dur;
$r.= pack "V",$order;
$r.= pack "V",0;
$r.= pack "V",0;
$r.= pack "V",$bitrate;
$r.= pack "V",2890137600;
for(1..23) {
$r.= pack "V",0;
}
return $r;
}
sub create_mhod {
my ($string,$type) = @_;
my $len=length($string);
my $r="mhod";
$r.= pack "V",24;
$r.= pack "V",(40+2*$len);
$r.= pack "V",$type;
$r.= pack "V2",0;
$r.= pack "V",1;
$r.= pack "V",(2*$len);
$r.= pack "V2",0;
my $u=latin1($string);
$u->byteswap;
$r.= $u->utf16;
return $r;
}
sub set_ipodname {
my ($dev,$backup,$name,$real,$cpu)=@_;
$dev.="/iPod_Control/iTunes/DeviceInfo";
my $file;
for(1..384) {
$file.=pack "V",0;
}
my $l=length($name);
substr($file,0,2)=pack "v",$l;
my $u=latin1($name);
$u->byteswap;
substr($file,2,$l*2)=$u->utf16;
$l=length($real);
substr($file,512,2)=pack "v",$l;
$u=latin1($real);
$u->byteswap;
substr($file,514,$l*2)=$u->utf16;
$l=length($cpu);
substr($file,1024,2)=pack "v",$l;
$u=latin1($cpu);
$u->byteswap;
substr($file,1026,$l*2)=$u->utf16;
if(-e $dev) {
my $t=time();
copy($dev,"$backup/DeviceInfo_$t");
gzip("$backup/DeviceInfo_$t");
}
open IPOD,">$dev" or die "cannot write DeviceInfo";
print IPOD $file;
close IPOD;
}
sub get_ipodname {
my $dev=shift;
$dev.="/iPod_Control/iTunes/DeviceInfo";
my $file;
my $buff;
open IPOD,$dev or return undef;
while (read(IPOD, $buff, 8 * 2**10)) {
$file.=$buff;
}
close IPOD;
my $l=unpack "v",substr($file,0,2);
my $s=substr($file,2,$l*2);
my $u=utf16($s);
$u->byteswap;
my $name=$u->latin1;
$l=unpack "v",substr($file,512,2);
$s=substr($file,514,$l*2);
$u=utf16($s);
$u->byteswap;
my $realname=$u->latin1;
$l=unpack "v",substr($file,1024,2);
$s=substr($file,1026,$l*2);
$u=utf16($s);
$u->byteswap;
my $computername=$u->latin1;
return ($name,$realname,$computername);
}
sub hash {
my $string=shift;
my $key;
my $len=length($string);
for(my $j=$len-1 ; $j>1 ; $j--) {
$key+=ord(substr($string,$j,1));
}
return sprintf "%.2d",(substr($key,length($key)-2,2) % 20);
}
sub readrc {
my $file = shift;
my $req = shift;
my $rc;
my $sub;
open IN,$file or die "cannot open rc file: $file";
while(<IN>) {
next if /^\s*$/;
next if /^\s*#/;
if(/^\s*(\S+)\s*=\s*(.*?)\s*$/) {
my $k=$1;
my $n=$2;
($n) = $n =~ /^\"(.*?)\"$/ if($n =~ /\"/);
unless($sub) {
$rc->{$k}=$n;
} else {
($k) = $k =~ /^\"(.*?)\"$/ if($k =~ /\"/);
my @n=split /,/,$n;
for(@n) {
s/^\s+//g;
s/\s+$//g;
s/^\"//;
s/\"$//;
}
$rc->{$sub}->{$k}=\@n;
}
} elsif (/^\s*(\S+)\s*\{/) {
$sub=$1;
} elsif (/^\s*}/) {
$sub=undef;
}
}
if($rc->{SYNCMODE} == 2) {
push @$req,"SYNCDIR";
}
if($rc->{WRITEDEVICEINFO} == 1) {
push @$req,("IPODNAME","REALNAME","COMPUTERNAME");
}
if($rc->{ALWAYSTEMPLATES} == 1) {
push @$req,"FILETEMPLATES";
}
for my $d (keys %$rc) {
if($d =~ /DIR$/) {
$rc->{$d} =~ s/\~/$ENV{HOME}/;
}
}
$rc->{SYNCLIST} =~ s/\~/$ENV{HOME}/ if $rc->{SYNCLIST};
for(@$req) {
die "RC PARAMETER: $_ not found" unless($rc->{$_});
}
return $rc;
}

3
syncauto.sh Normal file
View File

@@ -0,0 +1,3 @@
# sudo mount -o uid=marc /dev/sdt1 /media/hdext
rsync -a --no-o --no-p --no-g -L --modify-window 1 --stats --delete --progress /mp3/auto/ /media/hdext/

View File

@@ -8,7 +8,7 @@
# So sehen die Dateien aus: # So sehen die Dateien aus:
# http://www.taz.de/cgi-bin/digiabo/2007_04_17_HTM.zip # http://www.taz.de/cgi-bin/digiabo/2007_04_17_HTM.zip
TAZDIR=/dat/books/taz TAZDIR=/media/nas/books/taz
TAZUSER=103450 TAZUSER=103450
TAZPASSWD=oxculo TAZPASSWD=oxculo
TAZTYPE=.pdf TAZTYPE=.pdf
@@ -72,3 +72,6 @@ for i in {1..16}
do do
download "${TAG[$i]}""$TAZTYPE_EPUB" "$TAZURL""taz_""${TAG[$i]}""$TAZTYPE_EPUB" download "${TAG[$i]}""$TAZTYPE_EPUB" "$TAZURL""taz_""${TAG[$i]}""$TAZTYPE_EPUB"
done done
# Sync to Dropbox
bash /home/marc/bin/tazsync.sh

26
tazsync.sh Normal file
View File

@@ -0,0 +1,26 @@
daysback=10
srcdir=/dat/books/taz
dstdir=/home/marc/Dropbox-ipad/taz
tmpdir=/tmp
[ -d $dstdir ] || exit
[ -d $srcdir ] || exit
[ -d $tmpdir ] || exit
cd $dstdir
find . -type f | sort> $tmpdir/alt.lst
cd $srcdir
find . -mtime -$daysback -name "*.epub" | sort > $tmpdir/new.lst
rsync --files-from=$tmpdir/new.lst . $dstdir/
cd $dstdir
cat $tmpdir/alt.lst $tmpdir/new.lst | sort -u > $tmpdir/all.lst
cat $tmpdir/all.lst
cat $tmpdir/new.lst
diff $tmpdir/new.lst $tmpdir/all.lst | grep "^>" | sed "s/^> //" | xargs rm
# $rmfiles

7
test.sh Normal file
View File

@@ -0,0 +1,7 @@
echo "#!/bin/bash" > /tmp/cctest
echo "dstdir=\$(dirname \$1)" >> /tmp/cctest
echo "echo rsync -av \$1 \$bakdir/\$dstdir" >> /tmp/cctest
export bakdir=/media/hdext/git
find /home/marc/ -type d -name .git -exec bash -x /tmp/cctest {} \;

3
tonas.sh Normal file
View File

@@ -0,0 +1,3 @@
sudo -u vdr rsync -avz --progress --delete --exclude "*.del" /video/ /media/hdext/video/vdr/
sudo -u vdr rsync -avz --progress --delete /mp3/ /media/hdext/audio/

1
torrentcreate.sh Normal file
View File

@@ -0,0 +1 @@
ctorrent -t -u http://tracker.thepiratebay.org/announce -s test.torrent garmin_allinone_d_2009-07-17.tar

12
tvm2vdr_start Executable file
View File

@@ -0,0 +1,12 @@
#!/bin/bash
tmpdir1=/tmp/tvmovie2vdr
tmpdir2=/tmp/tvmovie2vdrup
logdir=/var/log/tvmovie2vdr
[ -d $tmpdir1 ] || mkdir $tmpdir1
[ -d $tmpdir2 ] || mkdir $tmpdir2
[ -d $logdir ] || mkdir $logdir
tvm2vdr

15
unqueue Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/bash
set -x
qfile=$1
lines=$(cat $qfile | wc -l)
while [ $lines -ge 1 ]; do
entry=$(head -n 1 $qfile)
$entry
tail -n +2 $qfile > ${qfile}.tmp
mv ${qfile}.tmp ${qfile}
lines=$(cat $qfile | wc -l)
done
rm $qfile

View File

@@ -3,8 +3,8 @@
LocalDir=/dat/gps/garmin LocalDir=/dat/gps/garmin
allinone=1 allinone=0
radfahrer=1 radfahrer=0
kleineisel=1 kleineisel=1
# ------------------------------------------- # -------------------------------------------
@@ -67,14 +67,15 @@ if [ $radfahrer -eq 1 ]; then
cd $LocalDir/radfahrer cd $LocalDir/radfahrer
wget -nv http://osm.arndnet.de/ -O index.html #wget -nv http://osm.arndnet.de/ -O index.html
wget -N http://radkarte.formann.de/gmapsupp.img.zip
#uncompress < Radkarte > Radkarte.html #uncompress < Radkarte > Radkarte.html
cp index.html Radkarte.html #cp index.html Radkarte.html
url_rad=$(cat Radkarte.html | grep img\.zip | cut -f 2 -d '"') #url_rad=$(cat Radkarte.html | grep img\.zip | cut -f 2 -d '"')
wget -nv -N $url_rad #wget -nv -N $url_rad
datestr=$(stat -c %y gmapsupp.img.zip | cut -f 1 -d ' ') datestr=$(stat -c %y gmapsupp.img.zip | cut -f 1 -d ' ')
[ -f radfahrer_$datestr.zip ] || cp gmapsupp.img.zip radfahrer_$datestr.zip [ -f radfahrer_$datestr.zip ] || cp gmapsupp.img.zip radfahrer_$datestr.zip
rm Radkarte.html #rm Radkarte.html
fi fi

199
vdrrecren Executable file
View File

@@ -0,0 +1,199 @@
#!/usr/bin/ruby
require 'socket'
DEBUG=1
#Port=6419
Port=2001
def SvdrpRecv(s)
lines=Array.new
begin
str=s.readline
lines.push(str)
#puts("SvdrpReceived: " + str + " - |" + str[3,1] + "|" ) if $DEBUG
end while str[3,1]=="-"
return(lines)
end
def SvdrpSend( s, strSvdrpCmd )
s.write(strSvdrpCmd + "\n")
l=SvdrpRecv(s)
return(l)
end
def Svdrp( strSvdrpCmd )
puts("Svdrp:" + strSvdrpCmd) if DEBUG
s=TCPSocket::new("localhost", Port)
l=SvdrpRecv(s)
l=SvdrpSend(s, strSvdrpCmd)
s.write("quit\r\n")
s.close
return(l)
end
def CmdRen( num, strNewName )
cmd=sprintf("MOVR %d %s", num, strNewName)
printf("Aufnahme umbennenen in '%s' ...\n", cmd)
Svdrp(cmd)
end
if ARGV.size!=2
printf("invalid arguments: %d\n",ARGV.size )
exit
end
CMD=ARGV[0]
REC=ARGV[1]
if not File.directory?(REC)
puts("not a directory")
exit
end
RECDATEDIR=File.basename(REC)
RECPATH=File.dirname(REC)
RECNAME=File.basename(RECPATH)
BASEDIR=File.dirname(RECPATH)
EPISODENAME=File.basename(BASEDIR)
printf("recpath:%s basedir:%s recname:%s recdatedir:%s\n", RECPATH, BASEDIR, RECNAME, RECDATEDIR)
sp=RECDATEDIR.split(".")
RECDATE=sp[0]
RECHOUR=sp[1].to_i
RECMIN=sp[2].to_i
if sp.last()!="rec"
puts("not .rec-dir")
exit
end
#printf("1\n")
sp=RECDATE.split("-")
RECDAY=sp[2].to_i
RECMON=sp[1].to_i
RECYEAR=sp[0].to_i
strTime=sprintf("%02d:%02d", RECHOUR, RECMIN);
strDate=sprintf("%02d.%02d.%02d", RECDAY, RECMON, RECYEAR % 100);
l=Svdrp("LSTR")
recs=Array.new
printf("Date:%s ; Time:%s\n", strDate,strTime) if DEBUG
l.each do |x|
z=x[4..x.size-1]
sp=z.split(" ")
#printf("d:%s;t:%s-%s;%s-%s\n", sp[1], sp[2], strDate,strTime, x)
#printf("%s%s|%s %s|%s\n", z, sp[1], sp[2][0,5], strDate, strTime)
if sp[1]==strDate && sp[2][0,5]==strTime
puts("LSTR:"+x) if DEBUG
recs.push(x)
end
end
if recs.size==0
puts("Aufnahme nicht gefunden")
exit
end
if recs.size>1
puts("Aufnahmezeit nicht eindeutig")
exit
end
#p(recs[0])
# Get Rec-Num
rec=recs[0][4..(recs[0].size-1)]
puts("rec:"+rec) if DEBUG
rec_s=rec.split(' ')
num=rec_s[0].to_i
printf("Num:%s\n",num) if DEBUG
# Get Title of Rec
title=""
rec_s[4..rec_s.size].each { |x| title=title+x+' ' }
printf("Title:%s\n",title) if DEBUG
# Get Dir of Rec
dir_s=title.split('~')
dir=""
printf("Dir_s:%s size:%d\n", dir_s, dir_s.size) if DEBUG
if(dir_s.size>1)
dir_s[0..dir_s.size-2].each { |x| dir=dir+x+'~' }
end
puts("Dir: " + dir) if DEBUG
dir_parent=""
dir_parent=dir_s[dir_s.size-2] if dir_s.size>=2
puts("ParentDir: " + dir_parent) if DEBUG
# read info.vdr-file
info_title=""
info_short=""
info_desc=""
infofile=REC + "/info.vdr"
if ! File.exists?( infofile )
infofile=REC + "/info"
end
puts("Infofile: " + infofile) if DEBUG
if File.exists?( infofile )
puts("Infofile: " + infofile) if DEBUG
f = File.new( infofile )
lines=f.readlines
f.close
lines.each do |l|
if l[0,2]=="T "
info_title=l[2..l.size].chop
elsif l[0,2]=="S "
info_short=l[2..l.size].chop
elsif l[0,2]=="D "
ld=l.size
ld=80 if ld>80
info_desc=l[2..ld].chop
end
end
end
#printf("5\n")
puts("Info Title: " + info_title) if DEBUG
puts(" Short: " + info_short) if DEBUG
puts(" Desc : " + info_desc) if DEBUG
#printf("6 %d\n", DEBUG)
puts("CMD:"+CMD) if DEBUG
case CMD
when "ShortToName" :
if info_short.size>0
puts("ShortToName") if DEBUG
newname=(dir+info_short) #.gsub(" ", "\\ ")
CmdRen(num, newname)
end
when "TitleToName" :
if info_title.size>0
puts("TitleToName") if DEBUG
newname=(dir+info_title) #.gsub(" ", "\\ ")
CmdRen(num, newname)
end
when "DescToName" :
if info_desc.size>0
puts("DescToName") if DEBUG
newname=(dir+info_desc) #.gsub(" ", "\\ ")
CmdRen(num, newname)
end
when "DirToName" :
if dir_parent.size>0
puts("DirToName") if DEBUG
CmdRen(num, dir.chop)
end
when "TitleToDir" :
if info_title.size>0
puts("TitleToDir") if DEBUG
title=info_title.gsub(" ", "_").gsub("(","\(").gsub(")","\)").gsub("/", "#2F").gsub(":", "#3A")
printf("title:%s recpath:%s\n", title, RECPATH)
newdir=BASEDIR+"/"+title
cmd=sprintf("mkdir %s", newdir)
puts(cmd)
system("mkdir", newdir)
cmd=sprintf("mv %s %s", RECPATH, newdir+"/"+RECNAME)
puts(cmd)
system("mv", RECPATH, newdir+"/"+RECNAME)
cmd=sprintf("touch /video/.update")
puts(cmd)
system("touch", "/video/.update")
#system("ls -l")
end
end

144
vdrrecren.rb Executable file
View File

@@ -0,0 +1,144 @@
#!/usr/bin/ruby
require 'socket'
def SvdrpRecv(s)
lines=Array.new
begin
str=s.readline
lines.push(str)
#puts("SvdrpReceived: " + str + " - |" + str[3,1] + "|" ) if $DEBUG
end while str[3,1]=="-"
return(lines)
end
def SvdrpSend( s, strSvdrpCmd )
s.write(strSvdrpCmd + "\n")
l=SvdrpRecv(s)
return(l)
end
def Svdrp( strSvdrpCmd )
puts("opening socket...") if $DEBUG
s=TCPSocket::new("localhost", 2001)
l=SvdrpRecv(s)
l=SvdrpSend(s, strSvdrpCmd)
s.write("quit\r\n")
s.close
return(l)
end
def RenameRec( num, strDir, strName)
if strName.size>0
cmd=sprintf("RENR %d '%s'", num, strDir + strName)
printf("Aufnahme %d umbennenen in '%s'...\n", num, strDir+strName)
#Svdrp(cmd)
end
end
if ARGV.size!=2
printf("invalid arguments: %d\n",ARGV.size )
exit
end
CMD=ARGV[0]
REC=ARGV[1]
if not File.directory?(REC)
puts("not a directory")
exit
end
RECDATEDIR=File.basename(REC)
RECPATH=File.dirname(REC)
RECNAME=File.basename(RECPATH)
BASEDIR=File.dirname(RECPATH)
EPISODENAME=File.basename(BASEDIR)
sp=RECDATEDIR.split(".")
RECDATE=sp[0]
RECHOUR=sp[1].to_i
RECMIN=sp[2].to_i
if sp[5]!="rec"
puts("not .rec-dir")
exit
end
sp=RECDATE.split("-")
RECDAY=sp[2].to_i
RECMON=sp[1].to_i
RECYEAR=sp[0].to_i
strTime=sprintf("%02d:%02d", RECHOUR, RECMIN);
strDate=sprintf("%02d.%02d.%02d", RECDAY, RECMON, RECYEAR % 100);
l=Svdrp("LSTR")
recs=Array.new
#printf("Date:%s ; Time:%s\n", strDate,strTime) if $DEBUG
l.each do |x|
sp=x.split(" ")
#printf("d:%s;t:%s\n", sp[1], sp[2])
if sp[1]==strDate && sp[2][0,5]==strTime
recs.push(x)
end
end
if recs.size>1
puts("Aufnahmezeit nicht eindeutig")
exit
end
# Get Rec-Num
rec=recs[0][4..(recs[0].size-1)]
rec_s=rec.split(' ')
num=rec_s[0].to_i
# Get Title of Rec
title=""
rec_s[3..rec_s.size].each { |x| title=title+x+' ' }
#printf("t:%s\n",title)
# Get Dir of Rec
dir_s=title.split('~')
dir=""
dir_s[0..dir_s.size-2].each { |x| dir=dir+x+'~' }
dir_parent=dir_s[dir_s.size-2] if dir_s.size>=2
#puts("D:"+dir)
# read info.vdr-file
infofile=REC + "/info.vdr"
if File.exists?( infofile )
puts("reading " + infofile) if $DEBUG
f = File.new( infofile )
lines=f.readlines
f.close
info_title=""
info_short=""
info_desc=""
lines.each do |l|
if l[0,2]=="T "
info_title=l[2..l.size].chop
elsif l[0,2]=="S "
info_short=l[2..l.size].chop
elsif l[0,2]=="D "
ld=l.size
ld=80 if l.size > 80
info_desc=l[2..ld].chop
end
end
end
puts(info_title) if $DEBUG
puts(info_short) if $DEBUG
puts(info_desc) if $DEBUG
case CMD
when "ShortToName" :
RenameRec(num, dir, info_short)
when "DirToName" :
if dir_parent.size>0
RenameRec(num, "", dir.chop)
end
when "DescToName" :
RenameRec(nu, dir, info_desc)
end

4
vdrrecren_start Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/sh
echo "/usr/local/bin/vdrrecren $1 '$2' 2>&1 >> /tmp/vdrrecren.log" | at now
echo "Command: /usr/local/bin/vdrrecren $1 '$2' 2>&1 >> /tmp/vdrrecren.log" >> /tmp/vdrrecren.log

12
zeit.sh Normal file → Executable file
View File

@@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
destdir=~/tmp/zeit destdir=/dat/books/zeit
user=mh256 user=mh256
pw=zeit0815 pw=zeit0815
@@ -17,22 +17,24 @@ tmpfile_bl=/tmp/zeit_bl.tmp
[ -d $destdir ] || mkdir -p $destdir [ -d $destdir ] || mkdir -p $destdir
cd $destdir cd $destdir
# links zum Download des pdf und epub ermitteln
wget --user=$user --password=$pw $url -O $tmpfile wget --user=$user --password=$pw $url -O $tmpfile
pdf_url=$(cat $tmpfile | grep Download | head -n 1 | sed -r 's/href=.(.*pdf).*/\1/') pdf_url=$(cat $tmpfile | grep Download | head -n 1 | sed -r 's/href=.(.*pdf).*/\1/')
epub_url=$(cat $tmpfile | grep content.*Download | awk -F "\"" '{print $2}') epub_url=$(cat $tmpfile | grep content.*Download | awk -F "\"" '{print $2}')
# Nummer des Ausgabe zum umbenennen des epub ermitteln
number=$(echo $pdf_url | sed -r 's/^.*DZ_ePaper_(.*)\.pdf/\1/' | awk -F_ '{ printf("%s-%s",$2,$1)}' ) number=$(echo $pdf_url | sed -r 's/^.*DZ_ePaper_(.*)\.pdf/\1/' | awk -F_ '{ printf("%s-%s",$2,$1)}' )
# links zum download von Beilage und Zeitmagazin ermitteln
wget --user=$user --password=$pw $url_zm -O $tmpfile_zm wget --user=$user --password=$pw $url_zm -O $tmpfile_zm
pdfzm_url=$(cat $tmpfile_zm | grep Download | head -n 1 | sed -r 's/href=.(.*pdf).*/\1/') pdfzm_url=$(cat $tmpfile_zm | grep Download | head -n 1 | sed -r 's/href=.(.*pdf).*/\1/')
wget --user=$user --password=$pw $url_bl -O $tmpfile_bl wget --user=$user --password=$pw $url_bl -O $tmpfile_bl
pdfbl_url=$(cat $tmpfile_bl | grep Download | head -n 1 | sed -r 's/href=.(.*pdf).*/\1/') pdfbl_url=$(cat $tmpfile_bl | grep Download | head -n 1 | sed -r 's/href=.(.*pdf).*/\1/')
# alles herunterladen
wget --user=$user --password=$pw $epub_url -O die_zeit_20$number.epub wget --user=$user --password=$pw $epub_url -O die_zeit_20$number.epub
wget --user=$user --password=$pw "$url_base/$pdf_url" wget --user=$user --password=$pw "$url_base/$pdf_url"
wget --user=$user --password=$pw "$url_base/$pdfzm_url" wget --user=$user --password=$pw "$url_base/$pdfzm_url"
wget --user=$user --password=$pw "$url_base/$pdfbl_url" wget --user=$user --password=$pw "$url_base/$pdfbl_url"
# Temp-files loeschen
rm $tmpfile $tmpfile_zm $tmpfile_bl rm $tmpfile $tmpfile_zm $tmpfile_bl