Skip to content

Instantly share code, notes, and snippets.

@istepanov
istepanov / copy_to_docker_volume.sh
Last active October 18, 2016 05:14
Copy host folder to a Docker volume (preserving all file permissions and ownership)
#!/bin/bash
# this is the source folder. We want to copy its content to a Docker volume.
SRC_PATH='/opt/docker/gitlab/data'
# this is target volume name. Assuming it's not been created yet.
VOLUME_NAME='gitlab-data'
tar Ccf $(dirname $SRC_PATH) - $(basename $SRC_PATH) | docker run -i --rm -v $VOLUME_NAME:/data debian tar Cxpf /data - --strip-components=1
@istepanov
istepanov / watchdoge.py
Created December 12, 2016 05:22
Simple ping watchdog
#!/usr/bin/env python
import os
import datetime
address = '8.8.8.8'
ping_timeout = 5
attempts = 4
log_file = '/var/log/ping_test.log'
@istepanov
istepanov / raw-to-jpeg.sh
Created January 2, 2017 01:00
Convert Canon RAW files to JPEGs (MacOS)
for D in `find . -type d`
do
pushd "$D"
for i in *.CR2; do sips -s format jpeg $i --out "${i%.*}.jpg"; done
popd
done
@istepanov
istepanov / init.sh
Created May 24, 2017 03:29
Install Docker, Docker Compose and NTP
#!/bin/bash
# stop execution if error
set -e
export DEBIAN_FRONTEND=noninteractive
# pre-requirements
apt-get update
apt-get upgrade -y
@istepanov
istepanov / gitlab-2fa-reset.sh
Last active August 24, 2017 13:08
Reset 2FA on Docker GitLab image
docker exec -ti gitlab bash
cd /home/git/gitlab
sudo -u git -H bundle exec rails console production
User.find_each(&:disable_two_factor!)
@istepanov
istepanov / nvidia-docker.sh
Last active November 3, 2018 19:28
Nvidia Docker
# make sure you have Ubuntu 18.04 and Docker >= 1.12 installed
# nvidia drivers (Ubuntu-based distros)
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
sudo apt-get install ubuntu-drivers-common
# show list of drivers to install
sudo ubuntu-drivers devices
@istepanov
istepanov / sudo_no_password.sh
Created November 3, 2018 19:51
Sudo without password
#!/bin/sh
echo "$USER ALL=(ALL:ALL) NOPASSWD: ALL" | sudo env EDITOR="tee -a" visudo
@istepanov
istepanov / install_docker.sh
Last active September 24, 2019 05:37
Install docker on Ubuntu 18.04
curl -sSL https://get.docker.com | sh && sudo usermod "$(whoami)" -aG docker && newgrp docker
@istepanov
istepanov / nginx.tmpl
Created October 30, 2016 02:13 — forked from SnowMB/nginx.tmpl
docker-gen_nginx_template
{{ define "upstream" }}
{{ if .Address }}
{{/* If we got the containers from swarm and this container's port is published to host, use host IP:PORT */}}
{{ if and .Container.Node.ID .Address.HostPort }}
# {{ .Container.Node.Name }}/{{ .Container.Name }}
server {{ .Container.Node.Address.IP }}:{{ .Address.HostPort }};
{{/* If there is no swarm node or the port is not published on host, use container's IP:PORT */}}
{{ else if .Address.IP }}
# {{ .Container.Name }}
server {{ .Address.IP }}:{{ .Address.Port }};
@istepanov
istepanov / install_gettext.sh
Created October 24, 2012 10:46
Compile and install gettext.so PHP extension for Mac OS X 10.8 Mountain Lion
#!/usr/bin/sh
# Scipt for installing mcrypt.so extension for PHP 5.3.13 (default PHP for OS X 10.8 Mountain Lion)
mkdir /tmp/gettext
cd /tmp/gettext
curl --location --progress-bar http://us.php.net/get/php-5.3.13.tar.gz/from/nl.php.net/mirror | tar -zx
brew update