コード例 #1
0
ファイル: m0n0dev.php プロジェクト: rixrix/m0n0dev
function package($platform, $image_name)
{
    global $dirs;
    global $mfsroot_pad, $image_pad;
    _set_permissions($image_name);
    if (!file_exists("tmp")) {
        _exec("mkdir -p tmp");
        _exec("mkdir -p tmp/mnt");
        _exec("mkdir -p tmp/stage");
    }
    $kernel = _platform_to_kernel($platform);
    // mfsroot
    // add rootfs
    _exec("cd tmp/stage; tar -cf - -C {$image_name} ./ | tar -xpf -");
    // ...system modules
    _exec("mkdir -p tmp/stage/boot");
    _exec("mkdir -p tmp/stage/boot/kernel");
    if ($platform == "generic-pc" || $platform == "generic-pc-cdrom") {
        _exec("cp /sys/i386/compile/{$kernel}/modules/usr/src/sys/modules/acpi/acpi/acpi.ko tmp/stage/boot/kernel/");
    }
    // ...stamps
    _exec("echo \"" . basename($image_name) . "\" > tmp/stage/etc/version");
    _exec("echo `date` > tmp/stage/etc/version.buildtime");
    _exec("echo {$platform} > tmp/stage/etc/platform");
    // get size and package mfsroot
    $mfsroot_size = _get_dir_size("tmp/stage") + $mfsroot_pad;
    _exec("dd if=/dev/zero of=tmp/mfsroot bs=1k count={$mfsroot_size}");
    _exec("mdconfig -a -t vnode -f tmp/mfsroot -u 0");
    _exec("bsdlabel -rw md0 auto");
    _exec("newfs -O 1 -b 8192 -f 1024 -o space -m 0 /dev/md0c");
    _exec("mount /dev/md0c tmp/mnt");
    _exec("cd tmp/mnt; tar -cf - -C ../stage ./ | tar -xpf -");
    // dummynet.ko and ipfw.ko reside in mfsroot/boot/kernel
    _exec("mkdir -p tmp/mnt/boot/kernel");
    _exec("cp /sys/i386/compile/{$kernel}/modules/usr/src/sys/modules/dummynet/dummynet.ko tmp/mnt/boot/kernel/");
    _exec("cp /sys/i386/compile/{$kernel}/modules/usr/src/sys/modules/ipfw/ipfw.ko tmp/mnt/boot/kernel/");
    _log("---- {$platform} - " . basename($image_name) . " - mfsroot ----");
    _exec("df tmp/mnt");
    _exec("umount tmp/mnt");
    _exec("rm -rf tmp/stage/*");
    _exec("mdconfig -d -u 0");
    _exec("gzip -9 tmp/mfsroot");
    _exec("mv tmp/mfsroot.gz {$dirs['mfsroots']}/{$platform}-" . basename($image_name) . ".gz");
    // .img
    if ($platform != "generic-pc-cdrom") {
        // add mfsroot
        _exec("cp {$dirs['mfsroots']}/{$platform}-" . basename($image_name) . ".gz " . "tmp/stage/mfsroot.gz");
        // ...boot
        _exec("mkdir -p tmp/stage/boot");
        _exec("mkdir -p tmp/stage/boot/kernel");
        _exec("cp /usr/obj/usr/src/sys/boot/i386/loader/loader tmp/stage/boot/");
        _exec("cp {$dirs['boot']}/{$platform}/loader.rc tmp/stage/boot/");
        // ...conf
        _exec("mkdir -p tmp/stage/conf");
        _exec("cp {$dirs['phpconf']}/config.xml tmp/stage/conf");
        _exec("cp /sys/i386/compile/{$kernel}/kernel.gz tmp/stage/kernel.gz");
        // get size and populate
        $image_size = _get_dir_size("tmp/stage") + $asterisk_size + $image_pad;
        $image_size += 16 - $image_size % 16;
        _exec("dd if=/dev/zero of=tmp/image.bin bs=1k count={$image_size}");
        _exec("mdconfig -a -t vnode -f tmp/image.bin -u 0");
        _exec("bsdlabel -Brw -b /usr/obj/usr/src/sys/boot/i386/boot2/boot md0 auto");
        _exec("newfs -O 1 -b 8192 -f 1024 -o space -m 0 /dev/md0a");
        _exec("mount /dev/md0a tmp/mnt");
        _exec("cd tmp/mnt; tar -cf - -C ../stage ./ | tar -xpf -");
        _log("---- {$platform} - " . basename($image_name) . " - system partition ----");
        _exec("df tmp/mnt");
        _exec("umount tmp/mnt");
        // cleanup
        _exec("mdconfig -d -u 0");
        _exec("gzip -9 tmp/image.bin");
        _exec("mv tmp/image.bin.gz {$dirs['images']}/m0n0wall-{$platform}-" . basename($image_name) . ".img");
        // .iso
    } else {
        if ($platform == "generic-pc-cdrom" && !file_exists($dirs['images'] . "/{$platform}-{$version}-" . basename($image_name) . ".iso")) {
            _exec("mkdir -p tmp/cdroot");
            _exec("cp " . $dirs['mfsroots'] . "/{$platform}-" . basename($image_name) . ".gz tmp/cdroot/mfsroot.gz");
            _exec("cp /sys/i386/compile/{$kernel}/kernel.gz tmp/cdroot/kernel.gz");
            _exec("mkdir -p tmp/cdroot/boot");
            _exec("cp /usr/obj/usr/src/sys/boot/i386/cdboot/cdboot tmp/cdroot/boot/");
            _exec("cp /usr/obj/usr/src/sys/boot/i386/loader/loader tmp/cdroot/boot/");
            _exec("cp " . $dirs['boot'] . "/{$platform}/loader.rc tmp/cdroot/boot/");
            _exec("cp /usr/obj/usr/src/sys/boot/i386/boot2/boot tmp/cdroot/boot/");
            _exec("mkisofs -b \"boot/cdboot\" -no-emul-boot -A \"m0n0wall CD-ROM image\" " . "-c \"boot/boot.catalog\" -d -r -publisher \"m0n0.ch\" " . "-p \"Your Name\" -V \"m0n0wall_cd\" -o \"m0n0wall.iso\" tmp/cdroot/");
            _exec("mv m0n0wall.iso " . $dirs['images'] . "/m0n0wall-cdrom-" . basename($image_name) . ".iso");
        }
    }
    _exec("rm -rf tmp");
}
コード例 #2
0
                _set_users("add", $userid, $groupid);
                break;
            case ' DELETE ':
                _page_sechead("exhibit.png", "User Management");
                _set_users("delete", $userid, $groupid);
                break;
            default:
                _page_sechead("exhibit.png", "User Management");
                break;
        }
        _display_users();
        break;
    case 'rolls':
    default:
        $roll = $_REQUEST['roll'];
        $library = $_REQUEST['library'];
        $public = $_REQUEST['public'];
        $group = $_REQUEST['group'];
        if (!isset($roll) and !isset($library)) {
            _page_sechead("exhibit.png", "Roll Management");
            _display_permissions();
        } elseif (isset($public) and isset($group)) {
            _page_sechead("exhibit.png", "Roll Management");
            _set_permissions($roll, $library, $public, $group);
        } else {
            _page_sechead("error.png", "An error occurred updating permissions.");
            _display_permissions();
        }
        break;
}
_page_footer();