Skip to content

Instantly share code, notes, and snippets.

View uncelvel's full-sized avatar

Đặng Xuân Cảnh uncelvel

View GitHub Profile
host=$(hostname)
/sbin/chkconfig -list > 01.1.services.txt
/bin/cat /etc/xinetd.conf > 01.2.etc_xinetdconf.txt
/bin/cat /etc/xinetd.d/r* > 01.3.etc_xinetdd_r.txt
/bin/ls -al /home/* > 01.4.home_dirs.txt
/bin/cat /etc/hosts.equiv > 02.${host}_host_equiv.txt
/bin/ls -l /etc/hosts.equiv > 03.${host}_perm_equiv.txt
/bin/cat /etc/passwd > 04.${host}_etc_passwd.txt
/bin/more /etc/shadow > 05.etc_shadow.txt
/usr/bin/ypcat passwd > 06.passwd.txt
import logging
import os
import pathlib
import sys
from datetime import datetime
import time
from dotenv import load_dotenv
# env = load_dotenv()
#!/bin/bash
# Script Gen file and rename file
number_small_file=1000
number_large_file=500
#sudo apt install pwgen -y
# ================ Small file ================
@uncelvel
uncelvel / ubuntu-mainline-kernel.sh
Created October 12, 2022 03:59
Upgrade newest kernel Ubuntu
#!/usr/bin/env bash
# shellcheck disable=SC1117
# Ubuntu Kernel PPA info
ppa_host="kernel.ubuntu.com"
ppa_index="/~kernel-ppa/mainline/"
ppa_key="17C622B0"
# If quiet=1 then no log messages are printed (except errors)
@uncelvel
uncelvel / gist:eaf9925761ee91639134189f508123a0
Created July 12, 2022 03:11
remove-local-storage-proxmox
sub parse_config {
my ($class, $filename, $raw) = @_;
my $cfg = $class->SUPER::parse_config($filename, $raw);
my $ids = $cfg->{ids};
=comment-out
# make sure we have a reasonable 'local:' storage
# we want 'local' to be always the same 'type' (on all cluster nodes)
@uncelvel
uncelvel / redis-sentinel-failover.sh
Created July 12, 2022 03:00 — forked from holly/redis-sentinel-failover.sh
redis-sentinel client-reconfig-script
#!/bin/sh
# The following arguments are passed to the script:
#
# <master-name> <role> <state> <from-ip> <from-port> <to-ip> <to-port>
MASTER_IP=$6
VIP=172.17.0.101
NETMASK=16
IF=eth0
MY_IP=$(ip addr show dev $IF | grep "global $IF" | head -1 | sed -e "s/^.*inet \(.*\)\/$NETMASK .*$/\1/")
@uncelvel
uncelvel / generate-wildcard-certificate.sh
Created April 21, 2022 10:32
generate-wildcard-certificate.sh
#!/usr/bin/env bash
# print usage
DOMAIN=$1
if [ -z "$1" ]; then
echo "USAGE: $0 ghtk.local"
echo ""
echo "This will generate a non-secure self-signed wildcard certificate for given domain."
echo "This should only be used in a development environment."
@uncelvel
uncelvel / check_rabbitmq.py
Created May 28, 2021 05:12
check_rabbitmq.py
#!/usr/bin/env python
import socket
from kombu import Connection
host = "localhost"
port = 5672
user = "guest"
password = "guest"
vhost = "/"
url = 'amqp://{0}:{1}@{2}:{3}/{4}'.format(user, password, host, port, vhost)
with Connection(url) as c:
#!/bin/bash
##########
# Script to resize a LVM Partition after extending the underlying disk device. Can be used on physical or virtual machines alike.
# Tested with CentOS6, RHEL6, CentOS7, RHEL7. This script is only intended for MBR partitioned disks and not for GPT.
#
# The script will first resize the partition by changing the partition end sector of the selected partition, and then after a reboot resize the filesystem.
# By default it rescans the SCSI bus to check a change in disk size if the disk was hot-extended, which is easy with VMs, and only then proceeds.
# If the extended disk size is recognized by the OS already, you can force resizing with the -f flag.
#
# It is recommended you backup the boot sector of your disk before as a safety measure with something like the following:
@uncelvel
uncelvel / update_lastest_sshd.sh
Created April 17, 2021 04:20
update_lastest_sshd.sh
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
cd /root
wget https://mirrors.sonic.net/pub/OpenBSD/OpenSSH/portable/openssh-8.5p1.tar.gz
tar -zxvf openssh-8.5p1.tar.gz
cd openssh-8.5p1