Permalink
Browse files

Obsoletes darius-tools, filenames cleanup.

  • Loading branch information...
Klink
Klink committed Apr 21, 2012
1 parent fc05419 commit 6965f5fdd6444b7a4404fb258cc08a830a233fff
View
4 README
@@ -1,3 +1,7 @@
Stuff completely useless, or almost.
See http://yeupou.wordpress.com/
+
+(In general, files prefixed stalag13- are specific to stalag13.ici local
+network and probably cannot be used anywhere else without being at least
+edited. The others should be portable as such)
View
@@ -7,7 +7,7 @@ Standards-Version: 3.5.9.0
Package: stalag13-utils
Architecture: all
Depends: perl-base (>=5.6.0), perl-modules, coreutils (>=4.5.0) | fileutils (>=4.1), bash (>=2.04), findutils (>=4.1), apt-utils, gzip (>=1), libnet-dns-perl, libfile-find-rule-perl, lltag, libapt-pkg-perl, libterm-readkey-perl, libfile-homedir-perl, libdate-calc-perl, libcalendar-simple-perl, debfoster, localepurge, etckeeper, ntp
-Conflicts: ntpdate
+Conflicts: ntpdate, darius-admin, darius-misc, darius-sound, darius-text
Description: Stuff useful on stalag13 computers.
.
Homepage: https://gate.stalag13.ici
View
@@ -75,7 +75,9 @@ my @outdated_2011 = ("/etc/init.d/torrent",
my @outdated_2012 = ("/etc/init.d/fcgi",
"/etc/cron.daily/stalag13-ntpdate",
- "/etc/cron.daily/torrent");
+ "/etc/cron.daily/torrent",
+ "/etc/profile.d/stalag13-ls.sh",
+ "/etc/profile.d/stalag13-tar.sh");
my @outdated = (@outdated_nov2003, @outdated_dec2003, @outdated_2004, @outdated_dec2004, @outdated_2005, @outdated_2006, @outdated_2007, @outdated_2010, @outdated_2011, @outdated_2012);
@@ -1,11 +0,0 @@
-if [ "$TERM" != "dumb" ]; then
- if [ -e "$HOME/.dircolors" ]; then
- DIRCOLORSRC="$HOME/.dircolors"
- fi
- eval `dircolors -b $DIRCOLORSRC`
- alias ls='ls --color'
-fi
-
-alias ll='ls -l'
-alias la='ls -A'
-alias l='ls -CF'
@@ -0,0 +1,14 @@
+# tar.[bz2|gz] decompression in 4 chars.
+alias targ='tar zxvf'
+alias tarb='tar jxvf'
+
+# ls
+alias ls='ls --color'
+alias ll='ls -l'
+alias la='ls -A'
+alias l='ls -CF'
+
+# cleanup
+function mrclean { find $1 \( -name "#*#" -or -name ".#*" -or -name "*~" -or -name ".*~" \) -exec rm -rfv {} \; }
+
+# EOF
@@ -1,3 +0,0 @@
-# tar.[bz2|gz] decompression in 4 chars.
-alias targ='tar zxvf'
-alias tarb='tar jxvf'
@@ -0,0 +1,20 @@
+# Wild assumption
+TORRENT_BASEDIR=/mnt/lan/gate.stalag13.ici
+
+# Run
+function tcdcheck {
+ if [ ! -d "$TORRENT_BASEDIR" ]; then
+ echo "TORRENT_BASEDIR ($TORRENT_BASEDIR) does not exists."
+ return 1
+ fi
+ return 0
+}
+
+alias tcd='tcdcheck && cd $TORRENT_BASEDIR/watch'
+alias tcdd='tcdcheck && cd $TORRENT_BASEDIR/download'
+alias tl='tcd && tail -n 100 log'
+alias ts='tcd && cat status'
+alias t='tcd && ls *.trs'
+alias t+='tcd && ls *.trs+'
+
+# EOF
@@ -1,5 +1,7 @@
#!/usr/bin/perl
-# Copyright 2010 (c) Mathieu Roy <yeupou--gnu.org>
+#
+# Copyright 2010-2012 (c) Mathieu Roy <yeupou--gnu.org>
+# http://yeupou.wordpress.com
#
# Thi program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -18,6 +20,9 @@
use strict;
use POSIX qw/setsid/;
+my @redshift_opts=("-l", "48.799:2.505",
+ "-t", "6500:3700");
+
# search for any redshift process in /proc
my @tokill;
opendir(PROC, "/proc");
@@ -62,8 +67,6 @@
open(STDOUT, ">/dev/null");
open(STDERR, ">&STDOUT");
# make it redshift
-exec("redshift",
- "-l 48.799:2.505",
- "-t 6500:9300");
+exec("redshift", @redshift_opts);
# EOF
@@ -201,8 +201,8 @@
closedir(ALBUMDIR);
# more cleanups
- print "/usr/bin/urlize -D $destdir\n";
- system("/usr/bin/urlize", "-D", $destdir) unless $debug;
+ print "/usr/local/bin/urlize -D $destdir\n";
+ system("/usr/local/bin/urlize", "-D", $destdir) unless $debug;
print "/bin/chown -R $user:$user $maindir/$style/band/\n";
system("/bin/chown", "-R", "$user:$user", "$maindir/$style/$band/") unless $debug;
print "/bin/chmod -R a+r $maindir/$style/$band/\n";
@@ -1,73 +0,0 @@
-#!/bin/bash
-#
-# Copyright (c) 2010 Mathieu Roy <yeupou--gnu.org>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-# USA
-
-# Set codecs used to reencode:
-MENCODER_OPTS="-oac lavc -ovc x264"
-FFMPEG_OPTS="-vcodec libx264 -vpre normal -acodec libvorbis"
-
-
-# Start logging
-echo -e `date`":\n" >> dir2x264log
-
-# Go thru the list of files here
-LIST="*.avi *.mpg *.mpeg *.mkv"
-for file in $LIST; do
- if [ -e "$file" ]; then
- # save original filesize
- MEMO="\t$file "`ls -sh "$file" | cut -d " " -f 1`" ->";
-
- # determine current file format
- ext=${file##*.}
-
- # set newfile name
- newfile=`basename "$file" .$ext`
- newfile="$newfile.mp4"
-
- if [ $ext != "mkv" ]; then
- # usual run
- #BUGGYmencoder "$file" $MENCODER_OPTS -o "$newfile";
- ffmpeg -i "$file" $FFMPEG_OPTS "$newfile"
- else
- # Workaround for MKV:
- # mencoder sometimes complains about
- # "Too many audio packets in the buffer",
- # being unable to process the MKV file.
- # The workaround consist of extract the audio stream and
- # then reincorporate it. Clumsy but it works.
-
- # separate audio and video with ffmpeg, as mplayer may be as
- # unreliable as mencoder
- rm -f temp.wav temp.mkv
- ffmpeg -i "$file" -vn -acodec pcm_s16le temp.wav
- ffmpeg -i "$file" -an -vcodec copy temp.mkv
-
- # reencode
- mencoder -audiofile temp.wav temp.mkv $MENCODER_OPTS -o "$newfile";
-
- # remove the temp files
- rm -f temp.wav temp.mkv
- fi
-
- # log original file size plus new filesize
- echo -e "$MEMO "`ls -sh "$newfile" | cut -d " " -f 1` >> dir2x264log
- fi
-done
-
-# log overal space gain, assuming that all mp4 were issued by this script
-echo -e "\n\t\t\t "`du -shc $LIST 2>> /dev/null| tail -n 1 | cut -d " " -f 1`" => "`du -shc *.mp4 2>> /dev/null| tail -n 1 | cut -d \t -f 1`"\n\n" >> dir2x264log
View
@@ -0,0 +1,131 @@
+#!/usr/bin/perl
+#
+# (c) 2001-2012 Mathieu Roy <yeupou@gnu.org>
+# http://yeupou.wordpress.com
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+# USA
+
+########################################
+# Configuration preset
+
+# Requirements
+use strict;
+use Getopt::Long;
+
+# Usual for Darius Tools perl scripts
+my $DARIUS_AUTHOR="2002-2012 Mathieu Roy";
+my $DARIUS_MAIL="yeupou@gnu.org";
+my $DARIUS_VER="Irrelevant";
+
+# Specific
+my $getopt;
+my $help;
+my $version;
+my $dir;
+my $expression;
+my $verbose;
+my $success;
+
+########################################
+# Functions definition
+
+########################################
+# Here we go
+
+# Get options
+eval {
+ $getopt = GetOptions("help" => \$help,
+ "version" => \$version,
+ "dir=s" => \$dir,
+ "expression=s" => \$expression,
+ "verbose" => \$verbose);
+};
+
+# Def return
+if($help) {
+ print STDERR <<EOF;
+Usage: $0 [OPTION]
+Rename files in a directory to a simplified name,
+(mainly for Universal Ressources Locators, URL.
+
+ -h, --help display this help and exit
+ --version output version information and exit
+
+ -d, --dir D rename files in dir D (default)
+ -e, --expression E urlize expression E
+ --verbose tells you what is done
+
+EXAMPLE: $0 . # would urlize each file in the current dir
+ $0 -d . # same command
+
+
+Report bugs or suggestions to <$DARIUS_MAIL>
+EOF
+exit(1);
+}
+
+if($version) {
+ print STDERR <<EOF;
+$0 $DARIUS_VER
+
+Copyright (c) $DARIUS_AUTHOR <$DARIUS_MAIL>
+This is free software; see the source for copying conditions.
+There is NO warranty; not even for MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE.
+EOF
+exit(1);
+}
+
+sub Urlize {
+ my $ret = $_[0];
+ $ret =~ tr/ /_/;
+ $ret =~ tr/à-é/a-e/;
+ $ret =~ tr/+/_/;
+ $ret =~ tr/=/_/;
+ $ret =~ tr/ù/u/;
+ $ret =~ s/\&//g;
+ $ret =~ s/\!//g;
+ $ret =~ s/\'//g;
+ $ret =~ s/\"//g;
+ $ret =~ s/\%//g;
+ return $ret;
+}
+
+
+if ($expression) {
+ print Urlize($expression)."\n";
+} elsif ($dir) {
+ die "$dir does not exit\n" unless -e $dir;
+ opendir(DIR, $dir);
+ while (defined(my $file = readdir(DIR))) {
+ next if $file =~ /^\.$/;
+ next if $file =~ /^\.\.$/;
+ my $file_clean = Urlize($file);
+ unless ($file_clean eq $file) {
+ print "$file -> $file_clean\n" if $verbose;
+ $success = rename($dir."/".$file,$dir."/".$file_clean);
+ print "Failed to rename $file\n" unless $success;
+ } else {
+ print "$file = $file_clean\n" if $verbose;
+ }
+ }
+ closedir(DIR);
+} else {
+ die "No expression specified, no directory specified\n";
+}
+
+# End
+########################################

0 comments on commit 6965f5f

Please sign in to comment.