Skip to content

Instantly share code, notes, and snippets.

View aputs's full-sized avatar

Allan Ralph Hutalla aputs

  • Earth
  • Philippines
View GitHub Profile
@aputs
aputs / go-get-from-git+ssh-repository
Last active August 29, 2015 13:57
Go get from git+ssh repository
#add following lines in your .ssh/config
Host example.com
HostName example.com
User git
IdentitiesOnly yes
@aputs
aputs / replace-centos6x-iptables
Last active February 28, 2022 04:58
replace centos 6.x iptables
# compile iptables from source and install to /usr/local
mkdir -p /tmp/iptables
wget "http://www.netfilter.org/projects/iptables/files/iptables-1.4.21.tar.bz2" -qO- | tar --strip-components=1 -C /tmp/iptables -xvj
cd /tmp/iptables
./configure
make
make install
# set alternatives
sudo alternatives --install /sbin/iptables iptables.x86_64 /usr/local/sbin/iptables 100 \
@aputs
aputs / etcd centos init.d script
Last active November 21, 2017 14:07
etcd init script
#!/bin/bash
# Startup script for etcd
#
# chkconfig: 2345 20 80
# description: Starts and stops etcd
. /etc/init.d/functions
prog="etcd"
ETCD_BIN=$(which etcd 2> /dev/null)
#!/bin/sh
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
#!/bin/bash
set -e
set -o pipefail
function list_tars {
ROOT=$1
TAG=${2:-latest}
BASE=$(sed -e 's/.*{\(".*"\)}.*/\1/g' "${ROOT}/repositories" | sed 's/"//g' | awk -v RS=',' -F: '/^'${TAG}'/ {print $2}')
CUR=$BASE
TGZ=http://hkg.mirror.rackspace.com/archlinux/iso/2014.11.01/archlinux-bootstrap-2014.11.01-x86_64.tar.gz
ROOT=/var/lib/archlinux
TMPROOT=/tmp/archlinux
sudo mkdir -p ${TMPROOT}
wget "${TGZ}" -O- | sudo tar --strip-components=1 -C ${TMPROOT} -Pxzf-
sudo sed --in-place s/^#//g ${TMPROOT}/etc/pacman.d/mirrorlist
sudo btrfs subvolume delete ${ROOT}
sudo btrfs subvolume create ${ROOT}
@aputs
aputs / tar-docker-image
Last active October 29, 2016 23:58
tar docker image (squash)
docker_root=/var/lib/docker/btrfs
subvolumes=subvolumes
docker_image=aputs/archlinux
tar_file=/tmp/image.tar.gz
# tar
cd $docker_root/$subvolumes/$(docker inspect --format='{{.Id}}' $docker_image)
tar --exclude={'.','..'} -Pcvzf $tar_file .* *
@aputs
aputs / nspawn-docker-image
Created November 7, 2014 11:50
run systemd-nspawn on btrfs docker image snapshot
docker_root=/var/lib/docker/btrfs
subvolumes=subvolumes
docker_image=aputs/archlinux
tar_file=/tmp/image.tar.gz
dest_dir=/var/lib/container/archlinux
btrfs subvolume snapshot $docker_root/$subvolumes/$(docker inspect --format='{{.Id}}' $docker_image) $dest_dir
systemd-nspawn -D $dest_dir
@aputs
aputs / pacman.conf
Created November 9, 2014 16:00
minimal pacman config
[options]
NoUpgrade = etc/passwd etc/group etc/shadow
NoUpgrade = etc/pacman.conf
NoExtract = usr/share/doc/*
NoExtract = usr/share/info/*
NoExtract = usr/share/man/*
NoExtract = usr/share/locale/[a-d,f-k,m-z]*
NoExtract = usr/share/locale/e[a-m,o-z]*
NoExtract = usr/share/locale/l[a-n,p-z]*
NoExtract = usr/share/locale/lo
@aputs
aputs / centos7-kickstart-iso.sh
Last active December 18, 2019 12:24
centos7 kickstart iso creation
# Mandatory Files: copied from Centos7 ISO installer (minimal/full dvd)
#
# $ROOT/cdroot/.discinfo
# $ROOT/cdroot/LiveOS/squashfs.img
# $ROOT/cdroot/isolinux/boot.cat
# $ROOT/cdroot/isolinux/initrd.img
# $ROOT/cdroot/isolinux/isolinux.bin
# $ROOT/cdroot/isolinux/vmlinuz
#