Compare commits
17 Commits
5920cde656
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bde475b433 | ||
|
|
c55b9931df | ||
|
|
4ffa88309e | ||
|
|
c723878a28 | ||
|
|
4cf98bc2cc | ||
|
|
d75c6b7d02 | ||
|
|
0d44ffbc99 | ||
|
|
9fad039627 | ||
|
|
aaff2c0a5f | ||
|
|
c8cd6ebd8e | ||
|
|
ac89a6b599 | ||
|
|
0fb47c30a2 | ||
|
|
fc75375f93 | ||
|
|
01ab07c7ea | ||
|
|
60e06abd72 | ||
|
|
13f6318023 | ||
|
|
2a2be82375 |
@@ -9,3 +9,8 @@ sudo apt install caddy
|
|||||||
echo
|
echo
|
||||||
echo Certificates will be saved automatically in ~/.local/share/caddy/certificates/acme-v02.api.letsencrypt.org-directory/
|
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
|
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
|
||||||
|
|||||||
@@ -2,11 +2,11 @@ FROM debian:12.8
|
|||||||
LABEL org.opencontainers.image.authors="luk"
|
LABEL org.opencontainers.image.authors="luk"
|
||||||
|
|
||||||
RUN apt update && apt install curl -y
|
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
|
CMD bash
|
||||||
|
|
||||||
# mv $(basename "$0") Dockerfile
|
# mv $(basename $0) Dockerfile
|
||||||
# docker build -t debian-faronear .
|
# docker build -t debian-faronear .
|
||||||
# docker tag debian-faronear anolaxy/debian-faronear:11.5-20221205
|
# docker tag debian-faronear anolaxy/debian-faronear:11.5-20221205
|
||||||
# docker login
|
# docker login
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/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 "Usage: this.sh [NewUser]"
|
||||||
echo "Example: this.sh alice"
|
echo "Example: this.sh alice"
|
||||||
@@ -26,7 +26,7 @@ echo "::*** Git cloning to /faronear/sysconfig"
|
|||||||
git config --global credential.helper cache
|
git config --global credential.helper cache
|
||||||
if [ ! -d "/faronear/sysconfig" ]
|
if [ ! -d "/faronear/sysconfig" ]
|
||||||
then
|
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/*
|
chmod -R 755 /faronear # 确保其他用户能够读取 /faronear/sysconfig/nixhome/*
|
||||||
fi
|
fi
|
||||||
echo
|
echo
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
echo "Usage:"
|
echo "Usage:"
|
||||||
echo ' "this-script.sh [imageName]" to search library/[imageName]'
|
echo " $(basename $0) [imageName] ===> to search library/[imageName]"
|
||||||
echo ' "this-script.sh [imageName] [ownerName]" to search [ownerName]/[imageName]'
|
echo " $(basename $0) [imageName] [ownerName] ===> to search [ownerName]/[imageName]"
|
||||||
echo ' "this.script.sh" to interactive enter [ownerName] and [imageName] to search'
|
echo " $(basename $0) ===> to interactive enter [ownerName] and [imageName] to search"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
IMAGE=$1
|
IMAGE=$1
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ if [ $targetUrl ]
|
|||||||
then
|
then
|
||||||
read -p "Enter adot password (ROAD) >>" PWD_ADOT
|
read -p "Enter adot password (ROAD) >>" PWD_ADOT
|
||||||
read -p "Enter root password (YU) >>" PWD_ROOT
|
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
|
else
|
||||||
while [ ! "$HOST" ]
|
while [ ! "$HOST" ]
|
||||||
do
|
do
|
||||||
|
|||||||
@@ -23,11 +23,11 @@ if not exist "%ROOTPATH%" (
|
|||||||
echo √√√ ROOTPATH = [[%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=">>> "
|
set /p GLOBALPATH=">>> "
|
||||||
echo;
|
echo;
|
||||||
if "" == "%GLOBALPATH%" (
|
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 (
|
) else (
|
||||||
for %P in (%GLOBALPATH%) do set "GLOBALPATH=%~dpnxP/.gitignore_global"
|
for %P in (%GLOBALPATH%) do set "GLOBALPATH=%~dpnxP/.gitignore_global"
|
||||||
if not exist "%GLOBALPATH%" (
|
if not exist "%GLOBALPATH%" (
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ else
|
|||||||
fi
|
fi
|
||||||
echo ""
|
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
|
read -p "***:: " GLOBALPATH
|
||||||
if [ "$GLOBALPATH" ]
|
if [ "$GLOBALPATH" ]
|
||||||
then
|
then
|
||||||
@@ -42,7 +42,7 @@ then
|
|||||||
echo "√√√ GLOBALPATH = [[$GLOBALPATH]]"
|
echo "√√√ GLOBALPATH = [[$GLOBALPATH]]"
|
||||||
fi
|
fi
|
||||||
else
|
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
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
DISKNAME=vdisk
|
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
|
if [ -d /Volumes/$DISKNAME ]; then
|
||||||
@@ -13,6 +13,6 @@ else
|
|||||||
diskutil apfs create ${DISKID} $DISKNAME
|
diskutil apfs create ${DISKID} $DISKNAME
|
||||||
fi
|
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/,
|
# copy the corresponding plist file to /Library/LaunchDaemons/,
|
||||||
# optionally run `sudo launchctl load /Library/LaunchDaemons/my-launch-file.plist` immediately for test.
|
# optionally run `sudo launchctl load /Library/LaunchDaemons/my-launch-file.plist` immediately for test.
|
||||||
|
|||||||
4
mac-disable-msoffice-autoupdate.sh
Normal file
4
mac-disable-msoffice-autoupdate.sh
Normal 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
|
||||||
6
myip.sh
6
myip.sh
@@ -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 Public IP: `curl -s ifconfig.me`
|
||||||
echo
|
echo
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ if [ -d "$HomePath" ]; then
|
|||||||
echo "--- Copying [[$NIXHOME/$homescript]] to [[$HomePath/$homescript]] ..."
|
echo "--- Copying [[$NIXHOME/$homescript]] to [[$HomePath/$homescript]] ..."
|
||||||
cp -r "$NIXHOME/$homescript" ./
|
cp -r "$NIXHOME/$homescript" ./
|
||||||
elif [ "$CopyOrLinkScripts" == 'g' ]; then
|
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
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,3 @@ unset USERNAME
|
|||||||
################################################################################
|
################################################################################
|
||||||
# End Of File: "~/.bash_profile"
|
# 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 || :
|
|
||||||
|
|||||||
@@ -125,20 +125,40 @@ esac
|
|||||||
# others:
|
# others:
|
||||||
# \w shows absolute path, \W shows current folder.
|
# \w shows absolute path, \W shows current folder.
|
||||||
|
|
||||||
|
if [ "$(uname)" = "Darwin" ]; then
|
||||||
|
MYIPLAN=$(ifconfig en0 | grep "inet " | awk '{print $2}')
|
||||||
|
else
|
||||||
|
MYIPLAN=$(echo `hostname -I` | awk '{print $1;}')
|
||||||
|
fi
|
||||||
|
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
|
if [ "$(uname)" = "Darwin" ]; then
|
||||||
MYOSVERSION=Mac`sw_vers -productVersion`
|
MYOSVERSION=Mac`sw_vers -productVersion`
|
||||||
|
elif [ "$(uname)" = "FreeBSD" ]; then
|
||||||
|
MYOSVERSION=$(echo "$(uname -r)" | cut -d'-' -f1)
|
||||||
elif [ -f /etc/debian_version ]; then
|
elif [ -f /etc/debian_version ]; then
|
||||||
MYOSVERSION=Deb`cat /etc/debian_version 2>/dev/null`
|
MYOSVERSION=Deb`cat /etc/debian_version 2>/dev/null`
|
||||||
elif [ -f /etc/ubuntu_version ]; then
|
elif [ -f /etc/ubuntu_version ]; then
|
||||||
MYOSVERSION=Ubt`cat /etc/ubuntu_version 2>/dev/null`
|
MYOSVERSION=Ubt`cat /etc/ubuntu_version 2>/dev/null`
|
||||||
fi
|
fi
|
||||||
if [[ -n "$SSH_CONNECTION" ]]; then
|
|
||||||
IN_SSH="[ssh]"
|
|
||||||
fi
|
|
||||||
if [ "$color_prompt" = yes ]; then
|
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
|
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
|
fi
|
||||||
unset color_prompt force_color_prompt
|
unset color_prompt force_color_prompt
|
||||||
|
|
||||||
@@ -166,13 +186,19 @@ fi
|
|||||||
# eval "$(fnm env --use-on-cd)"
|
# eval "$(fnm env --use-on-cd)"
|
||||||
# fi
|
# fi
|
||||||
|
|
||||||
# acme.sh settings
|
# acme.sh
|
||||||
if [ -f $HOME/.acme.sh/acme.sh.env ]
|
if [ -f $HOME/.acme.sh/acme.sh.env ]
|
||||||
then
|
then
|
||||||
. "$HOME/.acme.sh/acme.sh.env"
|
. "$HOME/.acme.sh/acme.sh.env"
|
||||||
alias acme=$HOME/.acme.sh/acme.sh
|
alias acme=$HOME/.acme.sh/acme.sh
|
||||||
fi
|
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.
|
# let MacOS uses the same variable so that vscode-sshfs can use "$USERPROFILE/.ssh/id_rsa" uniformly.
|
||||||
export USERPROFILE=$HOME
|
export USERPROFILE=$HOME
|
||||||
|
|
||||||
@@ -190,3 +216,4 @@ fi
|
|||||||
################################################################################
|
################################################################################
|
||||||
# End Of File: "~/.bashrc"
|
# End Of File: "~/.bashrc"
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
echo "Usage: this-script.sh [VERSION]"
|
echo "Usage: $(basename $0) [VERSION]"
|
||||||
|
|
||||||
defaultVERSION=18.12.1
|
defaultVERSION=18.12.1
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/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/node
|
||||||
sudo rm -fr /usr/local/bin/npm
|
sudo rm -fr /usr/local/bin/npm
|
||||||
|
|||||||
58
photo_rename_folders.sh
Normal file
58
photo_rename_folders.sh
Normal 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
71
photo_rename_images.sh
Normal 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
|
||||||
4
proxy.sh
4
proxy.sh
@@ -11,10 +11,10 @@ fi
|
|||||||
|
|
||||||
# to reset port to empty, otherwise the second run of this script will not ask for port.
|
# to reset port to empty, otherwise the second run of this script will not ask for port.
|
||||||
PORT=
|
PORT=
|
||||||
PORTDEFAULT=17890
|
PORTDEFAULT=7897
|
||||||
# function proxy() {
|
# function proxy() {
|
||||||
if [ "$proxySwitch" == "s" ] || [ "$proxySwitch" == "1" ]; then
|
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" ]
|
while [ ! "$PORT" ]
|
||||||
do
|
do
|
||||||
read -p "***:: " PORT
|
read -p "***:: " PORT
|
||||||
|
|||||||
@@ -23,11 +23,11 @@ if not exist "%ROOTPATH%" (
|
|||||||
echo √√√ ROOTPATH = [[%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=">>> "
|
set /p IGNOREPATH=">>> "
|
||||||
echo;
|
echo;
|
||||||
if "" == "%IGNOREPATH%" (
|
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 (
|
) else (
|
||||||
for %P in (%IGNOREPATH%) do set "IGNOREPATH=%~dpnxP/seafile-ignore.global.txt"
|
for %P in (%IGNOREPATH%) do set "IGNOREPATH=%~dpnxP/seafile-ignore.global.txt"
|
||||||
if not exist "%IGNOREPATH%" (
|
if not exist "%IGNOREPATH%" (
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ else
|
|||||||
fi
|
fi
|
||||||
echo ""
|
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
|
read -p "***:: " GLOBALPATH
|
||||||
if [ "$GLOBALPATH" ]
|
if [ "$GLOBALPATH" ]
|
||||||
then
|
then
|
||||||
@@ -42,7 +42,7 @@ then
|
|||||||
echo "√√√ GLOBALPATH = [[$GLOBALPATH]]"
|
echo "√√√ GLOBALPATH = [[$GLOBALPATH]]"
|
||||||
fi
|
fi
|
||||||
else
|
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
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
echo ::*** Merge remote [seafile-ignore.global.txt] and local [seafile-ignore.local.txt] to [seafile-ignore.txt]
|
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
|
if [ -f seafile-ignore.local.txt ]; then cat seafile-ignore.local.txt >> seafile-ignore.txt; fi
|
||||||
echo
|
echo
|
||||||
|
|||||||
81
ssh.sh
81
ssh.sh
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/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
|
# Ensure jq is installed
|
||||||
if ! command -v jq &> /dev/null; then
|
if ! command -v jq &> /dev/null; then
|
||||||
@@ -18,14 +18,6 @@ if [[ ! -f "$SETTINGS_FILE" ]]; then
|
|||||||
fi
|
fi
|
||||||
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
|
# Parse the JSON to get labels and corresponding details
|
||||||
labels=($(jq -r '.["sshfs.configs"][] | .label' "$SETTINGS_FILE"))
|
labels=($(jq -r '.["sshfs.configs"][] | .label' "$SETTINGS_FILE"))
|
||||||
hosts=($(jq -r '.["sshfs.configs"][] | .host' "$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"))
|
passwords=($(jq -r '.["sshfs.configs"][] | .password' "$SETTINGS_FILE"))
|
||||||
privateKeyPaths=($(jq -r '.["sshfs.configs"][] | .privateKeyPath' "$SETTINGS_FILE"))
|
privateKeyPaths=($(jq -r '.["sshfs.configs"][] | .privateKeyPath' "$SETTINGS_FILE"))
|
||||||
|
|
||||||
if [ "$1" -ge 0 ] 2>/dev/null && [ "$1" -le ${#hosts[@]} ] 2>/dev/null
|
options=()
|
||||||
then
|
prefixes=()
|
||||||
selected_index=$1-1
|
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
|
else
|
||||||
echo "Select a target to connect via SSH, or press 0 to exit:"
|
echo "Select a target to connect via SSH, or press 0 to exit:"
|
||||||
select target in "${labels[@]}"
|
echo
|
||||||
do
|
|
||||||
if [[ -n "$target" ]]; then
|
# Display options without numbers
|
||||||
selected_index=$REPLY-1
|
for opt in "${options[@]}"; do
|
||||||
break
|
echo "$opt"
|
||||||
elif [ "$REPLY" = '0' ]; then
|
|
||||||
exit 0
|
|
||||||
else
|
|
||||||
echo "Invalid selection. Try again."
|
|
||||||
fi
|
|
||||||
done
|
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
|
||||||
|
|
||||||
|
# 如果没有找到匹配的索引
|
||||||
|
if [ "$selected_index" -eq -1 ]; then
|
||||||
|
echo "无效的选择,请重试。"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
label="${labels[$selected_index]}"
|
label="${labels[$selected_index]}"
|
||||||
@@ -61,23 +77,20 @@ username="${usernames[$selected_index]}"
|
|||||||
password="${passwords[$selected_index]}"
|
password="${passwords[$selected_index]}"
|
||||||
privateKeyPath="${privateKeyPaths[$selected_index]}"
|
privateKeyPath="${privateKeyPaths[$selected_index]}"
|
||||||
|
|
||||||
if [ "$port" = "null" ]
|
if [ "$port" = "null" ]; then
|
||||||
then
|
|
||||||
port=22
|
port=22
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "::*** Connecting to ${label}"
|
echo "::*** Connecting to ${label}"
|
||||||
if [ "$password" != "null" ]
|
if [ "$password" != "null" ]; then
|
||||||
then
|
if command -v sshpass &> /dev/null; then
|
||||||
if [ "$(which sshpass)" ]
|
echo "::*** sshpass -p $password -Y -p $port $username@$host '$2'"
|
||||||
then
|
sshpass -p "$password" ssh -Y -p "$port" "$username@$host" "$2"
|
||||||
echo "::*** sshpass -p $password -Y -p $port $username@$host"
|
|
||||||
sshpass -p $password ssh -Y -p $port "$username@$host" $2
|
|
||||||
else
|
else
|
||||||
echo "::*** ssh -Y -p $port $username@$host"
|
echo "::*** ssh -Y -p $port $username@$host '$2'"
|
||||||
ssh -Y -p $port "$username@$host" $2 # -X 在 linux 安装 xrdp 后连接时报错,改 -Y 就可。
|
ssh -Y -p "$port" "$username@$host" "$2"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "::*** ssh -Y -p $port $username@$host"
|
echo "::*** ssh -Y -p $port $username@$host '$2'"
|
||||||
ssh -Y -p $port "$username@$host" $2
|
ssh -Y -p "$port" "$username@$host" "$2"
|
||||||
fi
|
fi
|
||||||
@@ -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
|
sudo tailscale up --advertise-exit-node
|
||||||
|
|||||||
Reference in New Issue
Block a user