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
#!/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}')
@stefanpejcic
stefanpejcic / Docker_mount.sh
Last active October 6, 2023 19:19
Mount 10gb to limit docker container writable layer
dd if=/dev/zero of=myfs.ext4 bs=1M count=10240
mkfs.ext4 myfs.ext4
docker inspect -f '{{ .GraphDriver.DataDir }}' <container_id>
mount -o loop /path/to/myfs.ext4 /path/to/writable/layer/folder
from flask import Flask, session
from flask_session import Session
app = Flask(__name__)
# Configure session type and secret key
app.config['SESSION_TYPE'] = 'filesystem' # You can use other options like 'redis' for better performance
app.config['SESSION_PERMANENT'] = True # Session lasts until the browser is closed
@stefanpejcic
stefanpejcic / vsftpd.conf
Created October 3, 2023 20:25
vsftpd.conf
# Enable standalone mode and disable anonymous FTP
listen=YES
anonymous_enable=NO
# Allow local users to login
local_enable=YES
# Enable write access for local users
write_enable=YES
server {
listen 80;
server_name fe34fsd.openpanel.co;
location / {
sub_filter 'http://panel.pejcic.rs/ffff' 'http://fe34fsd.openpanel.co';
sub_filter_once off;