diff --git a/debian-setup.Dockerfile b/debian-setup.Dockerfile index 5fe84cf..c907251 100644 --- a/debian-setup.Dockerfile +++ b/debian-setup.Dockerfile @@ -2,7 +2,7 @@ FROM debian:12.8 LABEL org.opencontainers.image.authors="luk" RUN apt update && apt install curl -y -RUN curl -s https://git.tic.cc/open/sysconfig/raw/branch/main/debian-setup.sh | bash +RUN curl -s https://git.tic.cc/opx/sysconfig/raw/branch/main/debian-setup.sh | bash CMD bash diff --git a/debian-setup.sh b/debian-setup.sh index 799197b..86bf3b5 100755 --- a/debian-setup.sh +++ b/debian-setup.sh @@ -1,6 +1,6 @@ #!/bin/bash -## "curl -s https://git.tic.cc/open/sysconfig/raw/branch/main/debian-setup.sh | bash" +## "curl -s https://git.tic.cc/opx/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/open/sysconfig /faronear/sysconfig + git clone https://git.tic.cc/opx/sysconfig /faronear/sysconfig chmod -R 755 /faronear # 确保其他用户能够读取 /faronear/sysconfig/nixhome/* fi echo diff --git a/git-ignore-find2merge.bat b/git-ignore-find2merge.bat index f77c324..cff5885 100644 --- a/git-ignore-find2merge.bat +++ b/git-ignore-find2merge.bat @@ -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/open/sysconfig/raw/branch/main/nixhome/.gitignore_global]] +echo ::*** Enter [path to .gitignore_global] or [leave blank] for default [[https://git.tic.cc/opx/sysconfig/raw/branch/main/nixhome/.gitignore_global]] set /p GLOBALPATH=">>> " echo; if "" == "%GLOBALPATH%" ( - set GLOBALPATH=https://git.tic.cc/open/sysconfig/raw/branch/main/nixhome/.gitignore_global + set GLOBALPATH=https://git.tic.cc/opx/sysconfig/raw/branch/main/nixhome/.gitignore_global ) else ( for %P in (%GLOBALPATH%) do set "GLOBALPATH=%~dpnxP/.gitignore_global" if not exist "%GLOBALPATH%" ( diff --git a/git-ignore-find2merge.sh b/git-ignore-find2merge.sh index 9c9bea9..3d9efea 100755 --- a/git-ignore-find2merge.sh +++ b/git-ignore-find2merge.sh @@ -26,7 +26,7 @@ else fi echo "" -echo "::*** Enter [path to .gitignore_global] or [leave blank] for default [[https://git.tic.cc/open/sysconfig/raw/branch/main/nixhome/.gitignore_global]]" +echo "::*** Enter [path to .gitignore_global] or [leave blank] for default [[https://git.tic.cc/opx/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/open/sysconfig/raw/branch/main/nixhome/.gitignore_global + GLOBALPATH=https://git.tic.cc/opx/sysconfig/raw/branch/main/nixhome/.gitignore_global fi echo "" diff --git a/mac-create-vdisk.sh b/mac-create-vdisk.sh index 9337a03..3583436 100755 --- a/mac-create-vdisk.sh +++ b/mac-create-vdisk.sh @@ -13,6 +13,85 @@ else diskutil apfs create ${DISKID} $DISKNAME fi +cat <<'EOF' > /Volumes/$DISKNAME/seafile-ignore.txt +# 特殊定制 +*.mp4 + +# 自定义的后缀名,凡有 sfignore 后缀的都不进行同步 +*.sfignore +*.sfignore/ +*.sfignore.* +*.sfignore.*/ +*.sfomit +*.sfomit.* +*.sfomit/ +*.sfomit.*/ +*.nosf +*.nosf.* +*.nosf/ +*.nosf.*/ + +## everything 'git pull or fetch' will update `.git/FETCH_HEAD`, even if the content doesn't change. To avoid too many useless updates of this file in Seafile history: +FETCH_HEAD +*/FETCH_HEAD + +.Trash/ +.Trashes/ + +.DS_Store +*/.DS_Store +*.aae # AAE 文件主要在苹果的照片应用程序中使用,保存对原始照片所做的编辑,比如,裁剪、旋转或调整亮度等操作的信息。 + +.thumbnails +*/.thumbnails + +Thumbs.db +*/Thumbs.db +thumbs.db +*/thumbs.db + +_desktop.ini +*/_desktop.ini + +._* +*/._* + +.$* +*/.$* + +~$* +*/~$* + +node_modules/ +*/node_modules/ +package-lock.json +*/package-lock.json + +pages4loader.json5 +*/pages4loader.json5 + +.deploy_git/ +*/.deploy_git/ + +# next.js 项目 +.next/ +*/.next/ + +# HBuilder 目录 +unpackage/ +*/unpackage/ + +Icon +OneDrive/Icon + +# wrangler project + +.dev.vars* +*/.dev.vars* +.wrangler/ +*/.wrangler/ +EOF + # 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. diff --git a/mac-disable-msoffice-autoupdate.sh b/mac-disable-msoffice-autoupdate.sh index 430aeb4..96b9585 100644 --- a/mac-disable-msoffice-autoupdate.sh +++ b/mac-disable-msoffice-autoupdate.sh @@ -1,4 +1,4 @@ cd /Library/Application\ Support/Microsoft/MAU2.0 # sudo chmod 000 Microsoft\ AutoUpdate.app -sudo mv Microsoft\ AutoUpdate.app MicrosoftAutoupdateDisabled.app \ No newline at end of file +sudo mv Microsoft\ AutoUpdate.app Microsoft\ Autoupdate.disabled.app \ No newline at end of file diff --git a/myip.sh b/myip.sh index 66a74fb..94f295c 100755 --- a/myip.sh +++ b/myip.sh @@ -6,3 +6,5 @@ fi echo Public IP: `curl -s ifconfig.me` echo + +curl ipinfo.io \ No newline at end of file diff --git a/nixhome-config.sh b/nixhome-config.sh index 0fbebb5..c4f1dac 100755 --- a/nixhome-config.sh +++ b/nixhome-config.sh @@ -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/open/sysconfig/raw/branch/main/nixhome/$homescript" + curl -sSLO "https://git.tic.cc/opx/sysconfig/raw/branch/main/nixhome/$homescript" fi done diff --git a/nixhome/.bashrc b/nixhome/.bashrc index 8de9c0f..2e0882a 100644 --- a/nixhome/.bashrc +++ b/nixhome/.bashrc @@ -156,9 +156,9 @@ elif [ -f /etc/ubuntu_version ]; then MYOSVERSION=Ubt`cat /etc/ubuntu_version 2>/dev/null` fi if [ "$color_prompt" = yes ]; then - 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 ' + 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\n### ' else - PS1='<\t#\u@\h=$MYIPPUB^$(uname -m),$(uname),$MYOSVERSION:\w>$IN_SSH$AS_ROOT ' # \w shows absolute path, \W shows current folder. + PS1='<\t#\u@\h=$MYIPPUB^$(uname -m),$(uname),$MYOSVERSION:\w>$IN_SSH$AS_ROOT\n### ' # \w shows absolute path, \W shows current folder. fi unset color_prompt force_color_prompt diff --git a/nixhome/seafile-ignore.global.txt b/nixhome/seafile-ignore.global.txt index 25b55a0..c7c0ec5 100644 --- a/nixhome/seafile-ignore.global.txt +++ b/nixhome/seafile-ignore.global.txt @@ -27,6 +27,7 @@ FETCH_HEAD */FETCH_HEAD .Trash/ +.Trashes/ .DS_Store */.DS_Store diff --git a/photo_rename_folders.sh b/photo_rename_folders.sh index 85dd450..c1e7a1c 100644 --- a/photo_rename_folders.sh +++ b/photo_rename_folders.sh @@ -7,8 +7,8 @@ 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; + base_dir=$(realpath "$base_dir") + echo Searching in "$base_dir"; else echo not a folder! exit 0 @@ -18,41 +18,43 @@ fi; read -p "Please enter [prod] to rename, or [anything else] to dry run: " user_input # 遍历所有目录 -for dir in "$base_dir"/*/; do +find "$base_dir" -type d | while read -r fullpath; do # 提取目录名称,去掉末尾的斜杠 - dir_name=$(basename "$dir") + dir_name=$(dirname "$fullpath") + folder_name=$(basename "$fullpath") # 调试输出:检查目录名称 - echo "Processing: $dir_name" + #echo "Processing: $folder_name" # 使用正则表达式提取前缀(可选)、年份、月份和日期 - if [[ $dir_name =~ ^([^,]*),?\ ([0-9]{4})年([0-9]{1,2})月([0-9]{1,2})日$ ]]; then + if [[ $folder_name =~ ^([^,]*),?\ ([0-9]{4})年([0-9]{1,2})月([0-9]{1,2})日$ ]]; then # 有前缀的情况 - prefix="${BASH_REMATCH[1]}" + intro="${BASH_REMATCH[1]}" year="${BASH_REMATCH[2]}" - month=$(printf "%02d" "${BASH_REMATCH[3]}") - day=$(printf "%02d" "${BASH_REMATCH[4]}") + month=$(printf "%02d\n" "$((10#${BASH_REMATCH[3]}))") + day=$(printf "%02d\n" "$((10#${BASH_REMATCH[4]}))") - elif [[ $dir_name =~ ^([0-9]{4})年([0-9]{1,2})月([0-9]{1,2})日$ ]]; then + elif [[ $folder_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]}") - + month=$(printf "%02d\n" "$((10#${BASH_REMATCH[2]}))") + day=$(printf "%02d\n" "$((10#${BASH_REMATCH[3]}))") + intro="${BASH_REMATCH[4]}" + else - echo "Skipping: $dir_name (not matching expected format)" + echo "Skip: $folder_name" continue fi # 创建新的目录名称 new_name="${year}${month}${day}" - if [[ -n "$prefix" ]]; then - new_name="${new_name}_${prefix// /_}" # 替换空格为下划线 + if [[ -n "$intro" ]]; then + new_name="${new_name}_${intro// /_}" # 替换空格为下划线 fi # 重命名目录 - if [[ "$user_input" == "prod" ]]; then mv "$dir" "$base_dir/$new_name"; fi; - echo "Renamed: $dir_name -> $new_name" + if [[ "$user_input" == "prod" ]]; then mv "$fullpath" "$dir_name/$new_name"; fi; + echo "Renamed: $folder_name" + echo " >>>> $dir_name/$new_name" done \ No newline at end of file diff --git a/photo_rename_images.sh b/photo_rename_images.sh index 4a8e0c2..b5c90ff 100644 --- a/photo_rename_images.sh +++ b/photo_rename_images.sh @@ -7,9 +7,9 @@ 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); + echo Searching in $(realpath "$target_directory"); else - echo $target_directory is not a folder! + echo "$target_directory" is not a folder! exit 0 fi; @@ -18,10 +18,10 @@ read -p "Please enter [prod] to rename, or [anything else] to dry run: " user_in # 查找并遍历所有文件 -find "$target_directory" -type f | while read -r file; do +find "$target_directory" -type f | while read -r fullpath; do # 获取文件的原名和扩展名 - dir_name=$(dirname "$file") - base_name=$(basename "$file") + dir_name=$(dirname "$fullpath") + base_name=$(basename "$fullpath") extension="${base_name##*.}" if [[ "$extension" = "7z" ]] || [[ "$extension" = "DS_Store" ]] || [[ "$extension" = "aae" ]] || [[ "$base_name" == *"unkn#own"* ]]; then @@ -35,7 +35,7 @@ find "$target_directory" -type f | while read -r file; do # 如果重命名后的文件名与原文件名不同,则进行重命名 if [[ "$base_name" != "$new_name" ]]; then - if [[ "$user_input" == "prod" ]]; then mv "$file" "$dir_name/$new_name"; fi; + if [[ "$user_input" == "prod" ]]; then mv "$fullpath" "$dir_name/$new_name"; fi; echo "$base_name -> $new_name" fi @@ -45,7 +45,7 @@ find "$target_directory" -type f | while read -r file; do # 获取文件的拍摄日期,假设日期以EXIF元数据存储 # 需要安装 exiftool - date_taken=$(exiftool -ExtractEmbedded -d "%Y%m%d#%H%M%S" -DateTimeOriginal -CreationDate -s -s -s "$file") + date_taken=$(exiftool -ExtractEmbedded -d "%Y%m%d#%H%M%S" -DateTimeOriginal -CreationDate -s -s -s "$fullpath") # 检查日期是否为空和文件名格式 if [ -n "$date_taken" ]; then @@ -53,13 +53,13 @@ find "$target_directory" -type f | while read -r file; do new_name="${date_taken}_${base_name}" # 重命名文件 - if [[ "$user_input" == "prod" ]]; then mv "$file" "$dir_name/$new_name"; fi; + if [[ "$user_input" == "prod" ]]; then mv "$fullpath" "$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; + if [[ "$user_input" == "prod" ]]; then mv "$fullpath" "$dir_name/$new_name"; fi; echo "$base_name -> $new_name" fi diff --git a/seafile-ignore-find2merge.bat b/seafile-ignore-find2merge.bat index e9a3280..05ce86f 100644 --- a/seafile-ignore-find2merge.bat +++ b/seafile-ignore-find2merge.bat @@ -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/open/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/opx/sysconfig/raw/branch/main/nixhome/seafile-ignore.global.txt]] set /p IGNOREPATH=">>> " echo; if "" == "%IGNOREPATH%" ( - set IGNOREPATH=https://git.tic.cc/open/sysconfig/raw/branch/main/nixhome/seafile-ignore.global.txt + set IGNOREPATH=https://git.tic.cc/opx/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%" ( diff --git a/seafile-ignore-find2merge.sh b/seafile-ignore-find2merge.sh index 3dd18e0..fbb8da8 100755 --- a/seafile-ignore-find2merge.sh +++ b/seafile-ignore-find2merge.sh @@ -12,7 +12,7 @@ else read -p "***:: " ROOTPATH if [ "$ROOTPATH" ] then - ROOTPATH=$(realpath $ROOTPATH) + ROOTPATH=$(realpath "${ROOTPATH/#\~/$HOME}") else ROOTPATH=`pwd` fi @@ -26,32 +26,30 @@ else fi echo "" -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]]" +echo "::*** Enter [path to seafile-ignore.global.txt] or [leave blank] for default [[https://git.tic.cc/opx/sysconfig/raw/branch/main/nixhome/seafile-ignore.global.txt]]" read -p "***:: " GLOBALPATH if [ "$GLOBALPATH" ] then + GLOBALPATH=$(realpath "${GLOBALPATH/#\~/$HOME}") + echo $GLOBALPATH if [ -d "$GLOBALPATH" ] then - GLOBALPATH=$(realpath $GLOBALPATH)/seafile-ignore.global.txt + GLOBALPATH="$GLOBALPATH/seafile-ignore.global.txt" fi - if [ ! -f "$GLOBALPATH" ] + if [ -f "$GLOBALPATH" ] then + echo "√√√ GLOBALPATH = [[$GLOBALPATH]]" + else echo "××× Not found [[$GLOBALPATH]]. Exit now..." exit - else - echo "√√√ GLOBALPATH = [[$GLOBALPATH]]" fi else - GLOBALPATH=https://git.tic.cc/open/sysconfig/raw/branch/main/nixhome/seafile-ignore.global.txt + GLOBALPATH=https://git.tic.cc/opx/sysconfig/raw/branch/main/nixhome/seafile-ignore.global.txt fi echo "" -echo "::*** Enter [y] to start updating, or [anything else] to quit" +echo "::*** Enter [y] to start updating, or [anything else] for dry-run" read -p "***:: " YESNO -if [ "$YESNO" != 'y' ] -then - exit -fi cd $ROOTPATH echo "*** Starting from [[`pwd`]] ***" @@ -62,13 +60,19 @@ do if [ -f "$repo/seafile-ignore.txt" ] || [ -d "$repo/.git" ] then echo "---- updating [[$repo/seafile-ignore.txt]] ----" - if [ -f "$GLOBALPATH" ] + if [ "$YESNO" = 'y' ] then - cat $GLOBALPATH > $repo/seafile-ignore.txt - else - curl -sSL $GLOBALPATH | cat > $repo/seafile-ignore.txt + if [ -f "$GLOBALPATH" ] + then + cat $GLOBALPATH > $repo/seafile-ignore.txt + else + curl -sSL $GLOBALPATH | cat > $repo/seafile-ignore.txt + fi + if [ -f "$repo/seafile-ignore.local.txt" ] + then + cat $repo/seafile-ignore.local.txt 2>/dev/null >> $repo/seafile-ignore.txt + fi fi - cat $repo/seafile-ignore.local.txt 2>/dev/null >> $repo/seafile-ignore.txt echo "" fi done diff --git a/seafile-ignore-merge-here.sh b/seafile-ignore-merge-here.sh deleted file mode 100755 index 37c43f6..0000000 --- a/seafile-ignore-merge-here.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/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/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 diff --git a/seafile-ignore.txt b/seafile-ignore.txt index d0a7486..c7c0ec5 100644 --- a/seafile-ignore.txt +++ b/seafile-ignore.txt @@ -27,9 +27,11 @@ FETCH_HEAD */FETCH_HEAD .Trash/ +.Trashes/ .DS_Store */.DS_Store +*.aae # AAE 文件主要在苹果的照片应用程序中使用,保存对原始照片所做的编辑,比如,裁剪、旋转或调整亮度等操作的信息。 .thumbnails */.thumbnails