Skip to content

Instantly share code, notes, and snippets.

View kekedaine's full-sized avatar
😆

David Nguyen kekedaine

😆
View GitHub Profile
#!/bin/bash
# Create .ssh directory and set permissions
mkdir -p ~/.ssh && chmod 700 ~/.ssh
# Install necessary packages
apt update && apt install -y nano vim build-essential tmux curl
# Add SSH key to authorized_keys and set permissions
echo "$PUBLIC_KEY" >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys
#!/bin/bash
sleep 3
IP=$(curl -s https://icanhazip.com)
PORT="$RUNPOD_TCP_PORT_70000"
TOKEN="$UPDATE_MODEL_SERVER_TOKEN"
HOST="$UPDATE_MODEL_SERVER_HOST"
MODEL_TYPE="${MODEL_TYPE:-model1}"
@kekedaine
kekedaine / Gemfile
Created March 15, 2023 15:04 — forked from hjhart/Gemfile
Trial Fluentd configuration for parsing HAProxy logs from Syslog
source 'https://rubygems.org'
gem 'fluentd'
gem 'fluent-plugin-td'
gem 'fluent-plugin-elasticsearch'
@kekedaine
kekedaine / extended-cleanup-rancher2.sh
Created January 12, 2023 04:12 — forked from superseb/extended-cleanup-rancher2.sh
Extended Rancher 2 cleanup (backup your data, use at your own risk)
#!/bin/sh
# Backup your data
# Use at your own risk
# Usage ./extended-cleanup-rancher2.sh
# Include clearing all iptables: ./extended-cleanup-rancher2.sh flush
docker rm -f $(docker ps -qa)
docker rmi -f $(docker images -q)
docker volume rm $(docker volume ls -q)
for mount in $(mount | grep tmpfs | grep '/var/lib/kubelet' | awk '{ print $3 }') /var/lib/kubelet /var/lib/rancher; do umount $mount; done
cleanupdirs="/etc/ceph /etc/cni /etc/kubernetes /opt/cni /opt/rke /run/secrets/kubernetes.io /run/calico /run/flannel /var/lib/calico /var/lib/etcd /var/lib/cni /var/lib/kubelet /var/lib/rancher/rke/log /var/log/containers /var/log/pods /var/run/calico"
@kekedaine
kekedaine / backupMongo_bucket.sh
Created January 3, 2023 15:03 — forked from njadhav1/backupMongo_bucket.sh
Backup MongoDB collection and upload to AWS s3
#!/bin/bash
########
# Purpose :- To take a backup of MongoDB Collections and upload to AWS s3
# Requirement :- Make Sure Collection.config file is present in /data/Backup/mongodb
# format for Collection.config is db|collection
# For example
# db1|collections1
@kekedaine
kekedaine / script.sh
Created January 3, 2023 05:07 — forked from davidcorbin/script.sh
Remove Rancher from Cluster - Force Delete CRDs
# Manually remove finalizers
kubectl edit -n cattle-system secret tls-rancher
kubectl patch secret tls-rancher -p '{"metadata":{"finalizers":[]}}' --type='merge' -n cattle-system
kubectl patch namespace cattle-system -p '{"metadata":{"finalizers":[]}}' --type='merge' -n cattle-system
kubectl delete namespace cattle-system --grace-period=0 --force
kubectl patch namespace cattle-global-data -p '{"metadata":{"finalizers":[]}}' --type='merge' -n cattle-system
kubectl delete namespace cattle-global-data --grace-period=0 --force
@kekedaine
kekedaine / restoreMongo_bucket.sh
Created December 25, 2022 17:15 — forked from njadhav1/restoreMongo_bucket.sh
Restore MongoDB backup from AWS S3
#!/bin/bash
########
# Purpose :- To Restore backup of MongoDB Collections from AWS s3
# Requirement :- Make Sure you took backup via backupMongo_bucket.sh
# Bug Report to :- [email protected]
########
PROGNAME=$(basename $0)
@kekedaine
kekedaine / mongodb-s3-backup.sh
Created December 25, 2022 17:13 — forked from eladnava/mongodb-s3-backup.sh
Automatically backup a MongoDB database to S3 using mongodump, tar, and awscli (Ubuntu 14.04 LTS)
#!/bin/sh
# Make sure to:
# 1) Name this file `backup.sh` and place it in /home/ubuntu
# 2) Run sudo apt-get install awscli to install the AWSCLI
# 3) Run aws configure (enter s3-authorized IAM user and specify region)
# 4) Fill in DB host + name
# 5) Create S3 bucket for the backups and fill it in below (set a lifecycle rule to expire files older than X days in the bucket)
# 6) Run chmod +x backup.sh
# 7) Test it out via ./backup.sh
@kekedaine
kekedaine / bash_parse_example.sh
Created November 3, 2022 06:44 — forked from Esl1h/bash_parse_example.sh
How to parse and use yaml file in bash/shell script.
#!/bin/bash
function parse_yaml {
local prefix=$2
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
sed -ne "s|^\($s\):|\1|" \
-e "s|^\($s\)\($w\)$s:$s[\"']\(.*\)[\"']$s\$|\1$fs\2$fs\3|p" \
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
awk -F$fs '{
indent = length($1)/2;
@kekedaine
kekedaine / open_port.py
Created October 26, 2022 09:56 — forked from ruanbekker/open_port.py
Find an open port in Python.
import socket
def find_open_port():
"""
Use socket's built in ability to find an open port.
"""
sock = socket.socket()
sock.bind(('', 0))