# HG changeset patch # User Christophe Lincoln # Date 1332254691 -3600 # Node ID 859162cb75e5372a351a6821ce8cde68542ed088 # Parent 2b97bc6859dfbcf0f76b9689352cbe6b0a5e9c80 Add mirror/root for file at mirror.slitaz.org (from slitaz-dev-tools/mirror-tools) diff -r 2b97bc6859df -r 859162cb75e5 mirror/README --- a/mirror/README Tue Mar 20 15:24:16 2012 +0100 +++ b/mirror/README Tue Mar 20 15:44:51 2012 +0100 @@ -8,6 +8,7 @@ * files : Custom system configurations files * info : Mirror web interface at http://mirror.slitaz.org/info/ + * root : File for the root directory of http://mirror.slitaz.org/ Host : mirror.slitaz.org diff -r 2b97bc6859df -r 859162cb75e5 mirror/mirror --- a/mirror/mirror Tue Mar 20 15:24:16 2012 +0100 +++ b/mirror/mirror Tue Mar 20 15:44:51 2012 +0100 @@ -9,7 +9,7 @@ REPOS="/home/slitaz/repos" WWW="/var/www" -VHOST="$WWW/mirror" +MIRROR="$WWW/mirror" INFO="$WWW/mirror-info" TINY="$WWW/pizza/tiny" BACKUPS="/home/backups" @@ -22,6 +22,7 @@ up-info Update mirror.slitaz.org/info/ web interface up-tiny Update tiny.slitaz.org/ web interface up-mf Update mf.slitaz.org web interface + up-mirror Update mirror.slitaz.org files EOT } @@ -34,10 +35,14 @@ up-tiny) echo "Updating: tiny.slitaz.org..." cd $REPOS/slitaz-pizza && hg pull -u - cp -a php/tiny/* $TINY + cp -a php/tiny/* $TINY ;; up-mf) echo "Updating: mf.slitaz.org..." cd $REPOS/slitaz-forge && hg pull -u ;; + up-mirror) + echo "Updating: mirror.slitaz.org files..." + cd $REPOS/slitaz-forge && hg pull -u + cp -a mirror/root/* $MIRROR ;; *) usage ;; esac diff -r 2b97bc6859df -r 859162cb75e5 mirror/root/dir-generator.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mirror/root/dir-generator.php Tue Mar 20 15:44:51 2012 +0100 @@ -0,0 +1,464 @@ + + + + + SliTaz mirror redirection + + + + + + +, + * Pascal Bellard + * Christophe Lincoln + * + * + * GNU License Agreement + * --------------------- + * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * http://www.gnu.org/licenses/gpl.txt + */ + +// Get the path (cut out the query string from the request_uri) +list($path) = explode('?', $_SERVER['REQUEST_URI']); + + +// Get the path that we're supposed to show. +$path = ltrim(rawurldecode($path), '/'); + + +if(strlen($path) == 0) { + $path = "./"; +} + + +// Can't call the script directly since REQUEST_URI won't be a directory +if($_SERVER['PHP_SELF'] == '/'.$path) { + redirect(); +// die("Unable to call " . $path . " directly."); +} + + +$vpath = ($path != "./")?$path:""; +// Make sure it is valid. +if(!is_dir($path)) { +// die("" . $path . " is not a valid path."); + $path = dirname($_SERVER["SCRIPT_FILENAME"]); + list($vpath) = explode('?', $_SERVER['REQUEST_URI']); + $vpath = ltrim(rawurldecode($vpath), '/'); +} + + +// +// This function returns the file size of a specified $file. +// +function format_bytes($size, $precision=1) { + $sizes = array('Y', 'Z', 'E', 'P', 'T', 'G', 'M', 'K', ''); + $total = count($sizes); + + while($total-- && $size > 1024) $size /= 1024; + if ($sizes[$total] == '') { + $size /= 1024; + $total--; + } + return sprintf('%.'.$precision.'f', $size).$sizes[$total]; +} + +// +// Get some variables from /etc/lighttpd/lighttpd.conf +// +$conf_lightty = file_get_contents("/etc/lighttpd/lighttpd.conf"); + +function get_conf($var,$start,$stop,$default='') { + global $conf_lightty; + + if (!preg_match('/'.$var.'/',$conf_lightty)) return $default; + $filter = '/(.*\n)*'.$var.'\s*=\s*'.$start.'(([^'.$stop.']*\n*)*)'.$stop.'(.*\n)*/'; + return preg_replace($filter,'$2',$conf_lightty); +} + +$encoding = get_conf('dir-listing.encoding','"','"','ascii'); +$external_css = get_conf('dir-listing.external-css','"','"'); + +$show_hidden_files = false; +if (get_conf('dir-listing.hide-dotfile','"','"','disable') == "disable") { + $show_hidden_files = true; +} +// get_conf('dir-listing.exclude','\(','\)'); +// get_conf('dir-listing.set-footer','"','"'); + +$mime_types = array(); +foreach (explode(',',get_conf('mimetype.assign','\(','\)')) as $item) { + $filter = '/\s*"(.*)"\s*=>\s*"(.*)".*/'; + $val = explode(',',preg_replace($filter,'$1,$2',$item)); + if (isset($val[1])) $mime_types[$val[0]] = $val[1]; +} + +// +// This function returns the mime type of $file. +// +function get_file_type($file) { + global $mime_types; + + $file = basename($file); + $default_type = "application/octet-stream"; + if (isset($mime_types[$file])) { + return $mime_types[$file]; + } + $pos = strrpos($file, "."); + if ($pos === false) { + return $default_type; + } +//FIXME .tar.gz + $ext = '.'.rtrim(substr($file, $pos+1), "~"); + if (isset($mime_types[$ext])) { + return $mime_types[$ext]; + } + return $default_type; +} + +//$slitaz_style = (dirname($_SERVER["PHP_SELF"]) == '/'); +//$slitaz_style = ($_SERVER["SERVER_NAME"] == "mirror.slitaz.org"); +$slitaz_style = preg_match("/mirror\.slitaz\./",$_SERVER["SERVER_NAME"]); +if ($slitaz_style) { + $fvalue = ""; + if (isset($_GET['f'])) $fvalue = 'value="'.$_GET['f'].'"'; + print << + + + Index of /$vpath + + + + + + + + + + + + + + +
+ +
+

