This commit is contained in:
Luk
2026-02-06 18:47:43 +08:00
parent 5920cde656
commit 2a2be82375
9 changed files with 76 additions and 53 deletions

View File

@@ -9,3 +9,8 @@ sudo apt install caddy
echo
echo Certificates will be saved automatically in ~/.local/share/caddy/certificates/acme-v02.api.letsencrypt.org-directory/
echo Config file of caddy started by systemctl : /etc/caddy/Caddyfile
# 202601 注意到 caddy 的 gpg.key 过时了,导致 apt update 报错。更新:
# https://github.com/caddyserver/caddy/issues/7411
# [Solved] Caddy's APT repo (ubuntu/debian) GPG key has expired · Issue #7411 · caddyserver/caddy
# curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg

View File

@@ -6,7 +6,7 @@ RUN curl -s https://git.tic.cc/npm/sysconfig/raw/branch/main/debian-setup.sh | b
CMD bash
# mv $(basename "$0") Dockerfile
# mv $(basename $0) Dockerfile
# docker build -t debian-faronear .
# docker tag debian-faronear anolaxy/debian-faronear:11.5-20221205
# docker login

View File

@@ -1,9 +1,9 @@
#!/bin/sh
echo "Usage:"
echo ' "this-script.sh [imageName]" to search library/[imageName]'
echo ' "this-script.sh [imageName] [ownerName]" to search [ownerName]/[imageName]'
echo ' "this.script.sh" to interactive enter [ownerName] and [imageName] to search'
echo " $(basename $0) [imageName] ===> to search library/[imageName]"
echo " $(basename $0) [imageName] [ownerName] ===> to search [ownerName]/[imageName]"
echo " $(basename $0) ===> to interactive enter [ownerName] and [imageName] to search"
echo
IMAGE=$1

View File

@@ -13,6 +13,6 @@ else
diskutil apfs create ${DISKID} $DISKNAME
fi
# copy this script to some public folder, e.g. `sudo cp this-script.sh /etc/`, because in my test, it doesn't work in /Users/...
# copy this script to some public folder, e.g. `sudo cp $(basename $0) /etc/`, because in my test, it doesn't work in /Users/...
# copy the corresponding plist file to /Library/LaunchDaemons/,
# optionally run `sudo launchctl load /Library/LaunchDaemons/my-launch-file.plist` immediately for test.

View File

@@ -133,12 +133,12 @@ elif [ -f /etc/ubuntu_version ]; then
MYOSVERSION=Ubt`cat /etc/ubuntu_version 2>/dev/null`
fi
if [[ -n "$SSH_CONNECTION" ]]; then
IN_SSH="[ssh]"
IN_SSH="ssh"
fi
if [ "$color_prompt" = yes ]; then
PS1='<\[\033[07;32m\]\t\[\033[00m\]#\[\033[07;35m\]\u\[\033[00m\]@\[\033[07;31m\]\h\[\033[00m\]^\[\033[07;34m\]$(uname -m),$(uname),$MYOSVERSION\[\033[00m\]:$IN_SSH:\[\033[07;36m\]\w\[\033[00m\]> '
PS1='<\[\033[07;32m\]\t\[\033[00m\]#\[\033[07;35m\]\u\[\033[00m\]@\[\033[07;31m\]\h\[\033[00m\]=\[\033[07;34m\]$(uname -m),$(uname),$MYOSVERSION\[\033[00m\]:$IN_SSH:\[\033[07;36m\]\w\[\033[00m\]> '
else
PS1='<\t#\u@\h^$(uname -m),$(uname),$MYOSVERSION:$IN_SSH:\w> ' # \w shows absolute path, \W shows current folder.
PS1='<\t#\u@\h=$(uname -m),$(uname),$MYOSVERSION:$IN_SSH:\w> ' # \w shows absolute path, \W shows current folder.
fi
unset color_prompt force_color_prompt

View File

@@ -1,6 +1,6 @@
#!/bin/bash
echo "Usage: this-script.sh [VERSION]"
echo "Usage: $(basename $0) [VERSION]"
defaultVERSION=18.12.1

View File

@@ -1,6 +1,6 @@
#!/bin/bash
echo "Usage: this-script.sh [VERSION]"
echo "Usage: $(basename $0) [VERSION]"
sudo rm -fr /usr/local/bin/node
sudo rm -fr /usr/local/bin/npm

99
ssh.sh
View File

