From ab001c8d5f1eee8798632e4d90d167e94b1219a9 Mon Sep 17 00:00:00 2001 From: Luk Lu Date: Tue, 26 Sep 2023 11:29:29 +0800 Subject: [PATCH] u --- rclone-starter.sh | 31 +++++++++++++++---------- run-files-recursively.sh | 48 +++++++++++++++++++++++++++++++++++++++ seafile-cli-install.sh | 2 +- seafile-server-install.sh | 19 +++++++++++----- seafile-server-run.sh | 3 --- 5 files changed, 81 insertions(+), 22 deletions(-) create mode 100644 run-files-recursively.sh delete mode 100755 seafile-server-run.sh diff --git a/rclone-starter.sh b/rclone-starter.sh index f0e10e2..12f4220 100644 --- a/rclone-starter.sh +++ b/rclone-starter.sh @@ -1,28 +1,35 @@ #!/bin/bash -echo "=== rclone to install, to sync, to web gui" +echo "=== rclone to install, to sync, to copy, to web gui" read -p ">>> " ACTION_TYPE if [ "$ACTION_TYPE" = 'i' ] then sudo -v ; curl https://rclone.org/install.sh | sudo bash -elif [ "$ACTION_TYPE" = 's' ] +elif [[ "$ACTION_TYPE" = 's' || "$ACTION_TYPE" = 'c' ]] then - echo "rclone sync from source:" - read -p ">>> " SOURCE_PATH - echo "rclone sync to target:" - read -p ">>> " TARGET_PATH - echo "rclone sync with max-age:" - read -p ">>> " MAX_AGE - + if [ "$ACTION_TYPE" = 's' ] + then + RC_CMD='sync' + elif [ ] + 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 "*****************************" - echo "rclone sync $SOURCE_PATH $TARGET_PATH -P -L --create-empty-src-dirs --max-age=$MAX_AGE --exclude=._* --exclude=.DS_Store --exclude=node_modules" + 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 "*****************************" - echo "Start cloning? for yes, for quit" + echo "Starting? for yes, for quit" read -p ">>> " YES_OR_NOT if [ "$YES_OR_NOT" = 'y' ] then - rclone sync $SOURCE_PATH $TARGET_PATH -P -L --create-empty-src-dirs --max-age=$MAX_AGE --exclude=._* --exclude=.DS_Store --exclude={node_modules/,.deploy_git/,unpackage/} + 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} + echo "****************** [rclone $RC_CMD] Start: `date -u -Iseconds` *****************" fi elif [ "ACTION_TYPE" = 'w' ] then diff --git a/run-files-recursively.sh b/run-files-recursively.sh new file mode 100644 index 0000000..b8356d8 --- /dev/null +++ b/run-files-recursively.sh @@ -0,0 +1,48 @@ +echo "***************************************" +echo "find \$FOLDER -mindepth \$MINDEPTH -maxdepth \$MAXDEPTH -type d_f_l -name \"\$PATTERN\" | while read item; do echo \"\$item\"; done" +echo "***************************************" + +echo "To find in which path? Enter or for the current path:" +read -p ">>> " FIND_FOLDER +if [ ! "$FIND_FOLDER" ] +then + FIND_FOLDER="." +fi + +read -p "mindepth >>> " MINDEPTH +if [ "$MINDEPTH" ] +then + MINDEPTH_CLAUSE="-mindepth $MINDEPTH" +fi +read -p "maxdepth >>> " MAXDEPTH +if [ "$MAXDEPTH" ] +then + MAXDEPTH_CLAUSE="-mindepth $MAXDEPTH" +fi + +echo "To find file or directory? for file, for directory, for link, for all:" +read -p ">>> " FIND_TYPE +if [ "$FIND_TYPE" ] +then + FIND_TYPE_CLAUSE="-type $FIND_TYPE" +fi + +echo "To match pattern: (e.g. '._*', '.*.js') or or for all:" +read -p ">>> " FIND_PATTERN +if [ ! "$FIND_PATTERN" ] +then + FIND_PATTERN="*" +fi + +echo "To do something on each: or for 'echo':" +read -p ">>> " FIND_ACTION +if [ ! "$FIND_ACTION" ] +then + FIND_ACTION='echo' +fi + +echo "***************************************" +echo "find $FIND_FOLDER $MINDEPTH_CLAUSE $MAXDEPTH_CLAUSE $FIND_TYPE_CLAUSE -name \"$FIND_PATTERN\" | while read item; do $FIND_ACTION \"\$item\"; done" +echo "***************************************" + +find $FIND_FOLDER $MINDEPTH_CLAUSE $MAXDEPTH_CLAUSE $FIND_TYPE_CLAUSE -name "$FIND_PATTERN" | while read item; do $FIND_ACTION "$item"; done \ No newline at end of file diff --git a/seafile-cli-install.sh b/seafile-cli-install.sh index 2f0a926..8b7bab6 100755 --- a/seafile-cli-install.sh +++ b/seafile-cli-install.sh @@ -12,7 +12,7 @@ mkdir $SETTINGS_FOLDER seaf-cli init -d $SETTINGS_FOLDER seaf-cli start -echo To sync a librarcy, run commands like: +echo To sync a library, run commands like: echo Download a new folder to sync with: echo seaf-cli download -l "library_id" -s "server_url" [-d "parent_folder"] -u "user_name" echo seaf-cli download-by-name -L "library_id" -s "server_url" [-d "target_folder_not_parent"] -u "user_name" diff --git a/seafile-server-install.sh b/seafile-server-install.sh index c125928..e635cd0 100755 --- a/seafile-server-install.sh +++ b/seafile-server-install.sh @@ -9,19 +9,26 @@ sudo apt-get install python3 python3-setuptools python3-pip python3-ldap sqlite3 ## for seafile 9.*: # sudo pip3 install --timeout=3600 django==3.2.* future Pillow pylibmc captcha jinja2 sqlalchemy==1.4.3 psd-tools django-pylibmc django-simple-captcha pycryptodome==3.12.0 -echo "=== Enter to install, or for default 9.0.10:" +echo "=== Enter to install, or for default 10.0.1:" read -p ">>> " SFVERSION if [ ! "$SFVERSION" ] then - SFVERSION="9.0.10" + SFVERSION="10.0.1" fi +echo "=== Enter for seafile installation, or for default to `pwd`:" +read -p ">>> " INSTALL_PATH +if [ ! "$INSTALL_PATH" ] +then + INSTALL_PATH=`pwd` +fi + +sudo mkdir -p "$INSTALL_PATH" +pushd "$INSTALL_PATH" -pushd /faronear -sudo mkdir bin-seafile cd bin-seafile -sudo wget https://seafile-downloads.oss-cn-shanghai.aliyuncs.com/seafile-server_$SFVERSION_x86-64.tar.gz -sudo tar -xzf seafile-server_$SFVERSION_x86-64.tar.gz +sudo wget https://seafile-downloads.oss-cn-shanghai.aliyuncs.com/seafile-server_${SFVERSION}_x86-64.tar.gz +sudo tar -xzf seafile-server_${SFVERSION}_x86-64.tar.gz ln -s seafile-server-$SFVERSION sea cd sea sudo ./setup-seafile.sh # to setup seafile+sqlite (setup-seafile-mysql.sh is for mysql). this will create ccnet,conf,seafile-data,seahub-data,seahub.db inside the parent folder /faronear/bin-seafile diff --git a/seafile-server-run.sh b/seafile-server-run.sh deleted file mode 100755 index 7223f07..0000000 --- a/seafile-server-run.sh +++ /dev/null @@ -1,3 +0,0 @@ -cd /faronear/bin.seafile/sea -sudo ./seafile.sh start -sudo ./seahub.sh start