Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
duild:
.PHONY: test
.DEFAULT_GOAL := help

help: ## Output usage documentation
@echo "Usage: make COMMAND [args]\n\nCommands:\n"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'

duild: ## Build necessary image for building packages
cd image && IMAGE_NAME=php-fpm-7.1-alpine ../hooks/build

.PHONY: test
test: test-static-analysis test-environment
test: lint env-validate ## Run all tests

test-environment: duild
env-validate: duild ## Testing requirements for environment
cd test && ./run.sh

test-static-analysis:
shellcheck --exclude=SC2148 Makefile
lint: ## Run static analysis
shellcheck --exclude=SC2148,SC2046 Makefile
shellcheck hooks/*
shellcheck test/*.sh
shellcheck test/**/*.sh
2 changes: 2 additions & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.env
core
Empty file added example/app/.gitkeep
Empty file.
Empty file added example/core/.gitkeep
Empty file.
10 changes: 10 additions & 0 deletions example/default.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
MYSQL_ROOT_PASSWORD=root

UMI_DB_NAME=umi
UMI_DB_HOSTNAME=db
UMI_DB_USERNAME=umi
UMI_DB_PASSWORD=umi
UMI_TEMPLATE=demodizzy

UMI_DOMAIN=localhost
UMI_KEY=%KEY%
42 changes: 42 additions & 0 deletions example/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
version: '3.3'

services:

runtime:
image: ware/umi.cms:php-fpm-7.1-alpine
restart: always
env_file: .env
depends_on:
- db
volumes:
- "./core:/var/www/html"
- "./etc/php/php.ini:/usr/local/etc/php/php.ini"

db:
image: mysql:5.5
restart: always
volumes:
- data-db:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=${UMI_DB_NAME}
- MYSQL_USER=${UMI_DB_USERNAME}
- MYSQL_PASSWORD=${UMI_DB_PASSWORD}

web:
image: nginx
restart: always
depends_on:
- runtime
ports:
- "80:80"
- "443:443"
volumes:
- "./core:/var/www/html"
- "./app:/var/www/html/templates/app"
- "./etc/nginx/default.conf:/etc/nginx/conf.d/default.conf"
- "./etc/certs:/etc/nginx/certs"

volumes:
data-db:
driver: local
17 changes: 17 additions & 0 deletions example/etc/certs/localhost.crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
-----BEGIN CERTIFICATE-----
MIICsjCCAhugAwIBAgIJAK9HXB0+bKUaMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV
BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX
aWRnaXRzIFB0eSBMdGQwIBcNMTcwNjI3MTkwMTE2WhgPMjA4NTA3MTUxOTAxMTZa
MEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJ
bnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJ
AoGBALvW04ukqYNjqoG70UM3RDlPVYtExJAUapDDuxYm6j861/LPPPFjFOT3XygC
WDRGJAQuSx+SSU8tD+scsZwl1sKppLX19BbnDAWxXVuCoxD7CdL+HORQ/oYCWVn8
6L1Nucn41NkCytz/lVMYYIu0U3Jpib7XvV2sRgVvS9byjT9xAgMBAAGjgacwgaQw
HQYDVR0OBBYEFJWQDkQ3kfZNEFvRd7JT3frl0fjSMHUGA1UdIwRuMGyAFJWQDkQ3
kfZNEFvRd7JT3frl0fjSoUmkRzBFMQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29t
ZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkggkAr0dc
HT5spRowDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOBgQAt8ASJ/0zYHOIp
WBOKSbammIFLnh/2Mttosi/HWpmr0+5GMN7yAPZKadK8XHbg1D4zw7YaJ18EBIcu
Fp9+Dvs/uyvzG9Q4oJWt4eYTY4uu8GYv0jaQnBmybQZfrkf8VLSCPZ0SPVc1+vBs
Fsm4eOUWHCfe11QxWE/b6q2zwUqULQ==
-----END CERTIFICATE-----
15 changes: 15 additions & 0 deletions example/etc/certs/localhost.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQC71tOLpKmDY6qBu9FDN0Q5T1WLRMSQFGqQw7sWJuo/Otfyzzzx
YxTk918oAlg0RiQELksfkklPLQ/rHLGcJdbCqaS19fQW5wwFsV1bgqMQ+wnS/hzk
UP6GAllZ/Oi9TbnJ+NTZAsrc/5VTGGCLtFNyaYm+171drEYFb0vW8o0/cQIDAQAB
AoGAWJn3hPnxn3EmnzU5ewwZmTLLtfqFATUwIwLAP62xdovKCtUn+PB0jaAFeXjJ
pDaljHdNpiG5hKhLxuns+St8Bd1P1/sZ7a4m8HXpW3JiE8yCBYXxUFNrCJH3pExs
KnM3o+S2woZ9RT8UzWdzODIhQgRmWERbeghtnkOJkFkkg6UCQQDhDhYRk+VkNQTh
1njsRDR+0C11oF57ioggWmzDlRaDEYU0WnqoIjvXNXgljo347zA74S2NJzGI52Dj
feinvLhHAkEA1aq+5/Icn/5Cf8vGOd9Po+cD9xWokVx5ETStrDOBKp7NWz32do1F
MN7i8BlN7N5ht2X/NAwJeTEXADD557JehwJBANb/LfX849enDtLwoPSU89Fx7vvA
CILdBM5jlCQD+U2dHzO0fBjDG4esfOrkFJ0LY3jQ1UNTfe7bm6O4VNppX2ECQEMA
WwMS+gT1z1aRyORG8YtdGvI1WXnTvKc3lKpmMD/0MkNFZ+7/F85eZl2SIcyAY7YG
BwQELkhRq3vE3+jXFysCQFW8Eq1qzfv07DInCz6KJ3OuN+AvPxaNnuSh4ENHMxS0
jsHubtcvg7w6jKsBYuifVba5bp/pqC9/xZctoEkItVI=
-----END RSA PRIVATE KEY-----
79 changes: 79 additions & 0 deletions example/etc/nginx/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
worker_processes 4;

