From 770148e116973b80c22dfecc637d617b3df58249 Mon Sep 17 00:00:00 2001 From: dr-js Date: Thu, 18 Jul 2024 04:04:07 +0000 Subject: [PATCH] CHG: update linux doc --- linux/0-3-install-vm.md | 35 +++++++++++ linux/7-0-nodejs.md | 8 +-- linux/8-0-shadowsocks-privoxy.md | 105 ++++++++++++++----------------- linux/9-6-docker.md | 35 +++++++++-- 4 files changed, 116 insertions(+), 67 deletions(-) create mode 100644 linux/0-3-install-vm.md diff --git a/linux/0-3-install-vm.md b/linux/0-3-install-vm.md new file mode 100644 index 0000000..6ebdf8c --- /dev/null +++ b/linux/0-3-install-vm.md @@ -0,0 +1,35 @@ +# install VirtualMachine + +Both WSL1 and WSL2 add some weird network & fs hack to smuggle data ins and outs. + +So use HyperV directly (or other VM software like VirtualBox) can be better when config dives deeper, +and backup/reuse is easier as whole system is in one huge file. + +The idea is config a VM with an additional local 10.42.1.X network, for host to, +everything else is by default separated, like net & fs. + +So this VM will have two network switch/device connected: +- an external network, random ip, for connect to Internet +- a internal/local network, on 10.42.1.X ip range: gate at 10.42.1.0, host should be at 10.42.1.1 and VM at 10.42.1.2 + +Here are the additional config required in VM linux: + +```shell +# /etc/systemd/network/00-local-10.42.1.2.network + +[Match] +MACAddress=00:00:22:22:44:44 +# Name=eth1 +# Name=enp0s8 + +[Network] +DHCP=no +LinkLocalAddressing=no + +[Address] +Address=10.42.1.2/24 +Scope=host +``` + +Note in the `Match` section, a static mac address is simpler to set from host side, +the net device name may change. diff --git a/linux/7-0-nodejs.md b/linux/7-0-nodejs.md index 5f7a487..d05897b 100644 --- a/linux/7-0-nodejs.md +++ b/linux/7-0-nodejs.md @@ -9,7 +9,7 @@ install `nodejs` and `npm`: # so the DIY install here will only use npm self update mkdir ~/DIY_NPM/ ( cd ~/DIY_NPM/ - wget https://registry.npmjs.org/npm/-/npm-8.12.1.tgz # find latest version from: npm.im/npm, or with: `npm view npm` + wget https://registry.npmjs.org/npm/-/npm-9.9.3.tgz # find latest version from: npm.im/npm, or with: `npm view npm` tar xf ./*.tgz # extract sudo mkdir -p /usr/lib/node_modules/ # `sudo rm -rf /usr/lib/node_modules/` sudo cp -rT ./package /usr/lib/node_modules/npm @@ -22,8 +22,8 @@ install `nodejs` and `npm`: rm -rf ~/DIY_NPM/ ) -( # debian/ubuntu, check: https://github.com/nodesource/distributions/blob/master/README.md#debinstall - curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash - # common node.js install +( # debian/ubuntu, check: https://github.com/nodesource/distributions/blob/master/README.md#using-debian-as-root-nodejs-22 + curl -sL https://deb.nodesource.com/setup_22.x | sudo -E bash - # common node.js install sudo apt-get install nodejs -y ) @@ -31,5 +31,5 @@ install `nodejs` and `npm`: sudo npm config set --global update-notifier false # for `sudo npm i -g` ``` -cn mirror: https://mirrors.tuna.tsinghua.edu.cn/help/nodesource/ +cn mirror: https://npmmirror.com/ optionally setup `npm` proxy through `shadowsocks + privoxy`, check: `./8-9-proxy-config.md` diff --git a/linux/8-0-shadowsocks-privoxy.md b/linux/8-0-shadowsocks-privoxy.md index 3efb442..7be609e 100644 --- a/linux/8-0-shadowsocks-privoxy.md +++ b/linux/8-0-shadowsocks-privoxy.md @@ -4,17 +4,7 @@ ## install `shadowsocks` install `shadowsocks-rust`: (check https://github.com/shadowsocks/shadowsocks-rust/releases) -```shell script -( mkdir -p "/opt/dr/common/shadowsocks-rust/" && cd "/opt/dr/common/shadowsocks-rust/" - SS_PLATFORM="$(uname -m)" - SS_VERSION="v1.14.3" - dr-js -f "https://github.com/shadowsocks/shadowsocks-rust/releases/download/${SS_VERSION}/shadowsocks-${SS_VERSION}.${SS_PLATFORM}-unknown-linux-gnu.tar.xz" -O "ss-rust.tar.xz" - dr-js -xI "ss-rust.tar.xz" -O "./.ss-rust-${SS_VERSION}-${SS_PLATFORM}/" - rm "ss-rust.tar.xz" - ln -sfT "./.ss-rust-${SS_VERSION}-${SS_PLATFORM}/sslocal" "sslocal" - ln -sfT "./.ss-rust-${SS_VERSION}-${SS_PLATFORM}/ssserver" "ssserver" -) -``` +use: https://www.npmjs.com/package/@min-pack/ss-rust check manual at: https://github.com/shadowsocks/shadowsocks-rust#getting-started @@ -23,14 +13,13 @@ check manual at: https://github.com/shadowsocks/shadowsocks-rust#getting-started config `nano /opt/dr/common/shadowsocks-rust/config.json` and add: ```json { - "servers": [ - { "server": "0.0.0.0", "server_port": 123, "password": "123456", "method": "chacha20-ietf-poly1305" }, - { "server": "0.0.0.0", "server_port": 1234, "password": "123456", "method": "chacha20-ietf-poly1305" }, - { "server": "0.0.0.0", "server_port": 12345, "password": "123456", "method": "chacha20-ietf-poly1305" } - ], - "mode": "tcp_and_udp", + "servers": [ { + "server": "0.0.0.0", "server_port": 123, "password": "123456", "method": "chacha20-ietf-poly1305" }, { + "server": "0.0.0.0", "server_port": 1234, "password": "123456", "method": "chacha20-ietf-poly1305" }, { + "server": "0.0.0.0", "server_port": 12345, "password": "123456", "method": "chacha20-ietf-poly1305" + } ], "timeout": 1000, - "fast_open": true, + "mode": "tcp_only", "acl": "/opt/dr/common/shadowsocks-rust/server_block_local.acl" } ``` @@ -61,56 +50,58 @@ fc00::/7 fe80::/10 ``` -start with `sudo /opt/dr/common/shadowsocks-rust/ssserver -c /opt/dr/common/shadowsocks-rust/config.json` +start with `sudo ss-rust server -c /opt/dr/common/shadowsocks-rust/config.json` #### `shadowsocks` local config config `nano /opt/dr/common/shadowsocks-rust/local-config.json` add: ```json { - "local_address": "127.0.0.1", "local_port": 1081, + "locals": [ + { "local_address": "127.0.0.1", "local_port": 1081 }, + { "protocol": "http", "local_address": "127.0.0.1", "local_port": 1080 } + ], "server":"999.999.999.999", "server_port": 12345, "password": "123456", "method": "chacha20-ietf-poly1305", - "mode": "tcp_and_udp", - "timeout": 1000, - "fast_open": true + "mode": "tcp_only", "timeout": 1000 } ``` -start with `sudo /opt/dr/common/shadowsocks-rust/sslocal -c /opt/dr/common/shadowsocks-rust/local-config.json` - - -## install `privoxy` - -```shell script -sudo pacman -S privoxy --noconfirm # arch -sudo apt install privoxy -y # ubuntu -``` - -to convert http to socks5 for local `shadowsocks`, -edit `sudo nano /etc/privoxy/config` and add: -```shell script -# listen-address 127.0.0.1:8118 # should already have this line -listen-address 127.0.0.1:1080 # change to port 1080, change to 0.0.0.0:1080 to allow LAN proxy connection - -# check: https://www.privoxy.org/user-manual/config.html#SOCKS - -# convert protocol to socks5 and forward to shadowsocks -forward-socks5 / 127.0.0.1:1081 . - -# skip proxy common localhost connection -forward 192.168.*.*/ . -forward 10.*.*.*/ . -forward 127.*.*.*/ . -forward localhost/ . -``` - -apply config: -```shell script -sudo systemctl enable privoxy.service # enable server -sudo systemctl restart privoxy.service # apply config -sudo systemctl status privoxy.service # check status -``` +start with `sudo ss-rust local -c /opt/dr/common/shadowsocks-rust/local-config.json` + +this will open both `sock5@1081` and `http@1080`, so no `privoxy` needed + + ## install `privoxy` + + ```shell script + sudo pacman -S privoxy --noconfirm # arch + sudo apt install privoxy -y # ubuntu + ``` + + to convert http to socks5 for local `shadowsocks`, + edit `sudo nano /etc/privoxy/config` and add: + ```shell script + # listen-address 127.0.0.1:8118 # should already have this line + listen-address 0.0.0.0:1080 # change to port 1080, change to 0.0.0.0:1080 to allow LAN proxy connection + + # check: https://www.privoxy.org/user-manual/config.html#SOCKS + + # convert protocol to socks5 and forward to shadowsocks + forward-socks5 / 127.0.0.1:1081 . + + # skip proxy common localhost connection + forward 192.168.*.*/ . + forward 10.*.*.*/ . + forward 127.*.*.*/ . + forward localhost/ . + ``` + + apply config: + ```shell script + sudo systemctl enable privoxy.service # enable server + sudo systemctl restart privoxy.service # apply config + sudo systemctl status privoxy.service # check status + ``` basic usage: ```shell script diff --git a/linux/9-6-docker.md b/linux/9-6-docker.md index 6fce9f2..bd57b12 100644 --- a/linux/9-6-docker.md +++ b/linux/9-6-docker.md @@ -7,25 +7,48 @@ check: https://docs.docker.com/config/containers/logging/configure/#configure-th basically run `sudo mkdir -p /etc/docker/ && sudo nano /etc/docker/daemon.json` and add: ```json { - "log-driver": "json-file", - "log-opts": { "max-size": "8m", "max-file": "4" } + "experimental": true, "features": { "buildkit": true }, + "log-driver": "json-file", "log-opts": { "max-size": "8m", "max-file": "4" } } ``` Note: should restart `dockerd`, and re-create existing container for default log config to fully apply -#### install `docker-compose@1.29.2` +```json5 +{ + // change root + "data-root": "/mnt/some-disk/docker", + + // enable latest features + "experimental": true, "features": { "buildkit": true } +} +``` + +#### install `docker-compose@2` -because docker-compose V2 is still not stable & reasonable enough (20220825) +use docker-compose V2 for faster compose +https://docs.docker.com/compose/install/standalone/ ```shell sudo curl \ - -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-Linux-x86_64" \ + -L "https://github.com/docker/compose/releases/download/v2.29.0/docker-compose-linux-$(uname -m)" \ -o "/usr/local/bin/docker-compose" sudo chmod +x "/usr/local/bin/docker-compose" -[[ -f /usr/lib/libcrypt.so.1 ]] || ( echo 'missing "/usr/lib/libcrypt.so.1"'; ls -al /usr/lib/libcrypt.*; sudo ln -sfT libcrypt.so /usr/lib/libcrypt.so.1 ) # patch old python lib for arch-linux docker-compose -v ``` + #### install `docker-compose@1.29.2` + + because docker-compose V2 is still not stable & reasonable enough (20220825) + + ```shell + sudo curl \ + -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-Linux-$(uname -m)" \ + -o "/usr/local/bin/docker-compose" + sudo chmod +x "/usr/local/bin/docker-compose" + [[ -f /usr/lib/libcrypt.so.1 ]] || ( echo 'missing "/usr/lib/libcrypt.so.1"'; ls -al /usr/lib/libcrypt.*; sudo ln -sfT libcrypt.so /usr/lib/libcrypt.so.1 ) # patch old python lib for arch-linux + docker-compose -v + ``` + #### WSL2 for WSL2 Debian extra patch will be needed: https://github.com/microsoft/WSL/discussions/4872#discussioncomment-76635