@@ -1,6 +1,6 @@
#!/bin/bash
echo Usage: this_script.sh [selected_index] [to_run_cmd]
echo "Usage: $(basename $0) [selected_index] [to_run_cmd]"
# Ensure jq is installed
if ! command -v jq &> /dev/null; then
@@ -11,21 +11,13 @@ fi
# Path to the settings.json file
SETTINGS_FILE="$HOME/Library/Application Support/Code/User/settings.json"
if [[ ! -f "$SETTINGS_FILE" ]]; then
SETTINGS_FILE="$HOME/product_产品/.vscode/settings.json"
if [[ ! -f "$SETTINGS_FILE" ]]; then
echo "settings.json file not found!"
exit 1
fi
SETTINGS_FILE="$HOME/product_产品/.vscode/settings.json"
if [[ ! -f "$SETTINGS_FILE" ]]; then
echo "settings.json file not found!"
exit 1
fi
fi
# 自定义的列表但是测试有问题只有第一行被select添加了序号
# targets=$(jq -r '.["sshfs.configs"][] | "\(.name)"' "$SETTINGS_FILE")
# if [ -z "$targets" ]
# then
# echo "No configurations found in the settings.json file."
# exit 1
# fi
# Parse the JSON to get labels and corresponding details
labels=($(jq -r '.["sshfs.configs"][] | .label' "$SETTINGS_FILE"))
hosts=($(jq -r '.["sshfs.configs"][] | .host' "$SETTINGS_FILE"))
@@ -35,22 +27,46 @@ usernames=($(jq -r '.["sshfs.configs"][] | .username' "$SETTINGS_FILE"))
passwords=($(jq -r '.["sshfs.configs"][] | .password' "$SETTINGS_FILE"))
privateKeyPaths=($(jq -r '.["sshfs.configs"][] | .privateKeyPath' "$SETTINGS_FILE"))
if [ "$1" -ge 0 ] 2>/dev/null && [ "$1" -le ${#hosts[@]} ] 2>/dev/null
then
selected_index=$1-1
options=()
prefixes=()
for i in "${!labels[@]}"; do
option=$(echo "${labels[$i]}" | sed 's/[^[:alnum:]].*//') # 提取前几个字母和数字
options+=("$option: ${labels[$i]}") # 去掉序号保留前缀和完整label
prefixes+=("$option") # 保存前缀
done
# Check if a command-line argument is provided
if [ "$1" != "" ]; then
# 如果提供了参数,则直接使用这个前缀
user_input=$1
else
echo "Select a target to connect via SSH, or press 0 to exit:"
select target in "${labels[@]}"
do
if [[ -n "$target" ]]; then
selected_index=$REPLY-1
break
elif [ "$REPLY" = '0' ]; then
exit 0
else
echo "Invalid selection. Try again."
echo "Select a target to connect via SSH, or press 0 to exit:"
echo
# Display options without numbers
for opt in "${options[@]}"; do
echo "$opt"
done
echo
read -p "请输入要连接的主机前缀: " user_input
fi
echo
# 查找用户输入对应的索引
selected_index=-1
for i in "${!prefixes[@]}"; do
if [[ "${prefixes[$i]}" == "$user_input" ]]; then
selected_index=$i
break
fi
done
done
# 如果没有找到匹配的索引
if [ "$selected_index" -eq -1 ]; then
echo "无效的选择,请重试。"
exit 1
fi
label="${labels[$selected_index]}"
@@ -61,23 +77,20 @@ username="${usernames[$selected_index]}"
password="${passwords[$selected_index]}"
privateKeyPath="${privateKeyPaths[$selected_index]}"
if [ "$port" = "null" ]
then
port=22
if [ "$port" = "null" ]; then
port=22
fi
echo "::*** Connecting to ${label}"
if [ "$password" != "null" ]
then
if [ "$(which sshpass)" ]
then
echo "::*** sshpass -p $password -Y -p $port $username@$host"
sshpass -p $password ssh -Y -p $port "$username@$host" $2
else
echo "::*** ssh -Y -p $port $username@$host"
ssh -Y -p $port "$username@$host" $2 # -X 在 linux 安装 xrdp 后连接时报错,改 -Y 就可。
fi
if [ "$password" != "null" ]; then
if command -v sshpass &> /dev/null; then
echo "::*** sshpass -p $password -Y -p $port $username@$host"
sshpass -p "$password" ssh -Y -p "$port" "$username@$host" $2
else
echo "::*** ssh -Y -p $port $username@$host"
ssh -Y -p "$port" "$username@$host" $2
fi
else
echo "::*** ssh -Y -p $port $username@$host"
ssh -Y -p $port "$username@$host" $2
echo "::*** ssh -Y -p $port $username@$host"
ssh -Y -p "$port" "$username@$host" $2
fi

View File

@@ -1 +1,6 @@
## 这应该是一次性即可,然后在 Admin Console 网页里这个 exit node 上就不会有警告标记。但实际上即使有警告也能用做 exit node。
echo 'net.ipv4.ip_forward = 1' | sudo tee -a /etc/sysctl.conf
echo 'net.ipv6.conf.all.forwarding = 1' | sudo tee -a /etc/sysctl.conf
sudo sysctl -p /etc/sysctl.conf
sudo tailscale up --advertise-exit-node