Skip to content

Instantly share code, notes, and snippets.

@mlocati
Last active Sep 29, 2019
Embed
What would you like to do?
Install concrete5 on Android (Termux)
<?php
// Save this file as /application/bootstrap/app.php
if (!function_exists('fnmatch')) {
// Shim for fnmatch
// Code from https://www.php.net/manual/en/function.fnmatch.php#100207
define('FNM_PATHNAME', 1);
define('FNM_NOESCAPE', 2);
define('FNM_PERIOD', 4);
define('FNM_CASEFOLD', 16);
function fnmatch($pattern, $string, $flags = 0)
{
$modifiers = '';
$transforms = [
'\*' => '.*',
'\?' => '.',
'\[\!' => '[^',
'\[' => '[',
'\]' => ']',
'\.' => '\.',
'\\' => '\\\\',
];
// Forward slash in string must be in pattern:
if ($flags & FNM_PATHNAME) {
$transforms['\*'] = '[^/]*';
}
// Back slash should not be escaped:
if ($flags & FNM_NOESCAPE) {
unset($transforms['\\']);
}
// Perform case insensitive match:
if ($flags & FNM_CASEFOLD) {
$modifiers .= 'i';
}
// Period at start must be the same as pattern:
if ($flags & FNM_PERIOD) {
if (strpos($string, '.') === 0 && strpos($pattern, '.') !== 0) return false;
}
$pattern = '#^'
. strtr(preg_quote($pattern, '#'), $transforms)
. '$#'
. $modifiers;
return (bool) preg_match($pattern, $string);
}
}
# Update the system
apt update && apt upgrade -y
# Install required packages
apt install -y git mariadb php
# Start MariaDB in background
mysqld_safe --datadir="$PREFIX/var/lib/mysql" &
# Create the database for concrete5
mysql -e 'CREATE DATABASE db5;'
# Create the user for the concrete5 DB
mysql -e "CREATE USER 'u5'@'localhost' IDENTIFIED BY '12345'; GRANT ALL PRIVILEGES ON db5.* TO 'u5'@'localhost'; FLUSH PRIVILEGES;"
# Download composer
curl -sS https://getcomposer.org/installer | php
mv composer.phar "$PREFIX/bin/composer"
# Download the "c5" CLI command
curl -sSL https://raw.githubusercontent.com/concrete5/cli/master/c5 -o "$PREFIX/bin/c5"
chmod uga+rx "$PREFIX/bin/c5"
# Get concrete5
git clone --depth=1 https://github.com/concrete5/concrete5.git
# Install composer dependencies
cd concrete5
composer install
# Add the fnmatch shim
curl -sSL \
https://gist.github.com/mlocati/d1724a4f7e984eb53f53724d10c25b29/raw/1058ee8a6a8e9e11d86f1b26e5e6b4b6b7e87d3f/app.php \
-o application/bootstrap/app.php
# Install concrete5
c5 c5:install --db-server=localhost \
--db-username=u5 \
--db-password=12345 \
--db-database=db5 \
--timezone=Europe/Rome \
--site=Droid5 \
--starting-point=elemental_full \
--admin-email=admin@example.com \
--admin-password=12345 \
--language=en_US \
--site-locale=en_US
# Start the PHP development web server
php -S 0.0.0.0:8080
# Shutdown MariaDB when done
mysqladmin shutdown
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment