Skip to content

Instantly share code, notes, and snippets.

Avatar

Srujan acsrujan

View GitHub Profile
@acsrujan
acsrujan / jsvc-install.sh
Created Sep 27, 2020
script to install jsvc with java-8 on amazonlinux/centos
View jsvc-install.sh
#!/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 Jun 26, 2020
slack notification for cloudwatch alerts
View handler.py
##### 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 Mar 18, 2020
example syslog
View 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 Jan 11, 2020
Quick commands
View mac.md

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 Aug 9, 2019
Cleans up terminated nodes from Chef server.. run it as cron on a server with both AWS access and Chef access, with knife installed.
View chef_cleanup.sh
#!/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 Jul 31, 2019
Creates mysql RDS database using terraform. Needs development.
View mysql_rds.tf
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 Nov 24, 2020
Launches bastion instance once provided values of variables
View launch_bastion.tf
#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 Jun 17, 2019
Setup VPC with AWS NAT gateways
View aws.tf
provider "aws" {
access_key = "${var.aws_access_key}"
secret_key = "${var.aws_secret_key}"
region = "${var.aws_region}"
}
@acsrujan
acsrujan / fluentd.yaml
Created Jun 12, 2019
fluentd for kubernetes
View fluentd.yaml
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 Jul 7, 2017
Installs nodejs on ubuntu..
View install_nodejs_ubuntu.sh
#!/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"
}