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 / encryption.key
Created October 3, 2024 17:16
get JetBackup5 encryption key for a server runninf WHM/cPanel
#!/bin/bash
# Print JB encryption key
token=$(whmapi1 api_token_create token_name=temp 2>/dev/null | grep -oP '(?<=token: ).*' 2>/dev/null)
hostname=$(hostname)
encryption_key=$(curl --insecure -H "Authorization: whm root:$token" "https://$hostname:2087/cgi/addons/jetbackup5/api.cgi?function=getMasterEncryptionKey" 2>/dev/null | grep -o '"encryption_key":"[^"]*' | awk -F '"' '{print $4}')
@stefanpejcic
stefanpejcic / install_lsws_on_openpanel.sh
Created September 26, 2024 10:02
Install LSWS trial in OpenPanel container
# install lsws
bash <( curl https://get.litespeed.sh ) TRIAL
# symlink docroot from filemanager to ls
ln -s /home/stefan/josjedan.openpanel.org /usr/local/lsws/Example2/public_html
# install lsphp
wget -O - https://repo.litespeed.sh | bash
apt-get install lsphp81 lsphp81-common lsphp81-mysql
@stefanpejcic
stefanpejcic / app.py
Created September 18, 2024 10:11
flask terminal for container - ispired by https://gist.github.com/Humerus/0268c62f359f7ee1ee2d
from flask import Flask, render_template, request
from flask_socketio import SocketIO, emit
import docker
app = Flask(__name__)
socketio = SocketIO(app, cors_allowed_origins="*")
client = docker.from_env()
@app.route('/terminal/<container_id>')
def terminal(container_id):
@stefanpejcic
stefanpejcic / domains_dnssec.sh
Created July 9, 2024 16:35
Setup DNSSEC for BIND9 *(OPENPANEL)
#!/bin/sh
# Variables
PDIR=$(pwd)
ZONEDIR="/var/cache/bind"
ZONE=$1
ZONEFILE="/etc/bind/zones/${ZONE}.zone"
CONFIG_FILE="/etc/bind/named.conf.local"
DNSSERVICE="bind9"
@stefanpejcic
stefanpejcic / nginx_disable_xmlrpc.sh
Created May 20, 2024 22:52
Disable access to xmprpc.php for all domains in Nginx
#!/bin/bash
# Threshold for the number of xmlrpc processes indicating an attack
THRESHOLD=50
# Path to the custom Nginx configuration include file
NGINX_CONF="/etc/nginx/conf.d/custom_code_for_all_domains.conf"
# Function to log the change
log_change() {
@stefanpejcic
stefanpejcic / service.config.py
Created May 8, 2024 16:36
gunicorn service.config.py
# Gunicorn configuration file
# https://docs.gunicorn.org/en/stable/configure.html#configuration-file
# https://docs.gunicorn.org/en/stable/settings.html
import multiprocessing
from gunicorn.config import Config
import configparser
import os
@stefanpejcic
stefanpejcic / docker_slice_limit_total_ram_and_cpu.sh
Last active May 9, 2024 16:03
Limit total RAM & CPU usage of all docker containers combined
#!/bin/bash
# https://unix.stackexchange.com/questions/537645/how-to-limit-docker-total-resources
# https://www.freedesktop.org/wiki/Software/systemd/ControlGroupInterface/
CPU_PERCENTAGE="90"
RAM_PERCENTAGE="90"
# Get total RAM in bytes
total_ram=$(grep MemTotal /proc/meminfo | awk '{print $2}')
@stefanpejcic
stefanpejcic / install_fr.sh
Created May 5, 2024 13:18
Install FR locale for OpenPanel
#!/bin/bash
###
#
# install and enable fr locale for openpanel
#
###
cd /usr/local/panel && pybabel init -i messages.pot -d translations -l fr
wget -O /usr/local/panel/translations/fr/LC_MESSAGES/messages.po https://raw.githubusercontent.com/stefanpejcic/openpanel-translations/main/fr-fr/messages.pot
#!/bin/bash
# Check if Docker is running
if ! docker info &>/dev/null; then
echo "Docker is not running. Please start Docker and try again."
exit 1
fi
# Check if the Docker container exists
if docker ps -a --format '{{.Names}}' | grep -q "openpanel_mysql"; then
-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: localhost
-- Generation Time: Sep 21, 2023 at 02:09 PM
-- Server version: 8.0.34-0ubuntu0.20.04.1
-- PHP Version: 7.4.3-4ubuntu2.19
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";