Skip to content

Instantly share code, notes, and snippets.

View moismailzai's full-sized avatar

Mo Ismailzai moismailzai

View GitHub Profile
@moismailzai
moismailzai / netns-proton.service
Created February 9, 2023 22:21
systemd unit to run the wireguard jail as a service. see notes at the bottom.
# forked from https://etherarp.net/network-isolation-of-services-with-systemd/index.html
# ln -s /path/to/this/file /usr/lib/systemd/system/netns-proton.service
[Unit]
After=zfs-mount.service
Description=Named network namespace "proton"
StopWhenUnneeded=true
[Service]
Type=oneshot
RemainAfterExit=yes
@moismailzai
moismailzai / wgjailr
Created February 9, 2023 22:19
Creates, destroys, or runs commands in a wireguard jail. Configure the variables up top to point to your wireguard configuration. Run like "wgjairl up|down|exec".
#!/bin/bash
# forked from https://www.wireguard.com/netns/#the-new-namespace-solution & expanded by [email protected] ###############
# CONFIGURABLE #########################################################################################################
ALL_PHYSICAL_INTERFACES=(enp6s0)
ALL_WIRELESS_INTERFACES=()
NETWORK_NAMESPACE_NAME=proton
VPN_CONFIG_PATH=/tank/opt/nas1-config/vpn/proton_us_ca_72.conf
VPN_DNS_SERVER=10.2.0.1
@moismailzai
moismailzai / export_for_wfs.sh
Created June 5, 2022 06:03
Export your current linux system for use with WSL
#!/bin/sh -eux
if [ "$(whoami)" != "root" ]
then
sudo su -s "$0"
exit
fi
# truncate any logs that have built up during the install
find /var/log -type f -exec truncate --size=0 {} \;
@moismailzai
moismailzai / README.md
Created June 5, 2022 03:27 — forked from djfdyuruiry/README.md
WSL 2 - Enabling systemd

Enable systemd in WSL 2

This guide will enable systemd to run as normal under WSL 2. This will enable services like microk8s, docker and many more to just work during a WSL session. Note: this was tested on Windows 10 Build 2004, running Ubuntu 20.04 LTS in WSL 2.

  • To enable systemd under WSL we require a tool called systemd-genie

  • Copy the contents of install-sg.sh to a new file /tmp/install-sg.sh:

    cd /tmp
@moismailzai
moismailzai / tmux-cheatsheet.markdown
Created March 7, 2021 06:34 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
KEYBINDINGS
byobu keybindings can be user defined in /usr/share/byobu/keybindings/ (or within .screenrc if byobu-export was used). The common key bindings
are:
F2 - Create a new window
F3 - Move to previous window
F4 - Move to next window
@moismailzai
moismailzai / varnish-purge-cache.sh
Created November 9, 2018 23:32 — forked from andrezrv/varnish-purge-cache.sh
Purge all Varnish cache.
# Purge all Varnish cache
varnishadm "ban req.url ~ /"
@moismailzai
moismailzai / .travis.yml
Created November 6, 2018 04:24 — forked from jonfriesen/.travis.yml
Example .travis.yml for Golang with CodeCov.io integration
language: go
# Only the last two Go releases are supported by the Go team with security
# updates. Any versions older than that should be considered deprecated.
# Don't bother testing with them. tip builds your code with the latest
# development version of Go. This can warn you that your code will break
# in the next version of Go. Don't worry! Later we declare that test runs
# are allowed to fail on Go tip.
go:
- 1.9
#!/bin/bash -eux
# Add vagrant user to sudoers
echo "vagrant ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
sed -i "s/^.*requiretty/#Defaults requiretty/" /etc/sudoers
# UseDNS no to `sshd_config`.
sed /UseDNS/d /etc/ssh/sshd_config > /tmp/sshd_config
echo "UseDNS no" >> /tmp/sshd_config
mv /tmp/sshd_config /etc/ssh/sshd_config
@moismailzai
moismailzai / vagrant-clean.sh
Last active September 3, 2018 08:28 — forked from jdowning/vagrant-clean.sh
Script to clean up Ubuntu Vagrant box before packaging
#!/bin/bash
# This script zeroes out any space not needed for packaging a new Ubuntu Vagrant base box.
# Run the following command in a root shell:
#
# bash <(curl -s https://gist.githubusercontent.com/moismailzai/0864e90d55d508ec8f5aa1ccd68887c6/raw/fdfd7b28bd00623311689a50754307b06e2e5922/vagrant-clean.sh)
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1