Skip to content

Instantly share code, notes, and snippets.

@AndersonIncorp
AndersonIncorp / instal_bind.txt
Last active November 5, 2017 17:07
DNS Self hosted subzone *.ip.example.com.
### Install BIND
# https://wiki.archlinux.org/index.php/BIND
pacman -S bind
### Configure named.conf
# cp /etc/named.conf /etc/named.conf.bak
# nano /etc/named.conf
# diff /etc/named.conf.bak /etc/named.conf
9c9
< // listen-on-v6 { any; };
---
@AndersonIncorp
AndersonIncorp / .bash_login
Last active July 10, 2018 19:42
Present info on terminal/ssh login. ~/.bash_login file
#!/bin/bash
## SSH Check
if [ -n "$SSH_CONNECTION" ] && [ "$SHLVL" == "1" ]; then
## pacman -S pacman-contrib
## https://unix.stackexchange.com/questions/119126
stat_mem=$(free -m | awk 'NR==2{printf "%s/%sMB (%.2f%%)\n", $3,$2,$3*100/$2 }')
stat_disk=$(df -h | awk '$NF=="/"{printf "%d/%dGB (%s)\n", $3,$2,$5}')
stat_cpu=$(top -bn1 | grep load | awk '{printf "%.2f\n", $(NF-2)}')
echo -e -n " Date : `date +"%A, %e %B %Y, %r"`
Hostname : `hostname`
@AndersonIncorp
AndersonIncorp / install.sh
Last active November 30, 2021 05:56
OS X to Linux gcc cross compiler build (arch linux x86_64 as target)
#!/bin/bash
set -e
# Prerequirements
# brew install gcc (gmp libmpc mpfr isl)
# copy /usr/lib && /usr/include from arch linux into your CC_ROOT.
# /usr/local/linux/usr/include
# /usr/local/linux/usr/lib
# /usr/local/linux/usr/local/include
# arch linux is target enviroment for this cross compiler
# x86_64 binutils && gcc
@AndersonIncorp
AndersonIncorp / postfix.md
Last active January 24, 2022 22:51
postfix && dovecot virtual email setup (redirect to gmail+alias from domain)

postfix && dovecot virtual email setup (redirect to gmail+alias from domain)

Example shows 2 domains in 1 IP address && 1 postfix instance. All redirected to Gmail.
First domain used as myhostname and is main domain. Others is virtual_alias_domains
Dovecot configured to use passwd database without IMAP && POP3. SMTP auth only
Gmail configured to send emails from our domains (using smtp TLS port 25).
DNS && SPF && PTR records. Example provided.

Brief config overview
Domains /etc/postfix/main.cf
@AndersonIncorp
AndersonIncorp / arch-openvpn-udp-tcp-server.md
Last active March 5, 2022 21:27
MIT License; Short guide for setting up openvpn-server service (tcp+udp), full network (redirect-gateway def1); Optional - Second VPS with traffic redirect to first via iptables; Optional - SSH tunneling for DPI prevention (pubkey)
$ pacman -S openvpn easy-rsa
$ cp -a /etc/easy-rsa/. /etc/easy-rsa-clientnet/
$ cd /etc/easy-rsa-clientnet/
$ export EASYRSA=$(pwd)
$ easyrsa init-pki
$ easyrsa build-ca nopass
$ easyrsa gen-req server nopass
$ easyrsa sign-req server server
@AndersonIncorp
AndersonIncorp / mikrotik-ovpn.md
Last active March 5, 2022 22:54
Short guide for setting up MikroTik ovpn server

CA cert

> System > Certificates
    > [Add new]
        Name: ca
        Country: UA
        Common name: ca
        Key size: 4096
        Key Usage: key cert. sign
@AndersonIncorp
AndersonIncorp / build-php-zts7.2.1-archlinux.txt
Created March 25, 2018 19:04
build-php-zts7.2.1-archlinux.txt php-zts7.2.1 or php7.2.1 without conflict with main php
# ! /bin/bash
# Build of php-zts OR php (if remove --enable-maintainer-zts flag) as second php into /usr/local/php/php-zts7.2.1
# Based on
# https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=php-zts
mkdir -p /root/aur-php/
cd /root/aur-php/
curl -O https://aur.archlinux.org/cgit/aur.git/snapshot/php-zts.tar.gz
tar -xzf php-zts.tar.gz -C patch
curl -O -L https://php.net/distributions/php-7.2.1.tar.xz
@AndersonIncorp
AndersonIncorp / redis_lua_smembers_hgetall_list.lua
Created September 10, 2023 20:58
lua script to get members of set then return hash for each key
https://gist.github.com/luke/dbca647bf07d1843ab47
local members = redis.call('SMEMBERS', KEYS[1])
local results = {}
for index, key in ipairs(members) do
results[index] = redis.call('HGETALL', KEYS[1] .. '/' .. key)
end
return results
1
@AndersonIncorp
AndersonIncorp / netboot.xyz.md
Created June 27, 2018 21:48
Install netboot.xyz.lkrn into grub

Install netboot.xyz.lkrn into grub

wget https://boot.netboot.xyz/ipxe/netboot.xyz.lkrn -O /boot/netboot.xyz.lkrn
nano /etc/grub.d/40_custom
#/etc/grub.d/40_custom
menuentry "netboot.xyz.lkrn" {
    linux16 (hd0,msdos1)/netboot.xyz.lkrn # /boot is (hd0,msdos1) drive
}
#
# One of
@AndersonIncorp
AndersonIncorp / install.md
Created June 29, 2018 16:36
Install any linux distro on VPS with low RAM, locked ISO boot

Overview

Scenario

  • Your VPS provider doesn't support ISO mount
  • Your VPS has low RAM and cannot load whole ISO image
  • Your current /boot is to small to contain ISO file

Workaround

  • Boot low memory ISO (CorePure64.iso ~ 14MB)
  • Create new partition ~1GB / size of your ISO
  • dd your ISO into that partition