Online Tools

+ +
+ +
+

Welcome to Open Source!

+EOT; + if (preg_match("/mirror\.slitaz\./",$_SERVER["SERVER_NAME"])) print <<This is the SliTaz GNU/Linux main mirror. The server runs naturally + SliTaz (stable) in an lguest virtual machine provided by + ADS. + Mirror info...

+EOT; + print << +

+ +
+
+ +
+EOT; + +// Mirror list +$mirrors = array(); +$fp = @fopen(dirname($_SERVER["SCRIPT_FILENAME"])."/mirrors","r"); +if ($fp) { + while (($line = fgets($fp)) !== false) { + $line = chop($line); + $url = parse_url($line); + if ($_SERVER["SERVER_NAME"] == $url['host']) continue; + $host = explode('.',$url['host']); + $mirrors[$host[count($host)-2].".". + $host[count($host)-1]] = $line; + } +} +fclose($fp); +foreach($mirrors as $name => $url) { + echo "$name\n"; +} + +print << + + +
+ +EOT; +} +else { + +// Print the heading stuff +print " + + + + Index of /" .$vpath. " +"; +if ($external_css != '') { +print " +"; +} +else { +print " +"; +} +print " + +

Index of /" . $vpath ."

+"; +} + +print "
+ +"; + +function my_is_file($path) // 2G+ file support +{ + exec("[ -f '".$path."' ]", $tmp, $ret); + return $ret == 0; +} + +function my_filesize($path) // 2G+ file support +{ + return rtrim(shell_exec("stat -Lc %s '".$path."'")); +} + +function my_filemtime($path) // 2G+ file support +{ + return rtrim(shell_exec("stat -Lc %Y '".$path."'")); +} + +function my_filemtimeasc($path) // 2G+ file support +{ + return rtrim(shell_exec("date -r '".$path."' '+%Y-%b-%d %H:%M:%S'")); +} + +// Get all of the folders and files. +$folderlist = array(); +$filelist = array(); +if($handle = @opendir($path)) { + while(($item = readdir($handle)) !== false) { + if ($item == "index.php") continue; + if ($item == "dir-generator.php") continue; + if (isset($_GET['f'])) { + $filter = $_GET['f']; + if (substr($filter,0,1) != '/') + $filter = '/'.$filter.'/i'; + if (!preg_match($filter,$item)) continue; + } + if(is_dir($path.'/'.$item) and $item != '.' and $item != '..') { + $folderlist[] = array( + 'name' => $item, + 'size' => 0, + 'modtime'=> filemtime($path.'/'.$item), + 'modtimeasc'=> my_filemtimeasc($path.'/'.$item), + 'file_type' => "Directory" + ); + } + elseif(my_is_file($path.'/'.$item)) { + if(!$show_hidden_files) { + if(substr($item, 0, 1) == "." or substr($item, -1) == "~") { + continue; + } + } + $filelist[] = array( + 'name'=> $item, + 'size'=> my_filesize($path.'/'.$item), + 'modtime'=> my_filemtime($path.'/'.$item), + 'modtimeasc'=> my_filemtimeasc($path.'/'.$item), + 'file_type' => get_file_type($path.'/'.$item) + ); + } + } + closedir($handle); +} + + +if(!isset($_GET['s'])) { + $_GET['s'] = 'name'; +} + +// Figure out what to sort files by +$file_order_by = array(); +foreach ($filelist as $key=>$row) { + $file_order_by[$key] = $row[$_GET['s']]; +} + +// Figure out what to sort folders by +$folder_order_by = array(); +foreach ($folderlist as $key=>$row) { + $folder_order_by[$key] = $row[$_GET['s']]; +} + +// Order the files and folders +$sort_type = SORT_ASC; +$order = "&o=d"; +if(isset($_GET['o'])) { + $sort_type = SORT_DESC; + $order = ""; +} +array_multisort($folder_order_by, $sort_type, $folderlist); +array_multisort($file_order_by, $sort_type, $filelist); + + +// Show sort methods +print ""; + +$sort_methods = array(); +$sort_methods['name'] = "Name"; +$sort_methods['modtime'] = "Last Modified"; +$sort_methods['size'] = "Size"; +$sort_methods['file_type'] = "Type"; + +foreach($sort_methods as $key=>$item) { + if ($_GET['s'] == $key) $key = "$key$order"; + print ""; +} +print "\n\n"; + + + +// Parent directory link +if($path != "./") { + print ""; + print ""; + print ""; + print "\n"; +} + + + +// Print folder information +foreach($folderlist as $folder) { + print ""; + print ""; + print ""; + print "\n"; +} + + +// Print file information +foreach($filelist as $file) { + print ""; + print ""; + print ""; + print "\n"; +} + +// Print ending stuff +$soft = explode('/',$_SERVER["SERVER_SOFTWARE"]); +$tag = get_conf('server.tag','"','"',$soft[0].' <'.$soft[1].'>'); +print " +
$item
Parent Directory/ -  Directory
" .htmlentities($folder['name']). "/" . $folder['modtimeasc'] . "-  " . $folder['file_type'] . "
" .htmlentities($file['name']). "" . $file['modtimeasc'] . "" . format_bytes($file['size']) . "" . $file['file_type'] . "
+
"; +if ($slitaz_style) { ?> + + +
+ + + + + +
".$tag." + + +
+ +"; +print " + "; +?> diff -r 2b97bc6859df -r 859162cb75e5 mirror/root/mirrors --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mirror/root/mirrors Tue Mar 20 15:44:51 2012 +0100 @@ -0,0 +1,17 @@ +http://mirror.slitaz.org/ +http://mirror.switch.ch/ftp/mirror/slitaz/ +ftp://mirror.switch.ch/mirror/slitaz/ +http://www.gtlib.gatech.edu/pub/slitaz/ +ftp://ftp.gtlib.gatech.edu/pub/slitaz/ +http://download.tuxfamily.org/slitaz/ +ftp://download.tuxfamily.org/slitaz/ +http://mirror.lupaworld.com/slitaz/ +http://slitaz.c3sl.ufpr.br/ +ftp://slitaz.c3sl.ufpr.br/slitaz/ +http://slitaz.mirror.garr.it/mirrors/slitaz/ +ftp://slitaz.mirror.garr.it/mirrors/slitaz/ +ftp://ftp.pina.si/slitaz/ +http://distro.ibiblio.org/pub/linux/distributions/slitaz/ +http://ftp.ch.xemacs.org/ftp/pool/2/mirror/slitaz/ +ftp://ftp.ch.xemacs.org//pool/2/mirror/slitaz/ +http://mirror.clarkson.edu/slitaz/ diff -r 2b97bc6859df -r 859162cb75e5 mirror/root/pxe/defaults.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mirror/root/pxe/defaults.cfg Tue Mar 20 15:44:51 2012 +0100 @@ -0,0 +1,17 @@ +default menu.c32 +prompt 0 + +MENU TITLE Slitaz Web boot http://www.slitaz.org/ +ALLOWOPTIONS 0 +MENU MARGIN 0 +MENU ROWS 17 +MENU COLOR BORDER 37;44 #40000000 #00000000 std +MENU COLOR TITLE 1;33;44 #c00090f0 #00000000 std +MENU COLOR SCROLLBAR 37;44 #40000000 #00000000 std + +#MENU COLOR TIMEOUT_MSG 1;33;44 #c00090f0 #00000000 std +#MENU COLOR TIMEOUT 37;40 #80ffffff #00000000 std +MENU TIMEOUTROW 25 +MENU AUTOBOOT Start cooking in # second{,s} +timeout 100 +TOTALTIMEOUT 9000 diff -r 2b97bc6859df -r 859162cb75e5 mirror/root/pxe/mkcfg.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mirror/root/pxe/mkcfg.sh Tue Mar 20 15:44:51 2012 +0100 @@ -0,0 +1,176 @@ +#!/bin/sh + +#usage: +# copy /boot/isolinux/* +# remove *.cfg +# copy then update /boot/isolinux/isolinux.cfg core.cfg + +cd $(dirname $0) + +# Status functions. +status() +{ + local CHECK=$? + echo -en "\\033[70G[ " + if [ $CHECK = 0 ]; then + echo -en "\\033[1;33mOK" + else + echo -en "\\033[1;31mFailed" + fi + echo -e "\\033[0;39m ]" +} + +directlinks() +{ + mkdir $1/$2 + ln -s .. $1/$2/$1 + ln -s ../$2.cfg $1/$2/default + ln -s ../../pxelinux.0 $1/$2/pxelinux.0 + ln -s . $1/$2/pxelinux.cfg + [ -e $1/boot ] || ln -s ../../boot $1/boot +} +for version in cooking $(ls ../boot | grep 0$) ; do + +[ "$version" = "1.0" ] && continue +echo -n "Building $version" +for i in splash.lss isolinux.msg core.cfg ; do + [ -s $version/$i ] && continue + echo -n " $version/$i not found !" + false + status + continue 2 +done +if ! grep -q $version/splash.lss $version/isolinux.msg ; then + echo "WARNING: please update $version/isolinux.msg with $version/splash.lss" +fi +rm -f $version/*-*.cfg +( cd ../boot/$version ; ls rootfs-*.gz 2> /dev/null ) | \ +sed 's/rootfs-\(.*\).gz/\1/' | while read flavor; do + lowcased=$(echo $flavor | tr [A-Z] [a-z]) + if [ "$lowcased" != "$flavor" ]; then + echo "" + echo "Warning : renaming ../boot/$version/rootfs-$flavor.gz to ../boot/$version/rootfs-$lowcased.gz" + mv ../boot/$version/rootfs-$flavor.gz ../boot/$version/rootfs-$lowcased.gz + flavor=$lowcased + fi + [ -f $version/$flavor.cfg ] && continue + cp $version/core.cfg $version/$flavor.cfg + sed -i -e "s/core-common/$flavor-common/" \ + -e "s/^label slitaz$/say Using $flavor flavor.\nlabel slitaz/" \ + -e "s/rootfs.gz/rootfs-$flavor.gz/" $version/$flavor.cfg + directlinks $version $flavor +done +for flavor in $(cd $version ; ls *.cfg | sed 's/.cfg//') ; do + echo -n " $flavor" + cat > $version/$flavor-common.cfg < $version/$flavor-$cfg.cfg + cat >> $version/$flavor-common.cfg < /dev/null ) | \ +sed 's/rootfs-\(.*\).gz/\1/' | while read flavor; do + [ -f 1.0/$flavor.cfg ] && continue + cp 1.0/core.cfg 1.0/$flavor.cfg + sed -i -e "s/core-common/$flavor-common/" \ + -e "s/rootfs.gz/rootfs-$flavor.gz/" 1.0/$flavor.cfg + directlinks 1.0 $flavor +done +directlinks 1.0 core +for flavor in $(cd 1.0; ls *.cfg | sed 's/.cfg//') ; do + echo -n " $flavor" + cat > 1.0/$flavor-common.cfg < 1.0/$flavor-$cfg.cfg + cat >> 1.0/$flavor-common.cfg <