Skip to content

Instantly share code, notes, and snippets.

View itzhang89's full-sized avatar
🏠
Working from home

itzhang89 itzhang89

🏠
Working from home
  • ThoughtWorks
  • wuhan
View GitHub Profile
@itzhang89
itzhang89 / kproxy.sh
Created June 8, 2023 09:57
This script easy forwards Kubernetes services to local ports.
#!/bin/bash
# Usage: kproxy [-A] servicename [localport]
# Parse command line arguments
if [[ "$1" == "-A" ]]; then
all_namespaces=true
shift
else
all_namespaces=false
@itzhang89
itzhang89 / awsctx.sh
Last active April 23, 2023 10:11
一个简单的 awsctx 命令(模拟kubectx),通过别名设定默认的使用的aws profile
function awsctx(){
local profile_name=${1:-default}
sed -i "/^alias aws='aws --profile/d" ${HOME}/.bashrc
alias aws="aws --profile $profile_name"
echo "alias aws='aws --profile $profile_name'" >> ${HOME}/.bashrc
}
@itzhang89
itzhang89 / headscale.nginx.conf
Created March 30, 2023 09:22
安装 headscale 服务端脚本和nginx反向代理配置文件
map $http_upgrade $connection_upgrade {
default keep-alive;
'websocket' upgrade;
'' close;
}
server {
listen 80;
listen [::]:80;
@itzhang89
itzhang89 / dante_proxy.sh
Last active February 13, 2023 02:49 — forked from sarvarrose/dante_proxy.sh
Setup Socks5 Proxy on Oracle Cloud Ubuntu Instance using Dante
#!/bin/sh
echo_status(){
TEXT=$1
echo "\n $(tput setaf 1)>>>> $(tput setab 7) $TEXT $(tput sgr 0)"
}
SOKSPROXY_PASS=$(openssl rand -base64 12)
echo_status "Updating System and installing dante-server"
@itzhang89
itzhang89 / merge_kube_config.sh
Created September 10, 2022 02:09
快速合并2个kubectl config 文件
#!/usr/bin/env bash
# 备份下现有的kubectl config 文件
suffix="bak$(date +"%Y%m%d")"
cp ~/.kube/config "~/.kube/config.${suffix}"
newPath=${1:-/path/to/new/config}
# 将2份kubectl config 文件合并成一份
KUBECONFIG=~/.kube/config:$newPath kubectl config view --flatten >/tmp/config # Replace your old config with the new merged config
@itzhang89
itzhang89 / install_frpc_ubuntu.sh
Last active September 9, 2022 10:01
install the frpc service on one script on the ubuntu 22.04
#!/bin/bash
FRP_VERSION="0.44.0"
arch=$(uname -i)
if [[ $arch == x86_64* ]]; then
echo "X64 Architecture"
elif [[ $arch == i*86 ]]; then
echo "X32 Architecture"
elif [[ $arch == arm* ]] || [[ $arch = aarch64 ]]; then
@itzhang89
itzhang89 / install_frps_ubuntu.sh
Last active September 9, 2022 10:01
install the frps service on one script on the ubuntu 22.04
#!/bin/bash
FRP_VERSION="0.44.0"
arch=$(uname -i)
if [[ $arch == x86_64* ]]; then
echo "X64 Architecture"
elif [[ $arch == i*86 ]]; then
echo "X32 Architecture"
elif [[ $arch == arm* ]] || [[ $arch = aarch64 ]]; then
@itzhang89
itzhang89 / openvpn-client.sh
Last active August 28, 2021 02:29
connect to openvpn comand
sudo openvpn --verb 4 lenovo-vpn \
--config /etc/openvpn/client.ovpn \
--auth-user-pass /etc/openvpn/passwd