Compare commits

...

17 Commits

Author SHA1 Message Date
Luk
bde475b433 u 2026-03-16 14:16:16 +08:00
Luk
c55b9931df u 2026-03-08 11:26:35 +08:00
Luk
4ffa88309e u 2026-03-07 20:22:14 +08:00
Luk
c723878a28 u 2026-03-07 15:53:59 +08:00
Luk
4cf98bc2cc u 2026-03-07 15:11:16 +08:00
Luk
d75c6b7d02 u 2026-02-24 11:20:15 +08:00
Luk
0d44ffbc99 u 2026-02-17 12:45:55 +08:00
Luk
9fad039627 u 2026-02-07 15:50:34 +08:00
Luk
aaff2c0a5f u 2026-02-07 15:08:00 +08:00
Luk
c8cd6ebd8e u 2026-02-07 15:06:52 +08:00
Luk
ac89a6b599 u 2026-02-07 15:02:03 +08:00
Luk
0fb47c30a2 u 2026-02-07 14:59:22 +08:00
Luk
fc75375f93 u 2026-02-07 14:58:14 +08:00
Luk
01ab07c7ea u 2026-02-07 14:56:25 +08:00
Luk
60e06abd72 u 2026-02-07 14:52:54 +08:00
Luk
13f6318023 rename /npm/ to /open/ 2026-02-06 19:36:57 +08:00
Luk
2a2be82375 u 2026-02-06 18:47:43 +08:00
23 changed files with 267 additions and 84 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

@@ -2,11 +2,11 @@ FROM debian:12.8
LABEL org.opencontainers.image.authors="luk"
RUN apt update && apt install curl -y
RUN curl -s https://git.tic.cc/npm/sysconfig/raw/branch/main/debian-setup.sh | bash
RUN curl -s https://git.tic.cc/open/sysconfig/raw/branch/main/debian-setup.sh | bash
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,6 +1,6 @@
#!/bin/bash
## "curl -s https://git.tic.cc/npm/sysconfig/raw/branch/main/debian-setup.sh | bash"
## "curl -s https://git.tic.cc/open/sysconfig/raw/branch/main/debian-setup.sh | bash"
echo "Usage: this.sh [NewUser]"
echo "Example: this.sh alice"
@@ -26,7 +26,7 @@ echo "::*** Git cloning to /faronear/sysconfig"
git config --global credential.helper cache
if [ ! -d "/faronear/sysconfig" ]
then
git clone https://git.tic.cc/npm/sysconfig /faronear/sysconfig
git clone https://git.tic.cc/open/sysconfig /faronear/sysconfig
chmod -R 755 /faronear # 确保其他用户能够读取 /faronear/sysconfig/nixhome/*
fi
echo

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

@@ -37,7 +37,7 @@ if [ $targetUrl ]
then
read -p "Enter adot password (ROAD) >>" PWD_ADOT
read -p "Enter root password (YU) >>" PWD_ROOT
expect ~/faronear/npm/sysconfig/expect-ssh.sh $targetUrl adot $PWD_ADOT $PWD_ADOT
expect ~/faronear/sysconfig/expect-ssh.sh $targetUrl adot $PWD_ADOT $PWD_ADOT
else
while [ ! "$HOST" ]
do

View File

