# this value, then mpd will drop root priveleges
# and runs as the user specified.
#
-user "nobody"
+#user "nobody"
#
# Set this value if you only have one
# address you want to allow connection to.
my $filename = "";
my $debug = 0;
-if ( ! -e /var/run/mpd.pid){
- system("mpd >/dev/null");
-}
-
if ($ARGV[0] eq 'scan') {
if ($debug){print "Creating Database\n";}
system("mpd --create-db >/dev/null");
}
elsif ($ARGV[0] eq 'playweb') {
&checkmute();
+ &stop();
&clearplaylist();
if ($debug){print "Playing webstream $ARGV[1] \n";}
- system("mpc add http://$ARGV[1] >/dev/null && mpc play >/dev/null && sleep 1");
+ system("mpc add \"http://$ARGV[1]\" >/dev/null && mpc play >/dev/null && sleep 1");
}
elsif ($ARGV[0] eq 'volume') {
$temp = "Master - ";
system("mpc clear >/dev/null");
}
+sub stop(){
+ system("mpc stop >/dev/null");
+ }
+
sub checkplaylist(){
my $Datei = "/var/ipfire/mpfire/playlist.m3u";
my @Info = stat($Datei);
+etc/rc.d/init.d/mpd
usr/bin/mpd
+var/log/mpd.error.log
+var/log/mpd.log
#usr/share/doc/mpd
#usr/share/doc/mpd/COMMANDS
#usr/share/doc/mpd/README
my @songdb = <DATEI>;
close(DATEI);
-my @artist; my @album; my @genre; my @year; my $linecount = 0; my @currentsong = ""; my %songs;
+my @artist; my @album; my @genre; my @year; my $linecount = 0; my %songs;
+my $key;my $file;my $Time;my $Artist;my $Title;my $Album;my $Track;my $Date;my $Genre;
foreach (@songdb){
if ( $_ =~ /mtime: / ){
- $songs{$currentsong[1]}="$currentsong[2]|$currentsong[3]|$currentsong[4]|$currentsong[5]|$currentsong[6]|$currentsong[7]|$currentsong[8]|$currentsong[9]";
- push(@artist,$currentsong[4]);
- push(@album,$currentsong[6]);
- push(@year,$currentsong[8]);
- push(@genre,$currentsong[9]);
- @currentsong = "";
- }
- elsif ( $_ =~ /key: / || $_ =~ /file: / || $_ =~ /Time: / || $_ =~ /Artist: / || $_ =~ /Title: / || $_ =~ /Album: / || $_ =~ /Track: / || $_ =~ /Date: / || $_ =~ /Genre: / ){
- my @temp = split(/: /,$_);
- push(@currentsong,$temp[1]);
- }
- else {
- next;
+ $songs{$key}="$file|$Time|$Artist|$Title|$Album|$Track|$Date|$Genre";
+ push(@artist,$Artist);push(@album,$Album);push(@year,$Date);push(@genre,$Genre);
+ $key="";$file="";$Time="";$Artist="";$Title="";$Album="";$Track="";$Date="";$Genre="";
}
+ elsif ( $_ =~ /key: / ){my @temp = split(/: /,$_);$key=$temp[1];}
+ elsif ( $_ =~ /file: / ){my @temp = split(/: /,$_);$file=$temp[1];}
+ elsif ( $_ =~ /Time: / ){my @temp = split(/: /,$_);$Time=$temp[1];}
+ elsif ( $_ =~ /Artist: / ){my @temp = split(/: /,$_);$Artist=$temp[1];}
+ elsif ( $_ =~ /Title: / ){my @temp = split(/: /,$_);$Title=$temp[1];}
+ elsif ( $_ =~ /Album: / ){my @temp = split(/: /,$_);$Album=$temp[1];}
+ elsif ( $_ =~ /Track: / ){my @temp = split(/: /,$_);$Track=$temp[1];}
+ elsif ( $_ =~ /Date: / ){my @temp = split(/: /,$_);$Date=$temp[1];}
+ elsif ( $_ =~ /Genre: / ){my @temp = split(/: /,$_);$Genre=$temp[1];}
+ else {next;}
}
-
+
my %hash = map{ $_, 1 }@artist;
@artist = sort keys %hash;
my %hash = map{ $_, 1 }@album;
PROG = mpfire
PAK_VER = 2
-DEPS = "mpd mpc alsa libshout libogg libmad libid3tag"
+DEPS = "mpd mpc alsa libshout libogg libmad libid3tag libvorbis"
###############################################################################
# Top-level Rules
install -v -m 755 $(DIR_SRC)/config/mpfire/mpfire.pl /var/ipfire/mpfire/bin
install -v -m 644 $(DIR_SRC)/config/mpfire/mpd.conf /var/ipfire/mpfire/
install -v -m 644 $(DIR_SRC)/config/mpfire/webradio /var/ipfire/mpfire/
- chown nobody.nobody /var/ipfire/mpfire/{settings,playlist.m3u,webradio,mpd.conf}
+ chown root.nobody /var/ipfire/mpfire/{settings,playlist.m3u,webradio,mpd.conf}
+ chown root.nobody /var/ipfire/mpfire/db/mpd.db
@$(POSTBUILD)
--- /dev/null
+#!/bin/sh
+# Begin $rc_base/init.d/mpd
+
+# Based on sysklogd script from LFS-3.1 and earlier.
+# Rewritten by Gerard Beekmans - gerard@linuxfromscratch.org
+# ALSA specific parts by Mark Hymers - markh@linuxfromscratch.org
+# Stores mixer settings in the default location: /etc/asound.state
+
+. /etc/sysconfig/rc
+. $rc_functions
+
+case "$1" in
+ start)
+ boot_mesg "Starting MPD..."
+ /bin/nice --20 /usr/bin/mpd
+ evaluate_retval
+ ;;
+ stop)
+ boot_mesg "Stopping MPD..."
+ /usr/bin/mpd --kill
+ evaluate_retval
+ ;;
+ status)
+ statusproc /usr/bin/mpd
+ ;;
+
+ *)
+ echo "Usage: $0 (start|stop|status)"
+ exit 1
+ ;;
+esac
+
+# End $rc_base/init.d/alsa
extract_files
touch /etc/asound.state
-ln -svf ../init.d/alsa /etc/rc.d/rc3.d/S65alsa
-ln -svf ../init.d/alsa /etc/rc.d/rc0.d/K35alsa
-ln -svf ../init.d/alsa /etc/rc.d/rc6.d/K35alsa
+ln -svf /etc/init.d/alsa /etc/rc.d/rc3.d/S65alsa
+ln -svf /etc/init.d/alsa /etc/rc.d/rc0.d/K35alsa
+ln -svf /etc/init.d/alsa /etc/rc.d/rc6.d/K35alsa
. /opt/pakfire/lib/functions.sh
extract_files
-
chown nobody.nobody -Rv /var/ipfire/mpfire
+ln -svf /etc/init.d/mpd /etc/rc.d/rc3.d/S65mpd
+ln -svf /etc/init.d/mpd /etc/rc.d/rc0.d/K35mpd
+ln -svf /etc/init.d/mpd /etc/rc.d/rc6.d/K35mpd
+touch /var/log/mpd.error.log
+touch /var/log/mpd.log