Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "Usage: $0 123.123.123.123 password"
echo "Specify your host's LAN IP and the desired Pihole password"
exit 1
fi
IP=$1
PASSWORD=$2
@atrakic
atrakic / gitlab-ci.yaml
Created October 16, 2019 21:33 — forked from lucj/gitlab-ci.yaml
kube deployment
deploy-kube:
stage: deploy
environment: test
image: dtzar/helm-kubectl:2.12.3
script:
- kubectl config set-cluster sophia-cluster --server=${KUBE_URL} --certificate-authority="${KUBE_CA_PEM_FILE}"
- kubectl config set-credentials sophia-admin --token=${KUBE_TOKEN}
- kubectl config set-context sophia-context --cluster=sophia-cluster --user=sophia-admin --namespace ${KUBE_NAMESPACE}
- kubectl config use-context sophia-context
- helm upgrade --reuse-values --set image.tag=$CI_BUILD_REF sophia k8s-chart
@atrakic
atrakic / urlencode
Created October 14, 2019 14:14 — forked from cbron/urlencode
URL encode/decode script
#!/usr/bin/python
import urllib
import sys
text = sys.argv[1]
encoded = urllib.quote_plus(text)
print encoded
@atrakic
atrakic / rioStart.sh
Created October 14, 2019 14:03 — forked from daxmc99/rioStart.sh
rioStart.sh
#!/bin/bash
#set -x
#set -e
k3d delete --name='rio'
k3d create -n rio --image rancher/k3s:v0.8.1 --publish 80:80 --publish 443:443 --publish 9443:9443 --publish 9080:9080 &&
declare -i i; i=0
until k3d get-kubeconfig --name='rio'
do
if (( i > 20 )); then
break
image:
name: hashicorp/terraform:light
entrypoint:
- '/usr/bin/env'
- 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
before_script:
- rm -rf .terraform
- terraform --version
- mkdir -p ./creds
podTemplate(
label: 'kubernetes',
containers: [
containerTemplate(name: 'maven', image: 'maven:alpine', ttyEnabled: true, command: 'cat'),
containerTemplate(name: 'golang', image: 'golang:alpine', ttyEnabled: true, command: 'cat')
]
) {
node('kubernetes') {
container('maven') {
stage('build') {
# Generate AWS credentials through https://console.aws.amazon.com/iam/home#/security_credential if you do NOT have them already
export AWS_ACCESS_KEY_ID=[...] # Replace [...] with the AWS Access Key ID
export AWS_SECRET_ACCESS_KEY=[...] # Replace [...] with the AWS Secret Access Key
export AWS_DEFAULT_REGION=us-east-2
# If Windows, use `tr '\r\n' ', '` instead of `tr '\n' ','`
export ZONES=$(aws ec2 describe-availability-zones \
######################
# Create The Cluster #
######################
# Tested with minikube v0.30
minikube start \
--vm-driver virtualbox \
--cpus 2 \
--memory 10240
@atrakic
atrakic / inotifyexec.py
Created December 3, 2018 21:19 — forked from wernight/inotifyexec.py
inotifywait helper that executes a command on file change (for Linux, put it in ~/bin/)
#!/usr/bin/env python
"""Use inotify to watch a directory and execute a command on file change.
Watch for any file change below current directory (using inotify via pyinotify)
and execute the given command on file change.
Just using inotify-tools `while inotifywait -r -e close_write .; do something; done`
has many issues which are fixed by this tools:
* If your editor creates a backup before writing the file, it'll trigger multiple times.
* If your directory structure is deep, it'll have to reinitialize inotify after each change.
@atrakic
atrakic / LambdaEfsBackup.py
Created December 3, 2018 19:18 — forked from eduardcloud/LambdaEfsBackup.py
Backup EFS file-system to S3 with lambda function
import boto3
import time
region = 'eu-west-1'
user_data_script = """#!/bin/bash
instanceid=$(curl http://169.254.169.254/latest/meta-data/instance-id)
cd /
mkdir moodledata
mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 fs-xxxxxxxxxxc.efs.eu-west-1.amazonaws.com:/ moodledata
tar czf mooodledata-backup-$(date +%d-%m-%Y_%H-%M).tar.gz /moodledata
aws s3 mv mooodledata-backup-*.tar.gz s3://xxxxxxxxx/