Skip to content

Instantly share code, notes, and snippets.

View stefanpejcic's full-sized avatar
:octocat:
Live long and may the source be with you

Stefan Pejcic stefanpejcic

:octocat:
Live long and may the source be with you
View GitHub Profile
@stefanpejcic
stefanpejcic / dump_all_mysql_databases.sh
Created April 16, 2024 18:04
dump_all_mysql_databases.sh
#!/bin/bash
databases=`mysql -e "SHOW DATABASES;" | tr -d "| " | grep -v Database`
for db in $databases; do
if [[ "$db" != "information_schema" ]] && [[ "$db" != "performance_schema" ]] && [[ "$db" != "mysql" ]] && [[ "$db" != _* ]] ; then
echo "Exporting database: $db"
mysqldump --databases $db > `date +%Y%m%d`.$db.sql
fi
done
version: '3.8'
services:
db:
image: mysql:latest
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: your_mysql_root_password
@stefanpejcic
stefanpejcic / plugin.php
Created April 2, 2024 07:17
Remote Post Check for WooCommerce
<?php
/*
Plugin Name: Remote Post Check for WooCommerce
Description: Checks the remote post and displays the result in the WordPress admin page with troubleshooting info.
Version: 1.0
Author: Stefan Pejcic
Author URL: https://pejcic.rs
*/
function check_remote_post() {
@stefanpejcic
stefanpejcic / openpanel_dev_versin_install.sh
Created March 28, 2024 14:51
openpanel_dev_versin_install.sh
bash <(curl -sSL https://get.openpanel.co/)
cd /usr/local/admin/
wget FAJL/2087-main.zip
unzip 2087-main.zip
mv modules/ modulesOLD/
mv 2087-main/modules/ modules
mv templates/ templatesOLD/
mv 2087-main/templates/ templates
mv 2087-main/static/pages/ static/pages
@stefanpejcic
stefanpejcic / flask.py
Created March 28, 2024 09:21
Use geoip db to check country code for ip
import os
import json
import socket
from flask import Flask, Response, abort, render_template, request, send_file, g, jsonify, session, url_for, flash, redirect, get_flashed_messages
import subprocess
import datetime
@stefanpejcic
stefanpejcic / gist:afa561ea1e1e03699b93046d4752969d
Last active March 26, 2024 15:12
Install Magento2.4 on Ubuntu docker container behind Nginx rev.proxy
NOTICE: You are seeing this message because you have apache2 package installed.
PHP extension php8.1-imagick is now successfully installed.
Hit:1 http://security.ubuntu.com/ubuntu jammy-security InRelease
Err:2 https://artifacts.elastic.co/packages/7.x/apt stable InRelease
403 Forbidden [IP: 34.120.127.130 443]
Hit:3 http://archive.ubuntu.com/ubuntu jammy InRelease
Hit:4 https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy InRelease
Hit:5 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
Hit:6 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
Reading package lists...
@stefanpejcic
stefanpejcic / cloud.sh
Created March 24, 2024 16:38
Clouslinux 7 udpate kernel
yum -h
yum update
yum update --disableexcludes=*
grubby --default-kernel
@stefanpejcic
stefanpejcic / install_tr.sh
Created March 21, 2024 20:55
Install TR for OpenPanel 0.1.5+
#!/bin/bash
###
#
# install and enable tr locale for openpanel
#
###
cd /usr/local/panel && pybabel init -i messages.pot -d translations -l tr
wget -O /usr/local/panel/translations/tr/LC_MESSAGES/messages.po https://raw.githubusercontent.com/stefanpejcic/openpanel-translations/main/tr-tr/messages.pot
@stefanpejcic
stefanpejcic / gist:ce9f0c43030d5ed246162d2117609ba7
Last active March 7, 2024 21:26
WHM sent summary - check and email if more than 100 dail/deff emails in last 1 hour
#!/bin/bash
WORKDIR="/var/tmp"
TIMESTAMP_FILE="$WORKDIR/last_email_timestamp"
LIMIT="100"
LOAD="20"
starttime=$(date +%s -d '1 hour ago') # 1 hour ago
currenttime=$(date +%s)
#!/bin/bash
# adds a custom blacklist to ufw
# Check if ipset is installed
if ! command -v ipset &> /dev/null
then
echo "ipset could not be found, installing..."
sudo apt-get update && sudo apt-get install -y ipset
else