Skip to content

Instantly share code, notes, and snippets.

View lichti's full-sized avatar
👨‍💻
🏊🏻🚴🏻🏃🏻

Gustavo Lichti lichti

👨‍💻
🏊🏻🚴🏻🏃🏻
View GitHub Profile
@lichti
lichti / wildfly-install-mysql.sh
Created January 12, 2017 19:43
Install mysql driver on Wildfly
#!/bin/bash
#title :wildfly-install-mysql.sh
#description :The script to install mysql drive in Wildfly 10.x
#usage :/bin/bash wildfly-install-mysql.sh
DRIVER_VERSION=5.1.40
DRIVER_FILENAME=mysql-connector-java-${DRIVER_VERSION}
DRIVER_ARCHIVE_NAME=${DRIVER_FILENAME}.tar.gz
DRIVER_UNTAR_NAME=${DRIVER_FILENAME}-bin.jar
DRIVER_DOWNLOAD_ADDRESS=https://cdn.mysql.com//Downloads/Connector-J/${DRIVER_ARCHIVE_NAME}
import subprocess
from flask import (Flask, abort, request, jsonify, Response)
from pybitbucket.bitbucket import Bitbucket, Client
from pybitbucket.auth import (
Authenticator,
Anonymous, BasicAuthenticator,
OAuth1Authenticator,
OAuth2Grant, OAuth2Authenticator)
from pybitbucket.repository import (
RepositoryRole, RepositoryType, RepositoryForkPolicy,

Centos7 - 64bits

#!/bin/bash
region='sa-east-1'
cd /tmp
curl https://amazon-ssm-${region}.s3.amazonaws.com/latest/linux_amd64/amazon-ssm-agent.rpm -o amazon-ssm-agent.rpm
yum install -y amazon-ssm-agent.rpm
rm -f amazon-ssm-agent.rpm
systemctl enable amazon-ssm-agent
systemctl start amazon-ssm-agent
ZABBIX_PROXY=zabbix-proxy.lichti.com.br
HOSTNAME_AGENT=$(hostname --fqdn)
yum update
rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
yum install zabbix-agent -y
systemctl enable zabbix-agent
cat << EOF > /etc/zabbix/zabbix_agentd.conf
ZABBIX_SERVER=zabbix-server.lichti.com.br
ZABBIX_PROXY=zabbix-proxy.lichti.com.br
ZABBIX_DBPASS=my_super_pass
sed -i 's/^SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
setenforce Permissive
sed -i "s/^HOSTNAME=.*/HOSTNAME=${ZABBIX_PROXY}/g" /etc/sysconfig/network
echo '${ZABBIX_PROXY}' > /etc/hostname
ZABBIX_HOSTNAME=zabbix-server.lichti.com.br
ZABBIX_DBPASS=my_super_pass
sed -i 's/^SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
setenforce Permissive
sed -i "s/^HOSTNAME=.*/HOSTNAME=${ZABBIX_HOSTNAME}/g" /etc/sysconfig/network
echo "${ZABBIX_HOSTNAME}" > /etc/hostname

DB Slave:

  • Backup grants
# mysql -B -N -e "SELECT DISTINCT CONCAT('SHOW GRANTS FOR \'', user, '\'@\'', host, '\';') AS query FROM mysql.user" | mysql | sed 's/\(GRANT .*\)/\1;/;s/^\(Grants for .*\)/## \1 ##/;/##/{x;p;x;}' | grep ^GRANT > /root/grants_2016-11-21.sql
  • Stop MySQL
# systemctl stop mysql
@lichti
lichti / aws-addresses.sh
Last active September 28, 2016 17:49
List all public address from all ec2, elb and eip
#!/bin/bash
ARRAY_ACCESS_KEY="conta001,KEY_ID,ACCESS_KEY:conta002,KEY_ID,ACCESS_KEY"
function ec2-public {
export AWS_DEFAULT_OUTPUT="json"
aws ec2 describe-instances | jq -r --arg ACCOUNT "${1}" --arg REGION "${2}" --arg TYPE "EC2" '.Reservations[] | .Instances | map((.PublicDnsName|tostring), (.PublicIpAddress|tostring), $ACCOUNT, $REGION, $TYPE) | @csv' | grep -v '"","null"'
}
function eip-public {
@lichti
lichti / service-checklist.md
Created September 22, 2016 18:01 — forked from acolyer/service-checklist.md
Internet Scale Services Checklist

Internet Scale Services Checklist

A checklist for designing and developing internet scale services, inspired by James Hamilton's 2007 paper "On Desgining and Deploying Internet-Scale Services."

Basic tenets

  • Does the design expect failures to happen regularly and handle them gracefully?
  • Have we kept things as simple as possible?
@lichti
lichti / jira_move.sh
Created September 19, 2016 21:48
move users from one group to another
#/bin/bash
USER=$1
PASS=$2
GROUPOLD=$3
GROUPNEW=$4
JIRAURL="https://dafiti.jira.com/rest/api/2"
STARTAT=0
MAXRESULT=50