czwartek, 7 listopada 2019

Sed: remove block of text

Example code:

var gdjfgjfgj235f = 1; var d=document;var s=d.createElement('script'); s.type='text/javascript';
(...)
d.getElementsByTagName('head')[0].appendChild(s);
}

Sed:

sed -i ‘/^var gdjfgjfgj235f/,/^}/d’ $file

sed -i ‘/^d.getElementsByTagName(.*head.*appendChild/,/^}/d’ $file

poniedziałek, 12 sierpnia 2019

cPanel: Failed at step NAMESPACE spawning /usr/bin/mysqld_pre_systemd: Cannot allocate memory

cPanel, mysql error, openvz container

Failed at step NAMESPACE spawning /usr/bin/mysqld_pre_systemd: Cannot allocate memory

error occurs when jailed Apache enabled

check /proc/mounts limits

wtorek, 6 sierpnia 2019

BORG backup: restrict client commands on remote SSH

Add on backup server to .ssh/authorized_keys:

command="borg serve --restrict-to-path /home/USER/REPO.borg",no-pty,no-agent-forwarding,no-port-forwarding,no-X11-forwarding,no-user-rc ssh-rsa KEY

cPanel DNS cluster - force sync zones to cPanel Slave Only from command line

1. Enable DNS cluster
2. Add cPanel Slave Only to MASTER as 'Synchronize changes'
3. Run from command line on master:

/usr/local/cpanel/scripts/dnscluster syncall --full

Check how many zones listed on slave:

[12:07:15 SLAVE root@XXXXXX ~]cPs# /usr/local/cpanel/whostmgr/bin/dnsadmin --action GETZONELIST --localonly|wc -l
1300

piątek, 2 sierpnia 2019

Recreate /boot directory on Centos 7

chroot / rescue / whatever

mv /boot{,.old}
mkdir -p /boot
chmod 0555 /boot
yum reinstall kernel -y
grub2-install /dev/xxx
grub2-mkconfig /boot/grub2/grub.cfg
ln -s /boot/grub2/grub.cfg /etc/grub2.cfg

piątek, 26 lipca 2019

Magento: white screen, 404 errors

Magento: white screen, 404 errors

add to index.php

ini_set('error_reporting', E_ERROR);
register_shutdown_function("fatal_handler");
function fatal_handler() {
    $error = error_get_last();
    echo("<pre>");
    print_r($error);
}

via: https://stackoverflow.com/questions/4784117/magento-how-to-debug-blank-white-screen

poniedziałek, 3 czerwca 2019

Magento: high MySQL load at_is_active.value_id > 0

High MySQL load, queries like

SELECT `e`.*, IF(at_is_active.value_id > 0, at_is_active.value, at_is_active_default.value) AS `is_a

run:

php -f shell/indexer.php reindexall –all 

czwartek, 9 maja 2019

nginx + cloudflare ssl = redirect loop solution

server {
   listen         80;
   server_name    example.com

   if ($http_x_forwarded_proto = "http") {
     return 301 https://$server_name$request_uri;
   }

}

wtorek, 26 marca 2019

SSH key restrict login

no-port-forwarding,no-agent-forwarding,no-X11-forwarding,command="echo 'Please login as the user \"XYZ\" rather than the user \"root\".';echo;sleep 10" KEY

piątek, 25 stycznia 2019

poniedziałek, 21 stycznia 2019

The cPanel user X does not exist in the database map.

The cPanel user X does not exist in the database map.
Mysql::initcache failed: adminbin Cpanel/cpmysql/DBCACHE: exit 255

fix:

/scripts/rebuild_dbmap username

środa, 16 stycznia 2019

EFI grub centos 7

grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
yum reinstall grub2-efi grub2-efi-modules  shim

https://community.centminmod.com/threads/grub-help.12867/page-3

without EFI

grub2-mkconfig –o /boot/grub2/grub.cfg