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 / 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
#!/bin/bash
###
#
# install and enable de locale for openpanel
#
###
cd /usr/local/panel && pybabel init -i messages.pot -d translations -l de
wget -O /usr/local/panel/translations/de/LC_MESSAGES/messages.po https://raw.githubusercontent.com/stefanpejcic/openpanel-translations/main/de-de/messages.pot
import sys
from werkzeug.security import generate_password_hash
def hash_password(unhashed_password):
hashed_password = generate_password_hash(unhashed_password)
return hashed_password
if __name__ == "__main__":
# Check if the correct number of command-line arguments is provided
if len(sys.argv) != 2:
import os
import sys
from htmlmin import minify
from css_html_js_minify import process_single_html_file
def minify_files(input_dir, output_dir):
if not os.path.exists(output_dir):
os.makedirs(output_dir)
for root, dirs, files in os.walk(input_dir):
@stefanpejcic
stefanpejcic / whitelist_cloudflare.sh
Created January 23, 2024 22:17
UFW block 89 and 443, allow only access from Cloudflare proxy
#!/bin/bash
CLOUDFLARE_IPS_V4=$(/usr/bin/curl -s --max-time 10 https://www.cloudflare.com/ips-v4)
CLOUDFLARE_IPS_V6=$(/usr/bin/curl -s --max-time 10 https://www.cloudflare.com/ips-v6)
if [ -n "$CLOUDFLARE_IPS_V4" ] && [ -n "$CLOUDFLARE_IPS_V6" ]; then
/usr/sbin/ufw --force reset
/usr/sbin/ufw default allow incoming
/usr/sbin/ufw default allow outgoing
for IP in $CLOUDFLARE_IPS_V4; do
@stefanpejcic
stefanpejcic / run.tpl
Last active December 29, 2023 16:47
Get run command for a running Docker container
docker run \
--name {{printf "%q" .Name}} \
{{- with .HostConfig}}
{{- if .Privileged}}
--privileged \
{{- end}}
{{- if .AutoRemove}}
--rm \
{{- end}}
{{- if .Runtime}}
@stefanpejcic
stefanpejcic / overlay2_with_xfs_pquota.sh
Last active March 7, 2024 14:39
overlay2_with_xfs_pquota.sh 90% of available du on /home
#!/bin/bash
# Stop the Docker service
systemctl stop docker.service
# Set the target file
target_file="/var/lib/docker.fs"
# Get available space in the home directory in kilobytes
available_space=$(df -k /home | awk 'NR==2 {print $4}')