From dd3c8ab167373aef9740244cd11b763be04788eb Mon Sep 17 00:00:00 2001 From: Luk Lu Date: Sun, 5 Mar 2023 15:23:46 +0800 Subject: [PATCH] =?UTF-8?q?git=E6=9C=8D=E5=8A=A1=E5=99=A8=E8=BF=81?= =?UTF-8?q?=E7=A7=BB=E5=88=B0=E7=BE=8E=E5=9B=BD=E5=87=A4=E5=87=B0=E5=9F=8E?= =?UTF-8?q?=E5=90=8E=E7=AC=AC=E4=B8=80=E6=AC=A1=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- debian-ddinstall-debi.sh | 4 ++-- git-repo-change-hook-path.sh | 28 ++++++++++++++++++++-------- home-config.sh | 2 +- nixhome/.bashrc | 16 +++++++++------- nixhome/.npmrc_taobao | 7 +++++++ nvm-install.sh | 27 ++++++++++++++++----------- proxy-off.bat | 2 -- proxy-on.bat | 7 ------- proxy.bat | 30 ++++++++++++++++++++++++++++++ proxy.sh | 16 ++++++++++------ remote-sync.sh => rsync-folder.sh | 0 ssr-install.sh | 18 ++++++++++++++++++ 12 files changed, 113 insertions(+), 44 deletions(-) create mode 100644 nixhome/.npmrc_taobao delete mode 100644 proxy-off.bat delete mode 100644 proxy-on.bat create mode 100644 proxy.bat rename remote-sync.sh => rsync-folder.sh (100%) mode change 100755 => 100644 diff --git a/debian-ddinstall-debi.sh b/debian-ddinstall-debi.sh index a1e5d8e..aea8c37 100644 --- a/debian-ddinstall-debi.sh +++ b/debian-ddinstall-debi.sh @@ -3,7 +3,7 @@ echo "Thanks https://github.com/bohanyang/debi" echo -echo "=== Enter debian version [8,9,10,11,12] or [leave blank] for 11" +echo "=== Enter debian version [8,9,10,11] or [leave blank] for 11" read -p ">>> " DEBIAN_VERSION if [ -z "${DEBIAN_VERSION}" ] then @@ -28,5 +28,5 @@ sudo curl -fLO https://raw.githubusercontent.com/bohanyang/debi/master/debi.sh sudo chmod a+rx debi.sh sudo ./debi.sh --version $DEBIAN_VERSION --architecture $DEBIAN_ARCH --user root --$PRESET # --architecture 可参略,默认为 amd64;--password 可省略,则脚本启动后会问你要密码 -echo "=== Shutdown now, wait for about 30 seconds, then try to ssh" +echo "=== Shutdown now, wait for about 30 minutes (the project's github says 30 seconds), then try to ssh" sudo shutdown -r now diff --git a/git-repo-change-hook-path.sh b/git-repo-change-hook-path.sh index 6415195..43b119d 100755 --- a/git-repo-change-hook-path.sh +++ b/git-repo-change-hook-path.sh @@ -1,14 +1,26 @@ #!/bin/bash -echo "in [RepoRoot]/*/*/hooks/[pre|update|post]-receive.d/*, path is hard-coded in full such as `/faronear/git/gitea/custom/conf/app.ini`, you need to replace it if the path is changed." -read -p "Enter old hook path: >> " OLDPATH -read -p "Enter new hook path: >> " NEWPATH +echo "in [REPOROOT]/*/*/hooks/[pre-receive.d|post-receive.d|update.d]/gitea, path is hard-coded in full such as `/faronear/git/gitea/gitea hook --config=/faronear/git/gitea/custom/conf/app.ini`, you need to replace it if the path is changed." +echo "[20230305] noticed that gitea 1.18.5 default is `/usr/local/bin/gitea hook --config=/data/gitea/conf/app.ini`" + +echo "Enter or for default '/faronear/git/gitea/gitea':" +read -p ">>> " OLDPATH +if [ ! "$OLDPATH"] +then + OLDPATH=/faronear/git/gitea/gitea +fi + +echo "Enter or for default '/usr/local/bin/gitea': " +read -p ">> " NEWPATH +if [ ! "$NEWPATH" ] +then + NEWPATH=/usr/local/bin/gitea +fi + read -p "Enter repository root path: >> " REPOROOT -sed -i "s:$OLDPATH:$NEWPATH:g" `grep "$OLDPATH" -rl $REPOROOT/*/*/hooks/` +# 用 : 来取代 /,以避免大量出现 \/ +# sed -i "s/\/home\/fon\//\/root\//g" `grep '/home/fon' -rl git.repo/*/*/hooks/*.d/gitea` +sed -i "s:$OLDPATH:$NEWPATH:g" `grep "$OLDPATH" -rl $REPOROOT/*/*/hooks/*.d/gitea` echo "Completed replacing $OLDPATH to $NEWPATH recursively in folder $REPOROOT" - -# 参数 -i 代表在文件里直接替换。但发现在 MacOS 里这会报错,在 Debian 里没问题。 -# 可以用 : 来取代 /,以避免大量出现 \/ -# sed -i "s/\/home\/fon\//\/root\//g" `grep '/home/fon' -rl git.repo/*/*/hooks` diff --git a/home-config.sh b/home-config.sh index 4bbd616..a153ed1 100755 --- a/home-config.sh +++ b/home-config.sh @@ -107,7 +107,7 @@ then mv $HomePath/.ssh/authorized_keys $HomePath/.ssh/authorized_keys.backup-$(date +%Y%m%dT%H%M%S) fi - echo "=== Append or link or omit [$HomePath/.ssh/authorized_keys] to config ssh server? for append, for link, <> for omit:" + echo "=== Append or link or omit [$HomePath/.ssh/authorized_keys] to config ssh server? for append, for link, for omit:" read -p ">>> " CopyOrLinkOrOmitAuthorizedKeys if [ "$CopyOrLinkOrOmitAuthorizedKeys" = 'l' ] diff --git a/nixhome/.bashrc b/nixhome/.bashrc index bb56a0a..ca28ade 100644 --- a/nixhome/.bashrc +++ b/nixhome/.bashrc @@ -51,16 +51,17 @@ alias emacst='emacs -nw' alias myip='ifconfig | grep netmask' -# Always list long directory and time. +# Set aliases +alias grep='grep --color=auto' +alias fgrep='fgrep --color=auto' +alias egrep='egrep --color=auto' +alias su='su -' if [[ "$(uname)" = "Darwin" ]]; then alias l='ls -lG' alias ll='ls -lGA' # show .xxx alias dir='ls -lGA' alias lll='ls -lGa' # show .xxx and . and .. - alias grep='grep --color=auto' - alias fgrep='fgrep --color=auto' - alias egrep='egrep --color=auto' alias sedi='sed -i ""' export HOMEBREW_NO_AUTO_UPDATE=true export BASH_SILENCE_DEPRECATION_WARNING=1 @@ -69,9 +70,6 @@ else alias ll='ls -lA --color=auto' alias dir='ls -lA --color=auto' alias lll='ls -la --color=auto' - alias grep='grep --color=auto' - alias fgrep='fgrep --color=auto' - alias egrep='egrep --color=auto' alias sedi='sed -i' export TIME_STYLE='+%Y-%m-%d--%H:%M:%S' fi @@ -165,6 +163,7 @@ tp3=/faronear/fon/sysconfig tp4=/faronear/fon.git/sysconfig tp5=/mnt/c/faronear/fon.git/sysconfig tp6=/mnt/d/faronear/fon.git/sysconfig +tp7=/faronear/sysconfig if [ -d $tp1 ] then export PATH=$tp1:$PATH @@ -183,6 +182,9 @@ then elif [ -d $tp6 ] then export PATH=$tp6:$PATH +elif [ -d $tp7 ] +then + export PATH=$tp7:$PATH fi if [ -f ~/.bashrc_custom ] diff --git a/nixhome/.npmrc_taobao b/nixhome/.npmrc_taobao new file mode 100644 index 0000000..d93e496 --- /dev/null +++ b/nixhome/.npmrc_taobao @@ -0,0 +1,7 @@ +registry=https://registry.npm.taobao.org + +## npm config set registry https://registry.npm.taobao.org +## npm config set registry https://registry.npmjs.org +## npm config get registry +## npm config ls -l +## npm --registry registry https://registry.npm.taobao.org ... \ No newline at end of file diff --git a/nvm-install.sh b/nvm-install.sh index 673e49a..d50f839 100755 --- a/nvm-install.sh +++ b/nvm-install.sh @@ -1,17 +1,22 @@ +## 注意,这个安装脚本先会查看 NVM_DIR。如果是从其他用户 `su` 过来的,继承了这个变量 NVM_DIR=/home/原用户/.nvm,导致无法安装在当前 root 用户下。 +## 因此要么 `su -` 要么不使用安装脚本,而是直接执行脚本里的真正安装动作,即 git clone # curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash -# pushd /faronear/fon/sysconfig -# # 取消被默认添加到 .bashrc 的设置,already integrated in .bashrc + +## Add these lines to your launch script such as .bashrc : +## '########################################################################' +## 'export NVM_DIR="$HOME/.nvm"' +## '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' +## '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"' +## '########################################################################' + +## 取消被默认添加到 .bashrc 的设置(already integrated in nixhome/.bashrc) +# pushd /faronear/sysconfig # git reset . && git checkout . # popd -# 注意,这个安装脚本先会查看 NVM_DIR。如果是从其他用户 `su` 过来的,继承了这个变量 NVM_DIR=/home/原用户/.nvm,导致无法安装在当前 root 用户下。 -# 因此要么 `su -` 要么不使用安装脚本,而是直接执行脚本里的真正安装动作,即 git clone - git clone https://github.com/nvm-sh/nvm.git ~/.nvm -echo Add these lines to your launch script such as .bashrc : -echo '########################################################################' -echo 'export NVM_DIR="$HOME/.nvm"' -echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' -echo '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"' -echo '########################################################################' +echo If in China, set mirror before nvm install +echo ######################################################################## +echo export NVM_NODEJS_ORG_MIRROR=https://npm.taobao.org/mirrors/node +echo ######################################################################## diff --git a/proxy-off.bat b/proxy-off.bat deleted file mode 100644 index 90e3e1e..0000000 --- a/proxy-off.bat +++ /dev/null @@ -1,2 +0,0 @@ -set http_proxy= -set https_proxy= diff --git a/proxy-on.bat b/proxy-on.bat deleted file mode 100644 index 6037637..0000000 --- a/proxy-on.bat +++ /dev/null @@ -1,7 +0,0 @@ -set HTTP_PROXY=http://127.0.0.1:41091 -@REM set HTTP_PROXY_USER=username -@REM set HTTP_PROXY_PASS=password - -set HTTPS_PROXY=http://127.0.0.1:41091 -@REM set HTTPS_PROXY_USER=username -@REM set HTTPS_PROXY_PASS=password \ No newline at end of file diff --git a/proxy.bat b/proxy.bat new file mode 100644 index 0000000..4721c1a --- /dev/null +++ b/proxy.bat @@ -0,0 +1,30 @@ +@REM 在 powershell 里,只要 ssr 打开全局模式,不需要设置 proxy 就可以。 +@REM 在 cmd 里,需要设置 proxy 才可以。 + +echo === Enter [s] to start, [t] to terminate or [anything else] for no change +set /p TODOMODE=">>> " +echo; +if "s" == "%TODOMODE%" ( + set ALL_PROXY=socks5://127.0.0.1:1080 + echo "--- 已开启网络代理" +) else if "t" == "%TODOMODE%" ( + set all_proxy= + set http_proxy= + set https_proxy= + echo "--- 已关闭网络代理" +) else ( + echo No change. +) + +@REM 测试 ip.gs, ip.sb, ipinfo.io +curl ipinfo.io + + +@REM set HTTP_PROXY=socks5://127.0.0.1:1080 +@REM set HTTP_PROXY_USER=username +@REM set HTTP_PROXY_PASS=password + +@REM set HTTPS_PROXY=socks5://127.0.0.1:1080 +@REM set HTTPS_PROXY_USER=username +@REM set HTTPS_PROXY_PASS=password + diff --git a/proxy.sh b/proxy.sh index 6010469..24c7995 100755 --- a/proxy.sh +++ b/proxy.sh @@ -1,15 +1,15 @@ #!/bin/bash function proxy(){ - echo "=== 开启或关闭网络代理? u for up, d for down, anything else for no change." + echo "=== 开启或关闭网络代理? s for start, t for terminate, anything else for no change." read -p ">>> " proxySwitch - if [ $proxySwitch ] && [ $proxySwitch == "u" ] + if [ $proxySwitch ] && [ $proxySwitch == "s" ] then - export ALL_PROXY=socks5://127.0.0.1:1090 - export http_proxy=http://127.0.0.1:41091 - export https_proxy=https://127.0.0.1:41091 + export ALL_PROXY=socks5://127.0.0.1:1086 + export http_proxy=http://127.0.0.1:8090 + export https_proxy=https://127.0.0.1:8090 echo -e "--- 已开启网络代理" - elif [ $proxySwitch ] && [ $proxySwitch == "d" ] + elif [ $proxySwitch ] && [ $proxySwitch == "t" ] then unset ALL_PROXY unset http_proxy @@ -18,5 +18,9 @@ function proxy(){ else echo "--- Nothing changed." fi + + echo 测试 ip.gs, ip.sb, ipinfo.io + curl ipinfo.io + } proxy diff --git a/remote-sync.sh b/rsync-folder.sh old mode 100755 new mode 100644 similarity index 100% rename from remote-sync.sh rename to rsync-folder.sh diff --git a/ssr-install.sh b/ssr-install.sh index a1641bc..9de34f7 100755 --- a/ssr-install.sh +++ b/ssr-install.sh @@ -9,6 +9,24 @@ unzip ssr.zip cd SSR* bash install.sh +# if [ "$1" ] +# then +# KEYCODE=$1 +# else +# KEYCODE=44444 +# fi +# USERNAME=$KEYCODE +# PORT=$KEYCODE +# PASSWORD=$KEYCODE +# ENCRYPTION=5 +# PROTOCOL=4 +# OBFS=4 +# ORIGINAL_OBFS=n +# QUOTA=1000 +# SPEEDLIMIT=n +# echo -e "2\n1\n$USER\n$PORT\n$PASSWORD\$ENCRYPTION\n$PROTOCOL\n\$OBFS\n$ORIGINAL_OBFS\n$QUOTA\n$SPEEDLIMIT\n" | ssr +## 报错,不能这样调用 + # [2020-02-13] 以下标准安装脚本无法使用,因为里面调用 http:// 但是现已转为 https:// # wget https://www.gigsgigscloud.com/cn/downloads/ssr.sh --no-check-certificate # sudo bash ssr.sh