From 6b3a39b6395a6bafe1495f88fc2ea02ec9b6b6a0 Mon Sep 17 00:00:00 2001 From: jengo Date: Sat, 19 May 2001 03:43:16 +0000 Subject: [PATCH] Added in new experimental toy to create ram disk and copy a phpgroupware install to it. --- phpgwapi/doc/create_ramdisk.php.txt | 87 +++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 phpgwapi/doc/create_ramdisk.php.txt diff --git a/phpgwapi/doc/create_ramdisk.php.txt b/phpgwapi/doc/create_ramdisk.php.txt new file mode 100644 index 0000000000..bbe0916c06 --- /dev/null +++ b/phpgwapi/doc/create_ramdisk.php.txt @@ -0,0 +1,87 @@ + * + * -------------------------------------------- * + * 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. * + \**************************************************************************/ + + /* $Id$ */ + + /* !!! WARNING !!! + ** This is highley experimental! Do NOT run it unless you know what you are doing! + ** You can serious screaw things up! + ** + ** Requirements: + ** - Must be run as root + ** - You need to have RAM disk support complied into the kernel + ** - You have to have the CGI binary for PHP + ** - This ONLY works with Linux + ** - The 2.2 kernel is limited to 20 RAM disks, so you will have to cut down on what you copy over + ** - I wouldn't run this on a server with less then 196 MB of RAM. If it has less, preformance + ** will only decrease. Since proccess will need to swap out to disk. + ** + ** The phpGroupWare development team does not support this program in anyway. If it breaks + ** or messes up your system, don't email us. Don't submit bug reports. If you do find ways to make + ** it better, please submit patches directly to me. jengo@phpgroupware.org + */ + + $debug = True; + + // Locations of your perminate copy, you will need it to be setup already + define('HARD_COPY','/home/jengo/public_html'); + // Where you want your install to be + define('RAM_COPY','/var/www/html'); + + function command($command) + { + global $debug; + + if ($debug) + { + echo $command . "\n"; + } + else + { + system($command); + } + } + + command('mke2fs /dev/ram0 200'); + command('mkdir ' . RAM_COPY . '/phpgroupware'); + command('mount -t ext2 /dev/ram0 ' . RAM_COPY . '/phpgroupware'); + command('cp ' . HARD_COPY . '/phpgroupware/* ' . RAM_COPY . '/phpgroupware'); + + $ram_drive_num = 1; + $dh = opendir(HARD_COPY . '/phpgroupware/'); + while ($file = readdir($dh)) + { + // The 2.2 kernel can only have 20 ram disks + if ($ram_drive_num == 21) + { + exit; + } + + if ($file != '.' && $file != '..' && $file != 'CVS' && $file != 'phpgroupware' && is_dir($file)) + { + $_du_string = 'du -s ' . HARD_COPY . '/phpgroupware/' . $file; + $_du = `$_du_string`;; + preg_match('/(\w+)\s/',$_du,$du); + $du_size = ereg_replace(' ','',$du[0]); + + // Make it slighty larger, so the files copy correctly + $du_size = $du_size + 400; + + command('mke2fs /dev/ram' . $ram_drive_num . ' ' . $du_size); + command('mkdir ' . RAM_COPY . '/phpgroupware/' . $file); + command('mount -t ext2 /dev/ram' . $ram_drive_num . ' ' . RAM_COPY . '/phpgroupware/' . $file); + command('cp -R ' . HARD_COPY . '/phpgroupware/' . $file . ' ' . RAM_COPY . '/phpgroupware/' . $file); + + $ram_drive_num++; + echo "\n"; + } + }