Skip to content

Instantly share code, notes, and snippets.

View carlessanagustin's full-sized avatar

carles san agustin carlessanagustin

View GitHub Profile
@carlessanagustin
carlessanagustin / get_docker.sh
Last active September 12, 2019 15:19
Install Docker Engine & Docker Compose in Ubuntu 18 LTS - wget -O - https://bit.ly/2YAnUp8 | bash
#!/usr/bin/env bash
#DOCKER_VERSION=18.06.1~ce~3-0~ubuntu
COMPOSE_VERSION=1.23.2
# TOOLS
sudo apt-get -y install curl wget make jq git make tree htop conntrack bash-completion build-essential python-pip python-virtualenv rsync unzip apache2-utils
# DOCKER ENGINE
sudo groupadd -f docker
@carlessanagustin
carlessanagustin / TODO.sh
Last active December 20, 2018 11:07
Install proftpd, create & delete ftp users (MUST BE RUN AS ROOT)
improve...
---------
-A INPUT -p tcp -m tcp --dport 20 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 21 -j ACCEPT
# -A INPUT -p tcp -m tcp --dport 990 -j ACCEPT
-A INPUT -p tcp -m multiport --dports $MIN_PORT:$MAX_PORT -j ACCEPT
---------
@carlessanagustin
carlessanagustin / chronograf_dashboard.sh
Created December 7, 2018 16:45
Chronograf dashboard import/export tool - EXPERIMENTAL
#!/usr/bin/env bash
URL=$2 # http://localhost:8888
FILENAME=$3 # dashboard.json
if [ $1 == "export" ]; then
curl -i -X GET $URL/chronograf/v1/dashboards > $FILENAME
elif [ $1 == "import" ]; then
curl -i -X POST -H "Content-Type: application/json" $URL/chronograf/v1/dashboards -d @$FILENAME
else
@carlessanagustin
carlessanagustin / generate_dregistry.sh
Last active March 29, 2019 18:08
Generate Docker Registry resource for Kubernetes - wget -O - https://bit.ly/2EepgOX | bash -s K8S_NAMESPACE DOCKER_HUB_USERNAME DOCKER_HUB_PASSWORD DOCKER_HUB_EMAIL SECRET_NAME
#!/usr/bin/env bash
: '
USAGE:
wget -O - <URL> | \
bash -s <kubectl namespace> <secret name> <docker hub username> <docker hub password> <docker hub email>
'
NS=$1
SNAME=$2
@carlessanagustin
carlessanagustin / hello_world_k8s.sh
Last active December 18, 2018 09:05
Hello World Ingress in Kubernetes
#!/usr/bin/env bash
: '
We'll see...
* Pod replicas
* Helm: The Kubernetes Package Manager
* Ingress resource: Exposes HTTP and HTTPS routes from outside the cluster to services within the cluster.
'
NS_HELLO=hello
@carlessanagustin
carlessanagustin / psql_go.sh
Last active December 5, 2018 11:50
Postgresql database and user creation - wget -O - https://bit.ly/2AOIw22 | bash -s <DB_HOST> <DB_NAME> <DB_USER> <DB_PASS>
#!/usr/bin/env bash
DB_HOST=$1
DB_NAME=$2
DB_USER=$3
DB_PASS=$4
psql "sslmode=verify-ca sslrootcert=server-ca.pem sslcert=client-cert.pem sslkey=client-key.pem hostaddr=$DB_HOST port=5432 user=postgres" << EOF
CREATE DATABASE $DB_NAME ;
CREATE USER $DB_USER WITH ENCRYPTED PASSWORD '$DB_PASS' ;
@carlessanagustin
carlessanagustin / check.sh
Last active November 22, 2018 17:10
Quick check OS, CPU, BITS, MEMORY and DISKS configuration - wget -O - https://bit.ly/2S2Av0m | bash
#!/usr/bin/env bash
echo
echo ">>>>>>>>>>>>>>>>> OS"
echo COMMAND: lsb_release -d
lsb_release -d
echo
echo ">>>>>>>>>>>>>>>>> CPU"
echo COMMAND: grep -c ^processor /proc/cpuinfo
@carlessanagustin
carlessanagustin / k8s_user.sh
Last active March 29, 2019 18:06
Configure k8s for local user - wget -O - https://goo.gl/QY8HnC | bash -s USERNAME
#!/usr/bin/env bash
: '
From root or sudoer user...
USAGE:
wget -O - URL | bash -s USERNAME
'
USERNAME=$1
LOCATION=/home/$USERNAME
@carlessanagustin
carlessanagustin / .tmux.conf
Last active October 7, 2019 09:08
Custom TMUX - curl -L https://goo.gl/xDv6Hv -o $HOME/.tmux.conf
# split panes using | and -, make sure they open in the same path
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
unbind '"'
unbind %
# To enable mouse scroll in tmux pane
set -g mouse on
# Tmux to support colors
@carlessanagustin
carlessanagustin / logrotate_setup.sh
Last active December 20, 2018 05:07
Logrotate setup - apply: wget -O - https://bit.ly/2PkCV8J | sudo bash -s <LOGS_FOLDER> <FILENAME>
#!/usr/bin/env bash
LOGS_FOLDER=$1
FILENAME=$2
DEST_FOLDER=/etc/logrotate.d
cat << EOF > $DEST_FOLDER/$FILENAME
$LOGS_FOLDER/*.log {
rotate 7
size 100M