Skip to content

Instantly share code, notes, and snippets.

View acsrujan's full-sized avatar
🏠

Srujan acsrujan

🏠
View GitHub Profile
@acsrujan
acsrujan / jsvc-install.sh
Created September 27, 2020 04:43
script to install jsvc with java-8 on amazonlinux/centos
#!/bin/bash
yum update -y
yum install wget glibc apache-commons-daemon-jsvc
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u152-b16/aa0333dd3019491ca4f6ddbe78cdb6d0/jdk-8u152-linux-x64.rpm
rpm -Uvh jdk-8u152-linux-x64.rpm
alternatives --install /usr/bin/java java /usr/java/jdk1.8.0_152/jre/bin/java 20000
alternatives --install /usr/bin/jar jar /usr/java/jdk1.8.0_152/bin/jar 20000
@acsrujan
acsrujan / handler.py
Created June 26, 2020 04:58
slack notification for cloudwatch alerts
##### To use: Setup a sns topic like cloudwatch-sns-slack.
### Enter webhook url in SLACK_URL; and change SLACK_CHANNEL;
import boto3
import json
import logging
import os
from base64 import b64decode
from urllib.request import Request, urlopen
from urllib.error import URLError, HTTPError
@acsrujan
acsrujan / syslog
Created March 18, 2020 07:40
example syslog
Mar 18 00:43:36 vieturn nodejs[4474]: [2020-03-18 04:43:36] #033[36mINFO#033[39m "GET /rss/" #033[36m304#033[39m 134ms
Mar 18 00:45:01 vieturn CRON[30621]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Mar 18 00:49:29 vieturn nodejs[4474]: [2020-03-18 04:49:29] #033[36mINFO#033[39m "GET /wintertime-happiness/" #033[32m200#033[39m 162ms
Mar 18 00:50:01 vieturn CRON[30696]: (ghost) CMD ("/home/ghost/.acme.sh"/acme.sh --cron --home "/home/ghost/.acme.sh" > /dev/null)
Mar 18 00:50:08 vieturn sendmail[31140]: My unqualified host name (vieturn) unknown; sleeping for retry
Mar 18 00:50:08 vieturn nodejs[4474]: [2020-03-18 04:50:08] #033[36mINFO#033[39m "GET /.well-known/acme-challenge/Qhmvv-JfesiFKgZVI6xBfScXpgwoTNQaBAk8L7jJmDA" #033[36m301#033[39m 4ms
Mar 18 00:50:08 vieturn nodejs[4474]: [2020-03-18 04:50:08] #033[36mINFO#033[39m "GET /.well-known/acme-challenge/Qhmvv-JfesiFKgZVI6xBfScXpgwoTNQaBAk8L7jJmDA" #033[36m301#033[39m 2ms
Mar 18 00:50:09 vieturn nodejs[4474]: [2020-03-18 04:50:09] #033[3
@acsrujan
acsrujan / mac.md
Created January 11, 2020 04:14
Quick commands

This is a constantly updated gist with quick commands I've used over the years. A collation for quick reference.

To delete a user from a mac from cli, from another admin user. Typically used when a contract/employment ends.

sudo dscl . delete /Users/<username>
sudo rm -rf /Users/<username>
@acsrujan
acsrujan / chef_cleanup.sh
Created August 9, 2019 08:43
Cleans up terminated nodes from Chef server.. run it as cron on a server with both AWS access and Chef access, with knife installed.
#!/bin/bash
# Scan for terminated nodes on AWS and remove from Chef
cleanupNodes() {
# get nodes that are terminated via aws-cli
terminated_nodes=$(aws ec2 describe-instances --region=us-east-1 --filters Name=instance-state-name,Values=terminated | grep "InstanceId" | awk -F ":" '{print $2}' | awk -F '"' '{print $2}')
for node in $terminated_nodes;
do
@acsrujan
acsrujan / mysql_rds.tf
Created July 31, 2019 11:57
Creates mysql RDS database using terraform. Needs development.
resource "aws_security_group" "mydatabase_sg" {
name = "mydatabase_sg"
description = "Allows services to talk to mydatabase mysql"
vpc_id = "vpc-xxxx"
ingress {
from_port = 3306
to_port = 3306
protocol = "TCP"
self = true
@acsrujan
acsrujan / launch_bastion.tf
Last active November 24, 2020 09:54
Launches bastion instance once provided values of variables
#Read more on https://acsrujan.net/launch-bastion-aws
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
}
}
}
@acsrujan
acsrujan / aws.tf
Last active June 17, 2019 07:05
Setup VPC with AWS NAT gateways
provider "aws" {
access_key = "${var.aws_access_key}"
secret_key = "${var.aws_secret_key}"
region = "${var.aws_region}"
}
@acsrujan
acsrujan / fluentd.yaml
Created June 12, 2019 18:17
fluentd for kubernetes
apiVersion: v1
kind: ServiceAccount
metadata:
name: fluentd
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
name: fluentd
@acsrujan
acsrujan / install_nodejs_ubuntu.sh
Created July 7, 2017 06:55
Installs nodejs on ubuntu..
#!/bin/bash
# This script installs node in ' $HOME/local/node ' directory wihtout sudo
# Store script's filename in $SELF_NAME
SELF_NAME=$(basename $0)
# Prints warning/error $MESSAGE in red foreground color (for [E]rror messages)
red_echo() {
echo -e "\e[1;31m[E] $SELF_NAME: $MESSAGE\e[0m"
}