#!/bin/bash - # Linux bash invoked as sh lacks of $RANDOM #exec > /tmp/log 2>&1 #set -x # # (c) Thu Jan 15 11:11:35 CET 2015 # Version: 0.3.1a # # CGI for browsing/streaming/searching MP3 collections # # Requires: # POSIX bourne shell (sh, bash, ksh) # perl # recode # charconv : http://www.chemie.fu-berlin.de/chemnet/use/charconv.html # zip : http://www.info-zip.org/ # mp3info: http://www.ibiblio.org/mp3info/ # id3v2 # jhead # dewplayer: http://www.alsacreations.fr/dewplayer.html # convert (ImageMagick) # # set -f #ulimit -f 0 # Uncomment these if your /bin/sh understand them. ulimit -c 0 ulimit -d 8192 ulimit -t 60 #ulimit -v 8192 ulimit -m 8192 # # Variables you have to customize # (put them on /usr/local/etc/stream.conf ) # VERSION="0.3.1a" . /usr/local/etc/stream.conf # IDX: This directory has: # list-*txt file with relative paths to all albums # songs.txt relative path of every song #### IDX=/raid/media/music/index/ # ROOT: Your music store # # Music sould be stored there as: # Initial/Artist/year-album/track-title.mp3 # Example: D/Dead Can Dance/1990-Aion/04-The Song of the Sybil.mp3 # #### ROOT=/raid/media/music # XMLCACHE: where XML playlists are stored. #### XMLCACHE=/raid/www/music/tmp/ #### XMLCACHEURI=/music/tmp/ # OWNER: POSIX owner of files for filtered listings #### OWNER=spd # URL of this script, without host part #### MYNAME=/cgi/stream # Main page #### MAIN=/music/ # Where is dewplayer #### PLAYERDIR=/music/player/ #### DEWPLAYER=${PLAYERDIR}dewplayer-playlist.swf #### # # End of customizable options # #### PATH=$PATH:/usr/local/bin LANG=C; export LANG LANGUAGE=C; export LANGUAGE LC_ALL=C; export LC_ALL error=: errormsg="" # URL decoding htd() { perl -pe 's/\%([A-Fa-f0-9]{2})/pack("C", hex($1))/seg;' } # trim unwanted (dangerous) characters sanitize() { tr -c -d "0-9,a-z,A-Z, +=:.!?/\-()'\[\]" | sed -e 's,//*,/,g' |\ sed -e 's,/\.[\.]*,/.,g' -e 's,\/\.\/,/,g' -e 's,^\.[\.]*,/,g' } # URL encoding for spaces (we are using ASCII-7 for file names) hte() { sed -e 's/ /%20/g' } htmlheader() { echo "Server: Apache" echo "Content-type: text/html; charset=ISO-8859-1" echo } htmlhead() { cat <<-EOF
"
echo "$*" #echo $* echo " | "
echo "
Please, login first.