From c23af842fd662beb2bc6d6948616c9342af6acd0 Mon Sep 17 00:00:00 2001 From: Luk Date: Sat, 14 Sep 2024 12:13:01 +0800 Subject: [PATCH] u --- .gitignore | 109 +++++++++++++++++++++++++++++++++++++++ debian-add-user.sh | 2 +- mac-brew-default-apps.sh | 6 +-- npm-registry.sh | 24 +++++++++ proxy.sh | 3 ++ rclone-starter.sh | 45 +++++++++++++--- 6 files changed, 177 insertions(+), 12 deletions(-) create mode 100644 .gitignore create mode 100644 npm-registry.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..36e9cc0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,109 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. +# how to include another gitignore? +# https://stackoverflow.com/questions/7005142/can-i-include-other-gitignore-file-in-a-gitignore-file-like-include-in-c-li +# https://github.com/github/gitignore +# https://github.com/SlideWave/gitignore-include?tab=readme-ov-file#examples +# https://gitignore.io + +### .gitignore.global.txt ### + +# Self defined pattern to ignore +?*.gitignore +?*.gitignore/ +?*.gitignore.* +?*.gitignore.*/ +*.gitomit +*.gitomit/ +*.gitomit.* +*.gitomit.*/ +# 保留 +!.gitignore +!.gitignore.* +!.gitkeep + +# 通用 +.svn/ +.deploy_git/ +.idea/ +.sass-cache/ +.wrangler +/test/unit/coverage/ +/test/e2e/reports/ +node_modules/ +*.aab +*.apk +*.ipa +*.min.js +*.min.css +*.min.html +*.iml +*.njsproj +*.ntvs* +*.sw* +*.sln +*.suo +.gitattributes +.umi +.umi-production +npm-debug.log* +yarn-debug.log* +yarn-error.log* +yarn.lock +selenium-debug.log +Thumbs.db +thumbs.db +_desktop.ini + +# vue-cli 项目 +/dist/ + +# 来自 vue-cli 创建项目的 .gitignore +.project + +# hexo +/public/ + +# Hardhat +/artifacts/ +/cache/ + +# seafile 临时文件 +._* + +.$* + +# office 暂存文件 +~$* + +# 用户shell配置脚本 +.bashrc_custom + +# 苹果系统临时文件 +.DS_Store + +# 安卓缓存文件夹 +.thumbnails + +# local env files +.env.local +.env.*.local + +# hexo +/db.json + +# wo +# 服务端 +/_archive/* +/_datastore/* +/_filestore/* +/_logstore/* +/_webroot/* +/_ssl/* +# uniapp 客户端 +/unpackage/* +!/unpackage/res/ +package-lock.json +pages4loader.json5 + +### .gitignore.local.txt ### + diff --git a/debian-add-user.sh b/debian-add-user.sh index 20e32c3..643790e 100755 --- a/debian-add-user.sh +++ b/debian-add-user.sh @@ -24,7 +24,7 @@ sed -i "s|/home/$NewUser:$|/home/$NewUser:/bin/bash|g" /etc/passwd echo "=== Allow the new user [[$NewUser]] to sudo without password? [y] for yes, [anything else] for no" read -p ">>> " AllowSudo -if [ "$AllowSudo" == "y" ] +if [ "$AllowSudo" = "y" ] then #usermod -a -G sudo $NewUser # Add to sudo group # Option 1: add user to %sudo group echo "$NewUser ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers.d/${NewUser//./-} # Option 2: add a user file into /etc/sudoers.d/ diff --git a/mac-brew-default-apps.sh b/mac-brew-default-apps.sh index ef6392c..440a9ee 100644 --- a/mac-brew-default-apps.sh +++ b/mac-brew-default-apps.sh @@ -1,7 +1,7 @@ echo "=== Install formulaes and casks, enter [y] for Yes, [anything else] for No:" echo -formulaeList=(jq openssl pandoc speedtest-cli yt-dlp) +formulaeList=(jq openssl pandoc rclone speedtest-cli yt-dlp) for APP in "${formulaeList[@]}" do echo "--- brew install $APP" @@ -15,10 +15,10 @@ do echo done -caskList=(appcleaner avidemux baidunetdisk cloudflare-warp cursor douyin drawio emacs futubull iina iterm2 lx-music miniconda obs poe qq seafile-client shotcut spacelauncher sqlitestudio telegram-desktop telegram-lite termius thunder warp wechat) +caskList=(appcleaner avidemux baidunetdisk cloudflare-warp cursor discord douyin drawio emacs futubull iina iterm2 lx-music miniconda obs poe qq seafile-client shotcut spacelauncher sqlitestudio telegram-desktop telegram-lite termius thunder warp wechat) for APP in "${caskList[@]}" do - echo "--- brew install $APP" + echo "--- brew install $APP --cask" read -p ">>> " YN if [ "$YN" = 'y' ] then diff --git a/npm-registry.sh b/npm-registry.sh new file mode 100644 index 0000000..c9ef9bd --- /dev/null +++ b/npm-registry.sh @@ -0,0 +1,24 @@ +echo 1. npm config set registry https://registry.npmmirror.com +echo 2. 命令行指定: npm --registry https://registry.npmmirror.com info underscore +echo 3. edit ~/.npmrc: registry=https://registry.npmmirror.com +echo 4. 使用 nrm 管理 registry 地址: +echo npm install -g nrm +echo nrm add taobao https://registry.npmmirror.com +echo nrm use taobao +echo nrm ls +echo nrm current +echo + +echo "=== npm config get registry ==> $(npm config get registry)" +echo +echo "=== npm config set registry \n [c] China, \n [w] World, [anything else] to quit" +read -p ">>> " TARGET +if [ "$TARGET" = 'c' ] +then + npm config set registry https://registry.npmmirror.com +elif [ "$TARGET" = 'w' ] +then + npm config set registry https://registry.npmjs.org +fi +echo +echo "=== npm config get registry ==> $(npm config get registry)" \ No newline at end of file diff --git a/proxy.sh b/proxy.sh index d1c08e7..b9b9cbd 100755 --- a/proxy.sh +++ b/proxy.sh @@ -9,6 +9,9 @@ else read -p ">>> " proxySwitch fi +# to reset port to empty, otherwise the second run of this script will not ask for port. +PORT= + # function proxy() { if [ "$proxySwitch" == "s" ] || [ "$proxySwitch" == "1" ]; then echo "=== Proxy server running on [port number] or [leave blank] for default 7897" diff --git a/rclone-starter.sh b/rclone-starter.sh index 4c0e2e0..e872dae 100644 --- a/rclone-starter.sh +++ b/rclone-starter.sh @@ -1,6 +1,6 @@ #!/bin/bash -echo "=== rclone [i] to install, [s] to sync, [c] to copy, [w] to web gui" +echo "=== rclone [i] to install, [s] to sync, [c] to copy, [w] to web gui, [else] to quit" read -p ">>> " ACTION_TYPE if [ "$ACTION_TYPE" = 'i' ] then @@ -10,26 +10,55 @@ then if [ "$ACTION_TYPE" = 's' ] then RC_CMD='sync' - elif [ ] + elif [ "$ACTION_TYPE" = 'c' ] then RC_CMD='copy' fi - read -p "rclone $RC_CMD from source >>> " SOURCE_PATH - read -p "rclone $RC_CMD into target >>> " TARGET_PATH -# read -p "rclone $RC_CMD with max-age >>> " MAX_AGE ## 发现用了 max-age 并没有提升速度,反而略有下降,即使对大量现有文件和少量更新文件 - read -p "rclone $RC_CMD excluding (folders must end with /) >>> " EXCLUDING + echo + echo "=== from source (default ./)"; read -p ">>> " SOURCE_PATH; if [ ! "$SOURCE_PATH" ]; then SOURCE_PATH="./"; fi + + echo + while [ ! "$TARGET_PATH" ] + do + echo "=== to target [remote:path]" + read -p ">>> " TARGET_PATH + done + + # read -p "rclone $RC_CMD with max-age >>> " MAX_AGE ## 发现用了 max-age 并没有提升速度,反而略有下降,即使对大量现有文件和少量更新文件 + + echo + echo "excluding files and folders (folders must end with /)" + read -p ">>> " EXCLUDING; + + echo + echo "with [number] files in parallel, default 4" + read -p ">>> " TRANSFERS; + if [ ! "$TRANSFERS" ]; then TRANSFERS=4; fi + + + echo + echo "with [number] threads simultaneously, default 4"; + read -p ">>> " THREADS; + if [ ! "$THREADS" ]; then THREADS=4; fi + + FULL_CMD="rclone $RC_CMD $SOURCE_PATH $TARGET_PATH -P -L --transfers=$TRANSFERS --multi-thread-streams=$THREADS --create-empty-src-dirs --exclude=._* --exclude=.DS_Store --exclude={node_modules/,.deploy_git/,unpackage/,$EXCLUDING}" + echo echo "*****************************" - echo "rclone $RC_CMD $SOURCE_PATH $TARGET_PATH -P -L --create-empty-src-dirs --exclude=._* --exclude=.DS_Store --exclude={node_modules/,.deploy_git/,unpackage/,$EXCLUDING}" + echo $FULL_CMD echo "*****************************" + echo echo "Starting? [y] for yes, [anything else] for quit" read -p ">>> " YES_OR_NOT + echo if [ "$YES_OR_NOT" = 'y' ] then echo "****************** [rclone $RC_CMD] Start: `date -u -Iseconds` *****************" - rclone $RC_CMD $SOURCE_PATH $TARGET_PATH -P -L --create-empty-src-dirs --exclude=._* --exclude=.DS_Store --exclude={node_modules/,.deploy_git/,unpackage/,$EXCLUDING} + $FULL_CMD echo "****************** [rclone $RC_CMD] Start: `date -u -Iseconds` *****************" + echo + rclone ls $TARGET_PATH fi elif [ "ACTION_TYPE" = 'w' ] then