@@ -23,11 +23,11 @@ if not exist "%ROOTPATH%" (
echo √√√ ROOTPATH = [[%ROOTPATH%]]
)
echo ::*** Enter [path to .gitignore_global] or [leave blank] for default [[https://git.tic.cc/npm/sysconfig/raw/branch/main/nixhome/.gitignore_global]]
echo ::*** Enter [path to .gitignore_global] or [leave blank] for default [[https://git.tic.cc/open/sysconfig/raw/branch/main/nixhome/.gitignore_global]]
set /p GLOBALPATH=">>> "
echo;
if "" == "%GLOBALPATH%" (
set GLOBALPATH=https://git.tic.cc/npm/sysconfig/raw/branch/main/nixhome/.gitignore_global
set GLOBALPATH=https://git.tic.cc/open/sysconfig/raw/branch/main/nixhome/.gitignore_global
) else (
for %P in (%GLOBALPATH%) do set "GLOBALPATH=%~dpnxP/.gitignore_global"
if not exist "%GLOBALPATH%" (

View File

@@ -26,7 +26,7 @@ else
fi
echo ""
echo "::*** Enter [path to .gitignore_global] or [leave blank] for default [[https://git.tic.cc/npm/sysconfig/raw/branch/main/nixhome/.gitignore_global]]"
echo "::*** Enter [path to .gitignore_global] or [leave blank] for default [[https://git.tic.cc/open/sysconfig/raw/branch/main/nixhome/.gitignore_global]]"
read -p "***:: " GLOBALPATH
if [ "$GLOBALPATH" ]
then
@@ -42,7 +42,7 @@ then
echo "√√√ GLOBALPATH = [[$GLOBALPATH]]"
fi
else
GLOBALPATH=https://git.tic.cc/npm/sysconfig/raw/branch/main/nixhome/.gitignore_global
GLOBALPATH=https://git.tic.cc/open/sysconfig/raw/branch/main/nixhome/.gitignore_global
fi
echo ""

View File

@@ -3,7 +3,7 @@
set -e
DISKNAME=vdisk
DISKSIZE=33554432 # 磁盘扇区数,每个扇区大小是 512 字节,n*1024*1024*1024/512 = n Gigabytes. Do NOT set the formula to DISKSIZE.
DISKSIZE=50331648 # 磁盘扇区数,每个扇区大小是 512 字节,1 Gigabytes 有 1024*1024*1024/512 = 2097152 扇区.
# 虚拟磁盘并不是一创建就把内存空间划走,而是等到真正写入了虚拟磁盘的时候,才会使用对应的内存空间,所以给虚拟磁盘分配大一点的空间是没有问题的
if [ -d /Volumes/$DISKNAME ]; then
@@ -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

@@ -0,0 +1,4 @@
cd /Library/Application\ Support/Microsoft/MAU2.0
# sudo chmod 000 Microsoft\ AutoUpdate.app
sudo mv Microsoft\ AutoUpdate.app MicrosoftAutoupdateDisabled.app

View File

@@ -1,4 +1,8 @@
echo Local IP: $(echo `hostname -I` | awk '{print $1;}')
if [ "$(uname)" = "Darwin" ]; then
echo Local IP: $(ifconfig en0 | grep "inet " | awk '{print $2}')
else
echo Local IP: $(echo `hostname -I` | awk '{print $1;}')
fi
echo Public IP: `curl -s ifconfig.me`
echo

View File

@@ -53,7 +53,7 @@ if [ -d "$HomePath" ]; then
echo "--- Copying [[$NIXHOME/$homescript]] to [[$HomePath/$homescript]] ..."
cp -r "$NIXHOME/$homescript" ./
elif [ "$CopyOrLinkScripts" == 'g' ]; then
curl -sSLO "https://git.tic.cc/npm/sysconfig/raw/branch/main/nixhome/$homescript"
curl -sSLO "https://git.tic.cc/open/sysconfig/raw/branch/main/nixhome/$homescript"
fi
done

View File

@@ -19,7 +19,3 @@ unset USERNAME
################################################################################
# End Of File: "~/.bash_profile"
################################################################################
# Added by OrbStack: command-line tools and integration
# This won't be added again if you remove it.
source ~/.orbstack/shell/init.bash 2>/dev/null || :

View File

@@ -79,7 +79,7 @@ umask 022 # rwxr-xr-x
############## following settings copied from amazon's debian ####################
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
debian_chroot=$(cat /etc/debian_chroot)
fi
## uncomment for a colored prompt, if the terminal has the capability; turned
@@ -99,7 +99,7 @@ fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
xterm-color|*-256color) color_prompt=yes;;
esac
# color starts with \[\033[${Style};${Type}${Color}m\] and ends with \[\033[00m\].
@@ -126,19 +126,39 @@ esac
# \w shows absolute path, \W shows current folder.
if [ "$(uname)" = "Darwin" ]; then
MYOSVERSION=Mac`sw_vers -productVersion`
elif [ -f /etc/debian_version ]; then
MYOSVERSION=Deb`cat /etc/debian_version 2>/dev/null`
elif [ -f /etc/ubuntu_version ]; then
MYOSVERSION=Ubt`cat /etc/ubuntu_version 2>/dev/null`
MYIPLAN=$(ifconfig en0 | grep "inet " | awk '{print $2}')
else
MYIPLAN=$(echo `hostname -I` | awk '{print $1;}')
fi
if [[ -n "$SSH_CONNECTION" ]]; then
IN_SSH="[ssh]"
MYIPPUB=$(curl -s ifconfig.me)
if [ "$(uname)" = "Darwin" ]; then
PSTYLE=07
PTYPE=3
elif [ "$(whoami)" = "root" ]; then
PSTYLE=07
PTYPE=4
AS_ROOT="#"
else
PSTYLE=07
PTYPE=3
if [[ -n "$SSH_CONNECTION" ]]; then
IN_SSH="$"
fi
fi
if [ "$(uname)" = "Darwin" ]; then
MYOSVERSION=Mac`sw_vers -productVersion`
elif [ "$(uname)" = "FreeBSD" ]; then
MYOSVERSION=$(echo "$(uname -r)" | cut -d'-' -f1)
elif [ -f /etc/debian_version ]; then
MYOSVERSION=Deb`cat /etc/debian_version 2>/dev/null`
elif [ -f /etc/ubuntu_version ]; then
MYOSVERSION=Ubt`cat /etc/ubuntu_version 2>/dev/null`
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[$PSTYLE;${PTYPE}2m\]\t\[\033[00m\]#\[\033[$PSTYLE;${PTYPE}5m\]\u\[\033[00m\]@\[\033[$PSTYLE;${PTYPE}1m\]\h\[\033[00m\]=\[\033[$PSTYLE;${PTYPE}4m\]$MYIPPUB\[\033[00m\]^\[\033[$PSTYLE;${PTYPE}5m\]$(uname -m),$(uname),$MYOSVERSION\[\033[00m\]:\[\033[$PSTYLE;${PTYPE}2m\]\w\[\033[00m\]>$IN_SSH$AS_ROOT '
else
PS1='<\t#\u@\h^$(uname -m),$(uname),$MYOSVERSION:$IN_SSH:\w> ' # \w shows absolute path, \W shows current folder.
PS1='<\t#\u@\h=$MYIPPUB^$(uname -m),$(uname),$MYOSVERSION:\w>$IN_SSH$AS_ROOT ' # \w shows absolute path, \W shows current folder.
fi
unset color_prompt force_color_prompt
@@ -166,13 +186,19 @@ fi
# eval "$(fnm env --use-on-cd)"
# fi
# acme.sh settings
# acme.sh
if [ -f $HOME/.acme.sh/acme.sh.env ]
then
. "$HOME/.acme.sh/acme.sh.env"
alias acme=$HOME/.acme.sh/acme.sh
fi
# Added by OrbStack: command-line tools and integration
if [ "$(uname)" = "Darwin" ] && [ -f $HOME/.orbstack/shell/init.bash ]
then
source ~/.orbstack/shell/init.bash 2>/dev/null || :
fi
# let MacOS uses the same variable so that vscode-sshfs can use "$USERPROFILE/.ssh/id_rsa" uniformly.
export USERPROFILE=$HOME
@@ -190,3 +216,4 @@ fi
################################################################################
# End Of File: "~/.bashrc"
################################################################################

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

58
photo_rename_folders.sh Normal file
View File

@@ -0,0 +1,58 @@
#!/bin/bash
# 指定目录
if [ "$1" ]; then
base_dir=$1
else
read -p "Please enter [root directory] to rename 1st level subfolders: " base_dir
fi
if [[ -d "$base_dir" ]]; then
base_dir=$(realpath $base_dir)
echo Searching in $base_dir;
else
echo not a folder!
exit 0
fi;
# Prompt user for input
read -p "Please enter [prod] to rename, or [anything else] to dry run: " user_input
# 遍历所有目录
for dir in "$base_dir"/*/; do
# 提取目录名称,去掉末尾的斜杠
dir_name=$(basename "$dir")
# 调试输出:检查目录名称
echo "Processing: $dir_name"
# 使用正则表达式提取前缀(可选)、年份、月份和日期
if [[ $dir_name =~ ^([^,]*),?\ ([0-9]{4})([0-9]{1,2})([0-9]{1,2})日$ ]]; then
# 有前缀的情况
prefix="${BASH_REMATCH[1]}"
year="${BASH_REMATCH[2]}"
month=$(printf "%02d" "${BASH_REMATCH[3]}")
day=$(printf "%02d" "${BASH_REMATCH[4]}")
elif [[ $dir_name =~ ^([0-9]{4})([0-9]{1,2})([0-9]{1,2})日$ ]]; then
# 没有前缀的情况
prefix=""
year="${BASH_REMATCH[1]}"
month=$(printf "%02d" "${BASH_REMATCH[2]}")
day=$(printf "%02d" "${BASH_REMATCH[3]}")
else
echo "Skipping: $dir_name (not matching expected format)"
continue
fi
# 创建新的目录名称
new_name="${year}${month}${day}"
if [[ -n "$prefix" ]]; then
new_name="${new_name}_${prefix// /_}" # 替换空格为下划线
fi
# 重命名目录
if [[ "$user_input" == "prod" ]]; then mv "$dir" "$base_dir/$new_name"; fi;
echo "Renamed: $dir_name -> $new_name"
done

71
photo_rename_images.sh Normal file
View File

@@ -0,0 +1,71 @@
#!/bin/bash
# 设置要处理的目录
if [ "$1" ]; then
base_dir=$1
else
read -p "Please enter [root directory] to rename images recursively: " target_directory
fi
if [[ -d "$target_directory" ]]; then
echo Searching in $(realpath $target_directory);
else
echo $target_directory is not a folder!
exit 0
fi;
# Prompt user for input
read -p "Please enter [prod] to rename, or [anything else] to dry run: " user_input
# 查找并遍历所有文件
find "$target_directory" -type f | while read -r file; do
# 获取文件的原名和扩展名
dir_name=$(dirname "$file")
base_name=$(basename "$file")
extension="${base_name##*.}"
if [[ "$extension" = "7z" ]] || [[ "$extension" = "DS_Store" ]] || [[ "$extension" = "aae" ]] || [[ "$base_name" == *"unkn#own"* ]]; then
echo === Bypassing $base_name
elif [[ "$base_name" =~ ^\[?[0-9]{8}[-_][0-9]{6}\]? ]]; then
#echo === Formatting $base_name
# 删除文件名中的 [ 和 ],并将日期时间后的 - 或空格 替换为 #
new_name=$(echo "$base_name" | sed -E 's/\[?([0-9]{8})[-_]([0-9]{6})\]?[- ]/\1#\2_/g; s/\[?([0-9]{8})[-_]([0-9]{6})\]?/\1#\2/g; s/\[|\]//g')
# 如果重命名后的文件名与原文件名不同,则进行重命名
if [[ "$base_name" != "$new_name" ]]; then
if [[ "$user_input" == "prod" ]]; then mv "$file" "$dir_name/$new_name"; fi;
echo "$base_name -> $new_name"
fi
elif [[ ! "$base_name" =~ ^[0-9]{8}#[0-9]{6} ]]; then
#echo === Add datetime $base_name
# 获取文件的拍摄日期假设日期以EXIF元数据存储
# 需要安装 exiftool
date_taken=$(exiftool -ExtractEmbedded -d "%Y%m%d#%H%M%S" -DateTimeOriginal -CreationDate -s -s -s "$file")
# 检查日期是否为空和文件名格式
if [ -n "$date_taken" ]; then
# 生成新的文件名
new_name="${date_taken}_${base_name}"
# 重命名文件
if [[ "$user_input" == "prod" ]]; then mv "$file" "$dir_name/$new_name"; fi;
echo "$base_name -> $new_name"
else
new_name="unkn#own_${base_name}"
# 重命名文件
if [[ "$user_input" == "prod" ]]; then mv "$file" "$dir_name/$new_name"; fi;
echo "$base_name -> $new_name"
fi
else
echo === Unknown $base_name
fi
done

View File

@@ -11,10 +11,10 @@ fi
# to reset port to empty, otherwise the second run of this script will not ask for port.
PORT=
PORTDEFAULT=17890
PORTDEFAULT=7897
# function proxy() {
if [ "$proxySwitch" == "s" ] || [ "$proxySwitch" == "1" ]; then
echo "::*** Proxy server running on [port number] or [leave blank] for default $PORTDEFAULT (20170 for v2ray2, 17890 for 零点云, or 7897 for clash verge)"
echo "::*** Proxy server running on [port number] or [leave blank] for default $PORTDEFAULT (20170 for v2ray2, 7897 for 零点云 or clash verge)"
while [ ! "$PORT" ]
do
read -p "***:: " PORT

View File

@@ -23,11 +23,11 @@ if not exist "%ROOTPATH%" (
echo √√√ ROOTPATH = [[%ROOTPATH%]]
)
echo ::*** Enter [path to seafile-ignore.global.txt] or [leave blank] for default [[https://git.tic.cc/npm/sysconfig/raw/branch/main/nixhome/seafile-ignore.global.txt]]
echo ::*** Enter [path to seafile-ignore.global.txt] or [leave blank] for default [[https://git.tic.cc/open/sysconfig/raw/branch/main/nixhome/seafile-ignore.global.txt]]
set /p IGNOREPATH=">>> "
echo;
if "" == "%IGNOREPATH%" (
set IGNOREPATH=https://git.tic.cc/npm/sysconfig/raw/branch/main/nixhome/seafile-ignore.global.txt
set IGNOREPATH=https://git.tic.cc/open/sysconfig/raw/branch/main/nixhome/seafile-ignore.global.txt
) else (
for %P in (%IGNOREPATH%) do set "IGNOREPATH=%~dpnxP/seafile-ignore.global.txt"
if not exist "%IGNOREPATH%" (

View File

@@ -26,7 +26,7 @@ else
fi
echo ""
echo "::*** Enter [path to seafile-ignore.global.txt] or [leave blank] for default [[https://git.tic.cc/npm/sysconfig/raw/branch/main/nixhome/seafile-ignore.global.txt]]"
echo "::*** Enter [path to seafile-ignore.global.txt] or [leave blank] for default [[https://git.tic.cc/open/sysconfig/raw/branch/main/nixhome/seafile-ignore.global.txt]]"
read -p "***:: " GLOBALPATH
if [ "$GLOBALPATH" ]
then
@@ -42,7 +42,7 @@ then
echo "√√√ GLOBALPATH = [[$GLOBALPATH]]"
fi
else
GLOBALPATH=https://git.tic.cc/npm/sysconfig/raw/branch/main/nixhome/seafile-ignore.global.txt
GLOBALPATH=https://git.tic.cc/open/sysconfig/raw/branch/main/nixhome/seafile-ignore.global.txt
fi
echo ""

View File

@@ -1,6 +1,6 @@
#!/bin/bash
echo ::*** Merge remote [seafile-ignore.global.txt] and local [seafile-ignore.local.txt] to [seafile-ignore.txt]
curl -sSL https://git.tic.cc/npm/sysconfig/raw/branch/main/nixhome/seafile-ignore.global.txt > seafile-ignore.txt
curl -sSL https://git.tic.cc/open/sysconfig/raw/branch/main/nixhome/seafile-ignore.global.txt > seafile-ignore.txt
if [ -f seafile-ignore.local.txt ]; then cat seafile-ignore.local.txt >> seafile-ignore.txt; fi
echo

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) [host_to_ssh] [cmd_to_run]"
# 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
# 如果提供了参数,则直接使用这个前缀
host_to_ssh=$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 "请输入要连接的主机前缀: " host_to_ssh
fi
echo
# 查找用户输入对应的索引
selected_index=-1
for i in "${!prefixes[@]}"; do
if [[ "${prefixes[$i]}" == "$host_to_ssh" ]]; 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 '$2'"
sshpass -p "$password" ssh -Y -p "$port" "$username@$host" "$2"
else
echo "::*** ssh -Y -p $port $username@$host '$2'"
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 '$2'"
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