Skip to content

Instantly share code, notes, and snippets.

View MParvin's full-sized avatar

Mohammad Parvin MParvin

View GitHub Profile
@MParvin
MParvin / check_logstash.py
Created September 23, 2024 08:18
Test Logstash connection in python
#!/usr/bin/env python
import json
import socket
import sys
import datetime
def send_data_to_logstash(ls_data, host, port):
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
@MParvin
MParvin / weblogic-ldap-configuration
Last active September 23, 2024 06:37
WebLogic Server LDAP Configuration for FreeIPA
# WebLogic Server LDAP Configuration for FreeIPA
## Connection
Host: freeipa.example.com
Port: 389
Principal: uid=weblogic,cn=users,cn=accounts,dc=example,dc=com
Credential: secure_password
Confirm Credential: secure_password
SSLEnabled: false
@MParvin
MParvin / check_shecan_pro.sh
Created July 21, 2024 16:00
Check shecan pro
#!/bin/bash
echo "Checking resolv.conf"
python3 -c '
import subprocess
shecan_ips = ("178.22.122.101" "185.51.200.1")
resolver_list = []
with open("/etc/resolv.conf", "r") as f:
@MParvin
MParvin / check_logstash.sh
Created October 8, 2023 14:16
Check logstash working
#!/bin/bash
command -v nc 2>&1 >/dev/null
if [[ "$#" < "2" ]]
then
echo "Usage: $0 LOGSTASH_ADDRESS LOGSTASH_PORT"
exit 1
fi
LS_IP=$1
@MParvin
MParvin / kubectl_2_ssh.sh
Created July 10, 2023 07:32
Adding servers IP address from kubectl to ssh config file
#!/bin/bash
if [ -z "$1" ]
then
user_name=root
else
user_name=$1
fi
IFS='
@MParvin
MParvin / ssh_tunnel.service
Last active July 13, 2025 08:03
SSH tunnel systemd service
[Unit]
Description=SSH Tunnel
After=network.target
[Service]
Type=forking
EnvironmentFile=/etc/default/ssh_tunnel
ExecStart=/usr/bin/ssh -fN -D "$SOCKS_PORT" -i "$SSH_KEY" -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes "$USER"@"$SSH_SERVER"
ExecStartPost=/bin/bash -c "/usr/bin/curl --silent --fail --max-time 10 -x socks5h://localhost:$SOCKS_PORT http://ifconfig.me/ip || /bin/kill -9 -- $MAINPID"
ExecReload=/bin/kill -1 -- $MAINPID
ExecStop=/bin/kill -9 -- $MAINPID
@MParvin
MParvin / kind-cluster.yml
Created July 2, 2023 16:23
Kind cluster config that creates Two masters and Three workers, also mount a path from host to containers for development environment
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: control-plane
- role: worker
- role: worker
- role: worker
extraMounts:
- hostPath: /mnt/kind
@MParvin
MParvin / manual_logrotate.sh
Created June 30, 2023 11:47
To manually rotate log files
#!/bin/bash
if [ -z $1 ]
then
echo -e "Usage is: ./main.sh PATH_TO_FILE\nExample: ./main.sh /var/log/nginx/access_log"
exit 1
fi
file=$1
@MParvin
MParvin / get-image.sh
Created January 3, 2023 08:51
This script will pull an image from the public docker registry and push it to your private registry
#!/bin/bash
private_registry="registry.example.com:5000"
if [ -z "$1" ]; then
echo "Usage: $0 <image_name>"
exit 1
fi
image_name=$1
@MParvin
MParvin / certbot_dns.sh
Created December 31, 2022 11:59
Certbot DNS script, This script is used to generate a certificate using DNS challenge.
#!/bin/bash
if ! [ -x "$(command -v certbot)" ]; then
echo 'Error: certbot is not installed.' >&2
exit 1
fi
if [ -z "$1" ]; then
echo "Usage: $0 domain_name"
exit 1