Skip to content

Instantly share code, notes, and snippets.

View adonis0147's full-sized avatar

Adonis Ling adonis0147

View GitHub Profile
[Unit]
Description=Dockerd Service
[Service]
Environment=PATH=/opt/docker:/usr/sbin
ExecStart=/opt/docker/dockerd
Restart=on-failure
[Install]
WantedBy=default.target
@adonis0147
adonis0147 / share_ssh_sessions
Last active September 4, 2024 08:18
Share multiple sessions over a single network connection (~/.ssh/config)
# ${HOME}/.ssh/config
Host *
HostKeyAlgorithms +ssh-rsa
ControlMaster auto
ControlPath ~/.ssh/connection-%r@%h:%p
ControlPersist yes
ServerAliveInterval 60
@adonis0147
adonis0147 / expect.py
Last active November 19, 2024 10:15
Expect powered by Python
import fcntl
import signal
import struct
import sys
import termios
from typing import Callable
import pexpect
@adonis0147
adonis0147 / save_ssh_client_ip.sh
Created October 25, 2023 15:33
Save SSH client IP
ssh -t <host> "export CLIENT_IP=${SSH_CLIENT/ */}; bash -l"
#!/usr/bin/expect
trap {
set rows [stty rows]
set cols [stty columns]
stty rows $rows columns $cols < $spawn_out(slave,name)
} WINCH
env:
TERM: alacritty
colors:
primary:
foreground: '#F8F8F2'
background: '#272822'
normal:
black: '#272822'
red: '#F92672'
@adonis0147
adonis0147 / QEMU.md
Last active October 11, 2021 14:20
QEMU scripts

QEMU

Prerequisite

  • MacOS >= Big Sur
  • vde_vmnet

Install vde_vmnet

  1. Install https://github.com/lima-vm/vde_vmnet.
  2. Modify /Library/LaunchDaemons/io.github.virtualsquare.vde-2.vde_switch.plist and /Library/LaunchDaemons/io.github.lima-vm.vde_vmnet.plist to use the correct program path.
  3. Start the vde_switch and vde_vmnet.
# DockerHub: https://hub.docker.com/_/postgres
# Start an instance.
docker run --name postgres -e POSTGRES_PASSWORD=postgres -d postgres
# Link the instance.
docker run -it --rm --link postgres postgres psql -h postgres -U postgres
set tui tab-width 2
define hook-file
directory
end
@adonis0147
adonis0147 / iptables-conf.sh
Last active September 28, 2018 15:26
iptables forwarding between two interfaces (connect docker containers in virtual machine with host)
#!/bin/bash
# reference: https://serverfault.com/questions/431593/iptables-forwarding-between-two-interface
# MacOS host
# sudo route -n add 172.17.0.0/16 192.168.1.9
# virutal machine which runs docker containers
# echo 1 > /proc/sys/net/ipv4/ip_forward
sudo iptables -A FORWARD -i ens33 -o docker0 -j ACCEPT
sudo iptables -A FORWARD -i docker0 -o ens33 -m state --state ESTABLISHED,RELATED -j ACCEPT