$out = exec("mysql --user={$_config['mysql']['USER']} --password={$_config['mysql']['PASS']} -e \"CREATE DATABASE IF NOT EXISTS {$_config['mysql']['NAME']} CHARACTER SET utf8 COLLATE utf8_general_ci;\"");
// Get latest MODX
echo date('Y-m-d H:i:s') . ' [INFO] Getting latest MODX version from modx.com...' . "\n";
$out = exec('wget -O modx.zip http://modx.com/download/latest/');
echo date('Y-m-d H:i:s') . ' [INFO] Unzipping MODX package...' . "\n";
$out = exec('unzip modx.zip');
$_ZDIR = exec('ls -F | grep "\\/" | head -1');
if ($_ZDIR == '/') {
    die(date('Y-m-d H:i:s') . ' [ERROR] Cannot find unzipped MODX folder...' . "\n");
} else {
    echo date('Y-m-d H:i:s') . ' [INFO] Moving unzipped files out of temporary directory...' . "\n";
    $out = exec("mv ./{$_ZDIR}* .; rm -r ./{$_ZDIR}");
    if (@unlink('modx.zip')) {
        echo date('Y-m-d H:i:s') . ' [INFO] Removed downloaded zip file...' . "\n";
    }
    echo date('Y-m-d H:i:s') . ' [INFO] Running into MODX setup...' . "\n";
    $out = exec("cd setup/; php ./index.php --installmode=new --config={$projectpath}config.xml");
    $out = exec("cd {$projectpath}");
    echo date('Y-m-d H:i:s') . ' [INFO] Copying ht.access to .htaccess...' . "\n";
    copy('ht.access', '.htaccess');
    if (@unlink('config.xml')) {
        echo date('Y-m-d H:i:s') . ' [INFO] Removed config XML file...' . "\n";
    }
    // load hooks
    loadHooks('install-core');
}
echo "\n\n---------------------------\nCongrats! MODX is installed!\n";
echo "Please visit http://{$projecthost}/manager/ to login.\n";
echo "User: {$adminUser}\n";
echo "Pass: {$adminPassword}\n";
echo "---------------------------\n";
<?php

/**
 * MODX ANYTHING ELSE INSTALLER
 *
 * @author Bert Oost at OostDesign.com <*****@*****.**>
 */
require_once dirname(__FILE__) . '/includes/initializer.php';
$modx->log(modX::LOG_LEVEL_INFO, 'Ready to install anything you want? Hooks will be fired!');
loadHooks('install-any');
$modx->log(modX::LOG_LEVEL_INFO, 'DONE!');
                //download file
                file_put_contents($modx->getOption('core_path') . 'packages/' . $foundPackage->signature . '.transport.zip', file_get_contents($foundPackage->location));
                /* add in the package as an object so it can be upgraded */
                /** @var modTransportPackage $package */
                $package = $modx->newObject('transport.modTransportPackage');
                $package->set('signature', $foundPackage->signature);
                $package->fromArray(array('created' => date('Y-m-d h:i:s'), 'updated' => null, 'state' => 1, 'workspace' => 1, 'provider' => 1, 'source' => $foundPackage->signature . '.transport.zip', 'package_name' => $packageName, 'version_major' => $versionSignature[0], 'version_minor' => !empty($versionSignature[1]) ? $versionSignature[1] : 0, 'version_patch' => !empty($versionSignature[2]) ? $versionSignature[2] : 0));
                if (!empty($sig[2])) {
                    $r = preg_split('/([0-9]+)/', $sig[2], -1, PREG_SPLIT_DELIM_CAPTURE);
                    if (is_array($r) && !empty($r)) {
                        $package->set('release', $r[0]);
                        $package->set('release_index', isset($r[1]) ? $r[1] : '0');
                    } else {
                        $package->set('release', $sig[2]);
                    }
                }
                $success = $package->save();
                if ($success) {
                    $package->install();
                } else {
                    $modx->log(modX::LOG_LEVEL_ERROR, 'Could not save package ' . $foundPackage->name);
                }
                break;
            }
        }
        return true;
    }
    return false;
}
loadHooks('install-packages');
$modx->log(modX::LOG_LEVEL_INFO, 'DONE!');