http {
include mime.types;
default_type application/octet-stream;

server {
listen 80 default_server;
server_name localhost;
root /var/www/html;


access_log /var/log/nginx/access.all.log;
error_log /var/log/nginx/error.log warn;

default_type 'text/plain';

try_files /sys-temp/static-cache/$host/$uri/index.html

if ( $request_uri ~ "^/(images|tinymce|install.php|install_update.php|captcha.php|styles|css|\.css|js|runscripts)") { break; }


if (-e $request_filename) {
rewrite ^/(sys\-temp|cache|xmldb|static|packages)\/.*$ /500/ break;
}

if (!-e $request_filename) {
rewrite ^/robots\.txt /sbots.php?path=$1&$query_string last;
rewrite ^/sitemap\?([0-9]*).xml /sitemap.php?id=$1 last;
rewrite ^(.*)\.xml$ /index.php?xmlMode=force&path=$1&$query_string last;
rewrite ^/(udata|upage|uobject|ufs|usel|ulang|utype|umess|uhttp):?(\/\/)?(.*)$ /releaseStreams.php?scheme=$1&path=$3&$query_string last;
rewrite ^(.*)\.json$ /index.php?jsonMode=force&path=$1&%query_string last;
rewrite ^/.* /index.php?path=$fastcgi_script_name&$query_string last;
}

location ~* ^/(images|files|logs)/.+\.(php|php3|php4|php5|phtml|phps|pl|pm)$ {
deny all;
}

location / {
rewrite ^/~/([0-9]+)$ /tinyurl.php?id=$1 break;
index index.php;
}

location ~* (config\.ini|install\.ini|install\.log|umi\.nginx\.conf|dbview\.php|umibackup) {
rewrite ^(.*)$ / permanent;
}

location ^~ /(config\.ini|classes|logs|libs|sys-temp|tpls|umaps|usels|xsltTpls) {
deny all;
}

location ^~ /styles/common/other/elfinder/php/ {
location ~.*\.(php)?$
{
deny all;
}
}

location ~* /files/ { }

location ~* ^.+\.(php)$ {
fastcgi_pass runtime:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_connect_timeout 3060;
fastcgi_send_timeout 3180;
fastcgi_read_timeout 3180;
fastcgi_buffer_size 32k;
fastcgi_buffers 4 32k;
fastcgi_busy_buffers_size 32k;
fastcgi_temp_file_write_size 32k;
fastcgi_temp_path /tmp;

}
}
}
######################## UMI_CMS_NGINX_END ############################
58 changes: 58 additions & 0 deletions example/etc/script/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env sh

set -e

IP=$(ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}')
UMI_IP="${UMI_IP:-"${IP}"}"
UMI_DOMAIN="${UMI_DOMAIN:-"localhost"}"
UMI_TEMPLATE="${UMI_TEMPLATE:-"_blank"}"

cat > install.ini <<- EOF
[SERVER]
phppath=$(which php)

[LICENSE]
key = "${UMI_KEY}"
domain = "${UMI_DOMAIN}"
ip = "${UMI_IP}"

[BACKUP]
mode = "none"

[DB]
host = "${UMI_DB_HOSTNAME}"
user = "${UMI_DB_USERNAME}"
password = "${UMI_DB_PASSWORD}"
dbname = "${UMI_DB_NAME}"
port = "${UMI_DB_PORT}"

[SUPERVISOR]
login = "umi"
password = "umi"
lname = "umi"
fname = "umi"
mname = "umi"
email = "umi@umi.local"

[DEMOSITE]
name = "${UMI_TEMPLATE}"

[SETUP]
sleep=10
download_by=25600
EOF

if [ ! -f "installer.php" ]; then
echo "Download Installer..."
curl -L http://updates.umi-cms.ru/updateserver \
-d type=get-installer \
-d ip=${UMI_IP} \
-d host=${UMI_DOMAIN} \
-d key=${UMI_KEY} \
-d revision=last \
-o installer.php
fi

echo "Install..."
php -f installer.php > init.log
echo "DONE"
Empty file added example/readme.md
Empty file.