Skip to content

Instantly share code, notes, and snippets.

View kantravikumar's full-sized avatar

Ravi Kant kantravikumar

View GitHub Profile
@kantravikumar
kantravikumar / docker-cleanup.sh
Created May 13, 2019 10:47 — forked from stanislavb/docker-cleanup.sh
Docker clean-up script for cron
#!/bin/bash
# Do not run if removal already in progress.
pgrep "docker rm" && exit 0
# Remove Dead and Exited containers.
docker rm $(docker ps -a | grep "Dead\|Exited" | awk '{print $1}'); true
# It will fail to remove images currently in use.
docker rmi $(docker images -qf dangling=true); true
@kantravikumar
kantravikumar / gist:be8dc00ff267995dfa64ad2384d35d6c
Created November 10, 2019 14:19 — forked from pitch-gist/gist:2999707
HTML: Simple Maintenance Page
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
@kantravikumar
kantravikumar / hosts
Created August 30, 2020 14:51 — forked from jaredhoyt/hosts
Example Apache setup (with SSL)
# Secure local IPs:
#
# 127.0.0.2 - www.example.dev
#
127.0.0.1 localhost
# example.com
127.0.0.2 www.example.dev
#!/usr/bin/python
# Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Amazon Software License (the "License"). You may not use
# this file except in compliance with the License. A copy of the License is
# located at http://aws.amazon.com/asl/ or in the "license" file accompanying
# this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
@kantravikumar
kantravikumar / mongo_backup.sh
Created May 10, 2021 02:28 — forked from sheharyarn/mongo_backup.sh
Mongodump Shell Script for Cronjob
#!/bin/bash
MONGO_DATABASE="your_db_name"
APP_NAME="your_app_name"
MONGO_HOST="127.0.0.1"
MONGO_PORT="27017"
TIMESTAMP=`date +%F-%H%M`
MONGODUMP_PATH="/usr/bin/mongodump"
BACKUPS_DIR="/home/username/backups/$APP_NAME"
@kantravikumar
kantravikumar / mongodb-s3-backup.sh
Created May 25, 2021 08:01 — 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
@kantravikumar
kantravikumar / nvidia-driver.yml
Created October 13, 2022 04:25 — forked from tmbdev/nvidia-driver.yml
Ansible playbook for installing NVIDIA drivers
---
- hosts: localhost
become: yes
vars:
driver: 378.13
driver_url: http://us.download.nvidia.com/XFree86/Linux-x86_64/{{driver}}/NVIDIA-Linux-x86_64-{{driver}}-no-compat32.run
tasks:
- get_url: dest=. url={{driver_url}}
- command: systemctl isolate multi-user.target
- service: name=nvidia-docker state=stopped
@kantravikumar
kantravikumar / k3s-logs-collector.sh
Created November 30, 2022 11:12 — forked from superseb/k3s-logs-collector.sh
k3s logs collector
TMPDIR=$(mktemp -d $MKTEMP_BASEDIR)
# k3s
if $(command -v k3s >/dev/null 2>&1); then
mkdir -p $TMPDIR/k3s/crictl
mkdir -p $TMPDIR/k3s/logs
mkdir -p $TMPDIR/k3s/podlogs
mkdir -p $TMPDIR/k3s/kubectl
k3s check-config > $TMPDIR/k3s/check-config 2>&1
k3s kubectl get nodes -o json > $TMPDIR/k3s/kubectl/nodes 2>&1
k3s kubectl version > $TMPDIR/k3s/kubectl/version 2>&1