├── META-INF └── com │ └── google │ └── android │ ├── updater-script │ └── update-binary ├── common ├── binary │ ├── arm │ │ ├── fusermount │ │ ├── inotifywait │ │ └── rclone │ ├── x64 │ │ ├── fusermount │ │ ├── inotifywait │ │ └── rclone │ ├── x86 │ │ ├── fusermount │ │ ├── inotifywait │ │ └── rclone │ └── arm64 │ │ ├── fusermount │ │ ├── inotifywait │ │ └── rclone └── lib │ ├── arm │ └── libandroid-support.so │ ├── arm64 │ └── libandroid-support.so │ ├── x64 │ └── libandroid-support.so │ └── x86 │ └── libandroid-support.so ├── uninstall.sh ├── module.prop ├── .gitattributes ├── syncd.sh ├── customize.sh ├── CHANGELOG.md ├── system └── bin │ └── rclone ├── README.md └── service.sh /META-INF/com/google/android/updater-script: -------------------------------------------------------------------------------- 1 | #MAGISK 2 | -------------------------------------------------------------------------------- /common/binary/arm/fusermount: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rabbits-heart/rclone_RD-MagiskModule/HEAD/common/binary/arm/fusermount -------------------------------------------------------------------------------- /common/binary/x64/fusermount: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rabbits-heart/rclone_RD-MagiskModule/HEAD/common/binary/x64/fusermount -------------------------------------------------------------------------------- /common/binary/x86/fusermount: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rabbits-heart/rclone_RD-MagiskModule/HEAD/common/binary/x86/fusermount -------------------------------------------------------------------------------- /common/binary/arm/inotifywait: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rabbits-heart/rclone_RD-MagiskModule/HEAD/common/binary/arm/inotifywait -------------------------------------------------------------------------------- /common/binary/arm64/fusermount: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rabbits-heart/rclone_RD-MagiskModule/HEAD/common/binary/arm64/fusermount -------------------------------------------------------------------------------- /common/binary/x64/inotifywait: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rabbits-heart/rclone_RD-MagiskModule/HEAD/common/binary/x64/inotifywait -------------------------------------------------------------------------------- /common/binary/x86/inotifywait: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rabbits-heart/rclone_RD-MagiskModule/HEAD/common/binary/x86/inotifywait -------------------------------------------------------------------------------- /common/binary/arm64/inotifywait: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rabbits-heart/rclone_RD-MagiskModule/HEAD/common/binary/arm64/inotifywait -------------------------------------------------------------------------------- /common/lib/arm/libandroid-support.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rabbits-heart/rclone_RD-MagiskModule/HEAD/common/lib/arm/libandroid-support.so -------------------------------------------------------------------------------- /common/lib/arm64/libandroid-support.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rabbits-heart/rclone_RD-MagiskModule/HEAD/common/lib/arm64/libandroid-support.so -------------------------------------------------------------------------------- /common/lib/x64/libandroid-support.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rabbits-heart/rclone_RD-MagiskModule/HEAD/common/lib/x64/libandroid-support.so -------------------------------------------------------------------------------- /common/lib/x86/libandroid-support.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rabbits-heart/rclone_RD-MagiskModule/HEAD/common/lib/x86/libandroid-support.so -------------------------------------------------------------------------------- /common/binary/arm/rclone: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:ce562429dd94a8d4a5fea94109a8e8572695b48abaf72969de0917ab8599c216 3 | size 106099540 4 | -------------------------------------------------------------------------------- /common/binary/arm64/rclone: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c1494a601aed77665b060cdae75c35babc66eebec0d6c40bda06c20f3921d086 3 | size 125461480 4 | -------------------------------------------------------------------------------- /common/binary/x64/rclone: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c21768f7c6097959a496e1de77de9b4db7a6b1889ef688091a288906d969c3cb 3 | size 126004152 4 | -------------------------------------------------------------------------------- /common/binary/x86/rclone: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:bdaed22a43eb152683ac91231c771b2efb8da2b1d850f681bac08b20cda63529 3 | size 107689328 4 | -------------------------------------------------------------------------------- /uninstall.sh: -------------------------------------------------------------------------------- 1 | MODDIR=${0%/*} 2 | 3 | CONFIGFILE=/sdcard/Android/.rclone/rclone.conf 4 | CLOUDROOTMOUNTPOINT=/mnt/cloud/ 5 | 6 | "$MODDIR"/rclone listremotes --config ${CONFIGFILE}|cut -f1 -d: | 7 | while read -r line; do 8 | umount -f ${CLOUDROOTMOUNTPOINT}/"$line" 9 | sleep 1 10 | done 11 | 12 | rm -f ${CONFIGFILE:?} 13 | rm -rf ${CLOUDROOTMOUNTPOINT:?} 14 | -------------------------------------------------------------------------------- /module.prop: -------------------------------------------------------------------------------- 1 | id=rclone_RD-MagiskModule 2 | name=rclone_RD Magisk Module (forked from rclone-mount-magisk) 3 | version=rclone: (v1.60.1) mod: (v1.3.1) 4 | versionCode=117 5 | author=rabbits-heart (OG: Howard20181 and AvinashReddy3108 and piyushgarg) 6 | description=RealDebrid-compatible magisk module to mount and sync your cloud storage on your device using 'rclone' & 'fusermount', providing virtually limitless storage expansion with support for dozens of cloud providers and extensive customization options. 7 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set the default behavior, in case people don't have core.autocrlf set. 2 | * text=auto eol=lf 3 | # Declare files that will always have CRLF line endings on checkout. 4 | *.cmd text eol=crlf 5 | *.bat text eol=crlf 6 | # Denote all files that are truly binary and should not be modified. 7 | *.so binary 8 | *.dex binary 9 | *.jar binary 10 | *.png binary 11 | common/binary/** binary 12 | /common/binary/x86/rclone filter=lfs diff=lfs merge=lfs -text 13 | /common/binary/x64/rclone filter=lfs diff=lfs merge=lfs -text 14 | /common/binary/arm/rclone filter=lfs diff=lfs merge=lfs -text 15 | /common/binary/arm64/rclone filter=lfs diff=lfs merge=lfs -text 16 | -------------------------------------------------------------------------------- /META-INF/com/google/android/update-binary: -------------------------------------------------------------------------------- 1 | #!/sbin/sh 2 | 3 | ################# 4 | # Initialization 5 | ################# 6 | 7 | umask 022 8 | 9 | # echo before loading util_functions 10 | ui_print() { echo "$1"; } 11 | 12 | require_new_magisk() { 13 | ui_print "*******************************" 14 | ui_print " Please install Magisk v20.4+! " 15 | ui_print "*******************************" 16 | exit 1 17 | } 18 | 19 | ######################### 20 | # Load util_functions.sh 21 | ######################### 22 | 23 | OUTFD=$2 24 | ZIPFILE=$3 25 | 26 | mount /data 2>/dev/null 27 | 28 | [ -f /data/adb/magisk/util_functions.sh ] || require_new_magisk 29 | . /data/adb/magisk/util_functions.sh 30 | [ $MAGISK_VER_CODE -lt 20400 ] && require_new_magisk 31 | 32 | install_module 33 | exit 0 -------------------------------------------------------------------------------- /syncd.sh: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | 3 | MODDIR=${0%/*} 4 | TMPDIR=${MODDIR}/.tmp 5 | SYNC_PENDING=$TMPDIR/$remote.sync.pend 6 | 7 | dump_battery() { 8 | BATTERY_DUMP="$(dumpsys battery)" 9 | } 10 | 11 | battery_level() { 12 | echo "$BATTERY_DUMP" | grep level | cut -d ':' -f2 | cut -d ' ' -f2 13 | } 14 | 15 | ac_charge() { 16 | echo "$BATTERY_DUMP" | grep -w "AC powered" | cut -d ":" -f2 | cut -d " " -f2 17 | } 18 | 19 | usb_charge() { 20 | echo "$BATTERY_DUMP" | grep -w "USB powered" | cut -d ":" -f2 | cut -d " " -f2 21 | } 22 | 23 | echo $$ >>"$PIDFILE" 24 | 25 | while true; do 26 | if [ ! -f "$SYNC_PENDING" ]; then 27 | inotifywait "/storage/emulated/$PROFILE/$SYNCDIR" -e modify,create,moved_to,close_write -q >>/dev/null 2>&1 && touch "$SYNC_PENDING" 28 | fi 29 | 30 | while true; do 31 | sleep 5 32 | dump_battery 33 | if [ "$(battery_level)" -gt "$SYNC_BATTLVL" ] || [ "$(bettery_level)" -eq "$SYNC_BATTLVL" ] || [ "$(ac_charge)" = true ] || [ "$(usb_charge)" = true ]; then 34 | echo "Sync battery check success" 35 | else 36 | sleep 300 37 | continue 38 | fi 39 | if [ "$SYNC_CHARGE" = 1 ]; then 40 | if [ "$(ac_charge)" = true ] || [ "$(usb_charge)" = true ]; then 41 | echo "Sync charge check success" 42 | else 43 | echo "Sync charge check fail" 44 | sleep 300 45 | continue 46 | fi 47 | fi 48 | if [ "$SYNC_WIFI" = 1 ]; then 49 | if ! ping -I wlan0 -c 1 "$NETCHK_ADDR" >>/dev/null 2>&1; then 50 | echo "Sync wifi check fail" 51 | sleep 300 52 | continue 53 | else 54 | echo "Sync wifi check success" 55 | fi 56 | fi 57 | break 58 | done 59 | 60 | echo "Syncing..." 61 | nice -n 19 ionice -c 2 -n 7 "$MODDIR"/rclone copy "/storage/emulated/$PROFILE/$SYNCDIR" "$CLOUDROOTMOUNTPOINT/$remote/$SYNCDIR" --retries-sleep=10m --retries 6 --transfers 1 --multi-thread-streams 1 >>/dev/null 2>&1 62 | 63 | if [ -f "$SYNC_PENDING" ]; then 64 | rm -f "${SYNC_PENDING:?}" 65 | fi 66 | echo "Sync finished!" 67 | done 68 | -------------------------------------------------------------------------------- /customize.sh: -------------------------------------------------------------------------------- 1 | # shellcheck disable=SC2034 2 | SKIPUNZIP=1 3 | extract() { 4 | zip=$1 5 | file=$2 6 | dir=$3 7 | junk_paths=$4 8 | [ -z "$junk_paths" ] && junk_paths=false 9 | opts="-o" 10 | [ $junk_paths = true ] && opts="-oj" 11 | 12 | file_path="" 13 | if [ $junk_paths = true ]; then 14 | file_path="$dir/$(basename "$file")" 15 | else 16 | file_path="$dir/$file" 17 | fi 18 | unzip $opts "$zip" "$file" -d "$dir" >&2 19 | [ -f "$file_path" ] || abort "$file not exists" 20 | 21 | ui_print "- Unzip $file" >&1 22 | } 23 | extract "$ZIPFILE" 'module.prop' "$MODPATH" 24 | extract "$ZIPFILE" 'service.sh' "$MODPATH" 25 | extract "$ZIPFILE" 'uninstall.sh' "$MODPATH" 26 | extract "$ZIPFILE" "syncd.sh" "$MODPATH" 27 | mkdir -p "$MODPATH/system/bin" 28 | extract "$ZIPFILE" "common/binary/$ARCH/inotifywait" "$MODPATH/system/bin" true 29 | extract "$ZIPFILE" "system/bin/rclone" "$MODPATH" 30 | extract "$ZIPFILE" "common/binary/$ARCH/rclone" "$MODPATH" true 31 | 32 | if [ "$IS64BIT" = true ]; then 33 | mkdir -p "$MODPATH/system/lib64" 34 | extract "$ZIPFILE" "common/lib/$ARCH/libandroid-support.so" "$MODPATH/system/lib64" true 35 | else 36 | mkdir -p "$MODPATH/system/lib" 37 | extract "$ZIPFILE" "common/lib/$ARCH/libandroid-support.so" "$MODPATH/system/lib" true 38 | fi 39 | 40 | extract "$ZIPFILE" "common/binary/$ARCH/fusermount" "$MODPATH/system/bin" true 41 | 42 | set_perm_recursive "$MODPATH" 0 0 0755 0644 43 | set_perm "$MODPATH"/service.sh 0 0 0755 44 | set_perm "$MODPATH"/syncd.sh 0 0 0755 45 | set_perm "$MODPATH"/rclone 0 0 0755 46 | [ -d "$MODPATH/system/bin" ] && set_perm_recursive "$MODPATH/system/bin" 0 0 0755 0755 47 | [ -d "$MODPATH/system/lib" ] && set_perm_recursive "$MODPATH/system/lib" 0 0 0755 0644 u:object_r:system_lib_file:s0 48 | [ -d "$MODPATH/system/lib64" ] && set_perm_recursive "$MODPATH/system/lib64" 0 0 0755 0644 u:object_r:system_lib_file:s0 49 | USER_CONFDIR_OLD=/sdcard/.rclone 50 | USER_CONFDIR=/sdcard/Android/.rclone 51 | USER_CONF=$USER_CONFDIR/rclone.conf 52 | USER_CONF_OLD=$USER_CONFDIR_OLD/rclone.conf 53 | if [ -f "$USER_CONF" ]; then 54 | ui_print 55 | ui_print "- Please reboot to take effect" 56 | ui_print 57 | elif [ -f "$USER_CONF_OLD" ] && [ ! -d "$USER_CONFDIR" ]; then 58 | ui_print "- Migrating config file to $USER_CONFDIR" 59 | mkdir -p "$USER_CONFDIR" 60 | mv "$USER_CONFDIR_OLD"/* "$USER_CONFDIR"/ 61 | rm -rf "${USER_CONFDIR_OLD:?}" 62 | else 63 | ui_print "'$USER_CONF' not found!" 64 | ui_print 65 | ui_print "Additional setup required..." 66 | ui_print "------------------------------------" 67 | ui_print " Instructions: " 68 | ui_print " - Open Terminal " 69 | ui_print " - Type 'su' & tap enter " 70 | ui_print " - Type 'rclone config' & tap enter " 71 | ui_print " - Follow on screen options. " 72 | ui_print "------------------------------------" 73 | fi 74 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## Changelog (forked) 2 | ### v1.30 3 | * Updated `rclone` to match itsToggle fork https://github.com/itsToggle/rclone_RD/releases 4 | 5 | 6 | ### v1.20 (Howard20 fork) 7 | * Updated `rclone` to 1.60.0 8 | * Updated `inotifywait` to 3.22.6.0 9 | * Fix `rclone config` on Windows Subsystem for Android 10 | * Fix bind-mount to `/sdcard` on Windows Subsystem for Android 11 | ### v1.14 (binary updates) 12 | * Updated rclone to 1.56.0 for all supported architectures. 13 | * Updated README.md to point to Termux packages source. 14 | 15 | ### v1.14 16 | * Used @Zackptg5's MMT-EX module template. 17 | * Cleaned all install & wrapper scripts. 18 | * Fixed bugs related to `rclone` command not working (proper wrapper script placement). 19 | * All the webservers (SFTP/FTP/HTTP) work fine now. 20 | * Bring back x86 and x86_64 support. 21 | * Updated all binaries (extracted from Termux builds). 22 | - `libandroid-support` (28) 23 | - `rclone` (1.55.0) 24 | - `fusermount` (2.9.9) 25 | - `inotifywait` (3.20.11.0) 26 | 27 | ## Changelog (source) 28 | 29 | ### v1.13 30 | * Add arm/arm64 1.53 binaries downloaded from https://beta.rclone.org/v1.53.0/testbuilds/rclone-android-16-arm.gz 31 | 32 | ### v1.12 33 | * Fixed restart problems. 34 | 35 | ### v1.11 36 | * Add arm/arm64 1.52 bins downloaded from https://beta.rclone.org/v1.52.0/testbuilds/rclone-android-16-arm.gz 37 | * Fixed service.sh paths 38 | 39 | ### v1.10 40 | * fixed fusermount wrapper 41 | 42 | ### v1.9 43 | * Add arm/arm64 1.51 bins downloaded from https://beta.rclone.org/ 44 | * Commented fusermount wrapper 45 | 46 | ### v1.8 47 | * Support for Work Profiles `PROFILE=` 48 | * Isolate to Work Profiles `ISOLATE=1` 49 | * Support syncing from SD to remote 50 | 51 | ### v1.7 52 | * Add ability to disable HTTP/FTP 53 | * Link rest of default params to custom vars 54 | * Exclude some custom params from globals 55 | * Make some globals exclusive 56 | * Change `BINDPOINT=` to `SDBINDPOINT=` 57 | * Fix bug with custom params 58 | * Set `PATH=` to change priority of used bins 59 | 60 | ### v1.6 61 | * Simplify custom global parameters 62 | * Fix & improve binding to SD 63 | * Specify additional rclone ops with `ADD_PARAMS=` 64 | * Replace `rclone mount` ops via `REPLACE_PARAMS=` 65 | 66 | ### v1.5 67 | * Replace arm/arm64 `rclone` 1.48 bins built with Termux 68 | * Replace arm/arm64 `fusermount` built with Termux 69 | * Add arm/arm64 `libandroid-support.so` from Termux 70 | * Support for mounting to SD 71 | * Squash missing rclone.conf install bug 72 | * Tune default parameters 73 | * Include a wrap for `rclone config` 74 | * Include `fusermount-wrapper.sh` 75 | * General Improvements 76 | 77 | ### v1.4 78 | * Add ability to disable a remote 79 | * Add a wrapper script for rclone 80 | * Access remotes via http & ftp 81 | * Use without rebooting device 82 | * Add wrapper cmds to `rclone help` 83 | * Make remount possible via `su -M -c` 84 | 85 | ### v1.3 86 | * Move user rclone.conf & related to `/sdcard/.rclone/` 87 | * Control global `--vfs-cache-mode` via simple files placed in `/sdcard/.rclone/` 88 | * Specify custom params for individual remotes via `/sdcard/.rclone/.REMOTENAME.params` 89 | 90 | ### v1.2 91 | * Change install process 92 | * Changes for full systemless 93 | * Improve mount reliability 94 | * Symlink mountpoint to `/storage/` 95 | 96 | ### v1.1 97 | * Initial release 98 | * rclone mount 99 | -------------------------------------------------------------------------------- /system/bin/rclone: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | 3 | # Module directory, DO NOT TOUCH THIS! 4 | MODDIR=${MODDIR:-$(magisk --path)/.magisk/modules/rclone.mount} 5 | RCLONE_BIN=${MODDIR}/rclone 6 | echo "Using 'rclone' binary: ${RCLONE_BIN}" 7 | 8 | USER_CONFDIR=/sdcard/Android/.rclone 9 | USER_CONF=${USER_CONFDIR}/rclone.conf 10 | export XDG_CONFIG_HOME=/data/local/tmp/ 11 | CONFIGFILE="$XDG_CONFIG_HOME"/rclone/rclone.conf 12 | export LOGFILE=${USER_CONFDIR}/rclone.log 13 | export LOGLEVEL=NOTICE 14 | export DATA_MEDIA=/data/media/0 15 | RUNTIME_R=/mnt/runtime/read 16 | RUNTIME_W=/mnt/runtime/write 17 | RUNTIME_D=/mnt/runtime/default 18 | BINDPOINT_R=${RUNTIME_R}/emulated/0/Cloud 19 | BINDPOINT_W=${RUNTIME_W}/emulated/0/Cloud 20 | BINDPOINT_D=${RUNTIME_D}/emulated/0/Cloud 21 | SD_BINDPOINT=${BINDPOINT_D} 22 | CLOUDROOTMOUNTPOINT=/mnt/cloud 23 | 24 | SCRIPTPID=$$ 25 | export INTERACTIVE=1 26 | 27 | custom_params() { 28 | PARAMS="DISABLE BINDSD BINDPOINT" 29 | BAD_SYNTAX="(^\s*#|^\s*$|^\s*[a-z_][^[:space:]]*=[^;&\(\`]*$)" 30 | if [ -f "$USER_CONFDIR/.$remote.param" ]; then 31 | echo "Found .$remote.param" 32 | if ! (grep -E -ivq "$BAD_SYNTAX" "$USER_CONFDIR/.$remote.param"); then 33 | echo "loading .$remote.param" 34 | for PARAM in "${PARAMS[@]}"; do 35 | while read -r VAR; do 36 | if (echo "$VAR" | grep -qw "$PARAM"); then 37 | echo "Importing $VAR" 38 | eval "$(echo "$VAR" | cut -d ' ' -f 1)" 39 | fi 40 | done <"$USER_CONFDIR/.$remote.param" 41 | done 42 | else 43 | echo ".$remote.param contains bad syntax" 44 | fi 45 | fi 46 | } 47 | 48 | config() { 49 | if [ ! -d "$USER_CONFDIR" ]; then 50 | mkdir "$USER_CONFDIR" 51 | fi 52 | if [ -f "$USER_CONF" ]; then 53 | cp "$USER_CONF" "$CONFIGFILE" 54 | fi 55 | $RCLONE_BIN config && cp "$CONFIGFILE" "$USER_CONF" && echo && remount 56 | } 57 | 58 | help() { 59 | $RCLONE_BIN help 60 | echo 61 | echo 'Wrapper Commands:' 62 | echo ' disable Disable a specified remote which exist in rclone.conf.' 63 | echo ' remount Remount the remotes inside rclone.conf except disabled.' 64 | echo ' unmount Kill rclone & unmount all remotes.' 65 | } 66 | 67 | disable() { 68 | echo "disabling remote $1" 69 | touch "$USER_CONFDIR/.$1.disable" 70 | remount 71 | } 72 | 73 | unmount() { 74 | echo "Killing & Unmounting Remotes...." 75 | echo 76 | kill "$(pgrep -f rclone | grep -v "$SCRIPTPID")" >>/dev/null 2>&1 77 | sleep 1 78 | { 79 | umount -lf ${CLOUDROOTMOUNTPOINT}/* 2>&1 80 | umount -lf ${CLOUDROOTMOUNTPOINT} 2>&1 81 | } >>/dev/null 82 | ${RCLONE_BIN} purge ${CLOUDROOTMOUNTPOINT} >>/dev/null 2>&1 83 | } 84 | 85 | sd_unbind_func() { 86 | if [ -z "$BINDPOINT" ]; then 87 | UNBINDPOINT=${BINDPOINT_D}/${remote} 88 | su -M -c umount -lf "$UNBINDPOINT" >>/dev/null 2>&1 89 | UNBINDPOINT=${BINDPOINT_R}/${remote} 90 | su -M -c umount -lf "$UNBINDPOINT" >>/dev/null 2>&1 91 | UNBINDPOINT=${BINDPOINT_W}/${remote} 92 | su -M -c umount -lf "$UNBINDPOINT" >>/dev/null 2>&1 93 | else 94 | USER_BINDPOINT=${BINDPOINT} 95 | UNBINDPOINT=${RUNTIME_D}/emulated/0/${USER_BINDPOINT} 96 | su -M -c umount -lf ${UNBINDPOINT} >>/dev/null 2>&1 97 | UNBINDPOINT=${RUNTIME_R}/emulated/0/${USER_BINDPOINT} 98 | su -M -c umount -lf ${UNBINDPOINT} >>/dev/null 2>&1 99 | UNBINDPOINT=${RUNTIME_W}/emulated/0/${USER_BINDPOINT} 100 | su -M -c umount -lf ${UNBINDPOINT} >>/dev/null 2>&1 101 | fi 102 | } 103 | 104 | sd_unbind() { 105 | $RCLONE_BIN listremotes --config "$CONFIGFILE" | cut -f1 -d: | while read -r remote; do 106 | echo 107 | custom_params 108 | sd_unbind_func 109 | done >>/dev/null 2>&1 110 | } 111 | 112 | remount() { 113 | sd_unbind 114 | unmount 115 | "$MODDIR"/service.sh 116 | } 117 | 118 | if [ "$1" = disable ]; then 119 | disable "$2" 120 | elif [ "$1" = remount ]; then 121 | remount 122 | elif [ "$1" = unmount ]; then 123 | sd_unbind 124 | unmount 125 | elif [ "$1" = config ]; then 126 | config 127 | elif [ "$1" = help ]; then 128 | help 129 | elif [ "$1" = --help ]; then 130 | help 131 | elif [ -z "$1" ]; then 132 | help 133 | else 134 | $RCLONE_BIN "$@" 135 | fi 136 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

RealDebrid-Compatible Cloud Storage Mounter for Magisk (prev: rclone-mount)

2 | 3 |
4 | 5 | Version 7 | 8 | _time_stamp_ 10 | 11 | _time_stamp_
13 | 14 |
15 | This is the spiritual successor of rclone-mount with bug fixes and newer binaries included. More details in the 16 | wiki. 17 |
18 | 19 |
20 |

21 | 22 | Source Code 23 | 24 | | 25 | 26 | Original Module Repository 27 | 28 | | 29 | 30 | Issues 31 | 32 |

33 |
34 | 35 | ### About 36 | - This magisk module has been created to work with [@itsToggle](https://github.com/itsToggle)'s [Rclone_RD](https://github.com/itsToggle/rclone_RD/) which implements Real-Debrid to rclone. 37 | 38 | - All credit goes to [@itsToggle](https://github.com/itsToggle), [@Howard20181](https://github.com/Howard20181), [@AvinashReddy3108](https://github.com/AvinashReddy3108) and [@piyushgarg](https://github.com/piyushgarg). 39 | 40 | # RClone_RD 41 | 42 | This RClone Fork contains a Real-Debrid implementation. 43 | Using this version, the entire RealDebrid /torrents directory can be served as a read-only virtual drive. 44 | 45 | A potential use-case for this is serving the /torrent directory over plex, allowing you to build a media library truly unlimted in size. Im working on a project that allows plex to function the same way that Wako,Syncler and other streaming apps do. Check it out on https://github.com/itsToggle/plex_rd 46 | 47 | ### Capabilities and Limitations: 48 | 49 | - Read/Write capabilities are limited to reading files and deleting them. 50 | - This rclone fork will automatically sort your torrents into 3 subfolder: "shows", "movies" and "default". If a torrent couldnt be classified as a movie or a show, you can find it in the "default" folder. 51 | - There are no server-side traffic or storage limitations. 52 | - This rclone fork will automatically re-activate direct links when they expire after 1 week. 53 | - There is a server-side connection limit, which I believe is 16 parallel connections. 54 | 55 | # Rclone Magisk Module 56 | 57 | ### Features 58 | - Support for arm, arm64, & x86 (64bit too) 59 | - Huge list of [supported cloud storage providers](https://rclone.org/#providers) 60 | - Apps with ability to specify paths can access the remotes at `/mnt/cloud/`. 61 | - Most file explorers work just fine ([read more on this](https://github.com/Magisk-Modules-Repo/com.piyushgarg.rclone/issues/9)). 62 | - Mount points use names of remote(s) in rclone.conf 63 | - Specify custom rclone params for each remote via `/sdcard/.rclone/.REMOTE.param` 64 | - Access remotes via HTTP or (S)FTP clients, or bind the remotes to `/sdcard/Cloud/REMOTE` (recommended to [read this](https://github.com/Magisk-Modules-Repo/com.piyushgarg.rclone/issues/5)). 65 | - Support for Work Profiles. 66 | 67 | ### Configuration 68 | 1. Copy your `rclone.conf` file (if you have one already) to `/sdcard/.rclone/rclone.conf` (can always be generated later.) 69 | 2. Add custom params at `/sdcard/.rclone/.[global/REMOTE].param` (if needed) 70 | 3. Install the module via Magisk Manager 71 | 4. Run `rclone config` via term if additional setup required 72 | 4. All your rclone mount points will show up under `/mnt/cloud/` & `/storage/cloud/` or `/sdcard/cloud/` 73 | 74 | For more detailed configuration of rclone please refer to [official documentation](https://rclone.org) 75 | 76 | ### Known Issues 77 | - VLC takes a long time to load media as it opens file in write mode when using it's internal browser. 78 | 79 | a. Create remote type alias for media dirs in rclone.conf and 80 | specify `CACHEMODE=off` in `/sdcard/.rclone/.ALIASNAME.param` 81 | 82 | - Encrypted devices can not mount until unlock 83 | - Encrypted `rclone.conf` causes reboots 84 | - High cpu/mem in some apps with storage perms ([issue #9](https://github.com/Magisk-Modules-Repo/com.piyushgarg.rclone/issues/9)) 85 | - The `fusermount` bin may not be compatible on all devices (see [thread](https://www.google.com/amp/s/forum.xda-developers.com/android/development/fusermount-android-rclone-mount-t3866652/amp/)) 86 | 87 | ## Disclaimer 88 | - Neither the author nor devs will be held responsible for any damage/data loss that may occur during use of this module. 89 | - While we have done our best to make sure no harm will come about, no guarantees can be made. 90 | - Keep in mind the binaries included in this project are BETA quality (at best), which may cause unforseen issues. 91 | 92 | Always check this document before updating to new releases as significant changes may occur. 93 | 94 | ## Credits 95 | - [@itsToggle](https://github.com/itsToggle) for [rclone_RD](https://github.com/itsToggle/rclone_RD/) 96 | - [@Howard20181](https://github.com/Howard20181), [@AvinashReddy3108](https://github.com/AvinashReddy3108) and [@piyushgarg](https://github.com/piyushgarg) for their original magisk modules 97 | - rclone devs 98 | - pmj_pedro[@xda](https://forum.xda-developers.com/showpost.php?p=78147335&postcount=1) 99 | - agnostic-apollo[@xda](https://forum.xda-developers.com/showpost.php?p=79929083&postcount=12) 100 | - Termux for building and hosting binaries for [rclone](https://packages.termux.org/apt/termux-main/pool/main/r/rclone), [fusermount](https://grimler.se/termux-root-packages-24/pool/stable/libf/libfuse2/), [inotifywait](https://packages.termux.org/apt/termux-main/pool/main/i/inotify-tools), [libandroid-support.so](https://packages.termux.org/apt/termux-main/pool/main/liba/libandroid-support). 101 | - improvements by geofferey@github 102 | - @Zackptg5 for MMT-EX Module template. 103 | -------------------------------------------------------------------------------- /service.sh: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | MODDIR=${0%/*} 3 | # Do NOT assume where your module will be located. 4 | # ALWAYS use $MODDIR if you need to know where this script 5 | # and module is placed. 6 | # This will make sure your module will work 7 | # if Magisk changes it's mount point in the future 8 | 9 | # MODULE VARS 10 | CLOUDROOTMOUNTPOINT=/mnt/cloud 11 | USER_CONFDIR=/sdcard/Android/.rclone 12 | USER_CONF=$USER_CONFDIR/rclone.conf 13 | PROFILE=0 14 | DATA_MEDIA=/data/media 15 | RUNTIME_R=/mnt/runtime/read 16 | RUNTIME_W=/mnt/runtime/write 17 | RUNTIME_D=/mnt/runtime/default 18 | BINDPOINT_R=${RUNTIME_R}/emulated/${PROFILE}/Cloud 19 | BINDPOINT_W=${RUNTIME_W}/emulated/${PROFILE}/Cloud 20 | BINDPOINT_D=${RUNTIME_D}/emulated/${PROFILE}/Cloud 21 | BINDPOINT_P=/mnt/pass_through/${PROFILE}/emulated/${PROFILE}/Cloud 22 | SD_BINDPOINT=${BINDPOINT_P} 23 | DISABLE=0 24 | NETCHK=1 25 | 26 | # DEFAULT RCLONE PARAMETERS 27 | CONFIGFILE=${MODDIR}/.config/rclone/rclone.conf 28 | LOGFILE=${USER_CONFDIR}/rclone.log 29 | LOGLEVEL=NOTICE 30 | CACHE=/data/rclone/cache 31 | CACHE_BACKEND=/data/rclone/cache/cache-backend 32 | CACHEMODE=off 33 | READCHUNKSIZE=1M 34 | CACHEMAXSIZE=1G 35 | CHUNKSIZE=1M 36 | CHUNKTOTAL=1G 37 | CACHEWORKERS=1 38 | CACHEINFOAGE=1h0m0s 39 | DIRCACHETIME=30m0s 40 | ATTRTIMEOUT=30s 41 | BUFFERSIZE=0 42 | READAHEAD=128k 43 | M_UID=0 44 | M_GID=1015 45 | DIRPERMS=0775 46 | FILEPERMS=0644 47 | UMASK=002 48 | BINDSD=1 49 | SYNC_WIFI=1 50 | SYNC_CHARGE=0 51 | SYNC_BATTLVL=0 52 | HTTP=0 53 | HTTP_ADDR=127.0.0.1:38762 54 | FTP=0 55 | FTP_ADDR=127.0.0.1:38763 56 | SFTP=0 57 | SFTP_ADDR=127.0.0.1:38722 58 | SFTP_USER= 59 | SFTP_PASS= 60 | 61 | if [[ -z ${INTERACTIVE} ]]; then 62 | INTERACTIVE=0 63 | fi 64 | 65 | if [[ ! -d ${MODDIR}/.config/rclone ]]; then 66 | mkdir -p ${MODDIR}/.config/rclone 67 | fi 68 | gethostip() { 69 | ip=$(ip route list match 0 table all scope global | cut -F3) 70 | if [ -z "$ip" ]; then 71 | return 1 72 | else 73 | echo "$ip" 74 | fi 75 | } 76 | 77 | while ! (gethostip); do 78 | sleep 3 79 | done 80 | NETCHK_ADDR=$(gethostip) 81 | custom_params() { 82 | if [[ ${remote} = global ]]; then 83 | PARAMS="DISABLE LOGFILE LOGLEVEL CACHEMODE CHUNKSIZE CHUNKTOTAL CACHEWORKERS CACHEINFOAGE DIRCACHETIME ATTRTIMEOUT BUFFERSIZE READAHEAD M_UID M_GID DIRPERMS FILEPERMS READONLY BINDSD ADD_PARAMS REPLACE_PARAMS NETCHK NETCHK_IF NETCHK_ADDR HTTP FTP HTTP_ADDR FTP_ADDR SFTP SFTP_ADDR SFTP_USER SFTP_PASS PROFILE ISOLATE" 84 | else 85 | PARAMS="DISABLE LOGFILE LOGLEVEL CACHEMODE CHUNKSIZE CHUNKTOTAL CACHEWORKERS CACHEINFOAGE DIRCACHETIME ATTRTIMEOUT BUFFERSIZE READAHEAD M_UID M_GID DIRPERMS FILEPERMS READONLY BINDSD SDBINDPOINT ADD_PARAMS REPLACE_PARAMS PROFILE ISOLATE SDSYNCDIRS SYNC_WIFI SYNC_BATTLVL SYNC_CHARGE SUBPATH" 86 | fi 87 | BAD_SYNTAX="(^\s*#|^\s*$|^\s*[a-z_][^[:space:]]*=[^;&\(\`]*$)" 88 | if [[ -e ${USER_CONFDIR}/.${remote}.param ]]; then 89 | echo "Found .${remote}.param" 90 | if ! [[ $(egrep -q -iv "${BAD_SYNTAX}" ${USER_CONFDIR}/.${remote}.param) ]]; then 91 | echo "loading .${remote}.param" 92 | # FIX: Unnecessary and very inefficient double loop 93 | for PARAM in ${PARAMS[@]}; do 94 | while read -r VAR; do 95 | if [[ "$(echo "${VAR}" | grep "$PARAM=")" ]]; then 96 | echo "Importing ${VAR}" 97 | VALUE="$(echo ${VAR} | cut -d '=' -f2)" 98 | VALUE=\"${VALUE}\" 99 | # Unnecessary echo in a subshell execution below? Why not just: 100 | # eval "${PARAM}""=""${VALUE}" 101 | eval $(echo "${PARAM}""=""${VALUE}") 102 | fi 103 | done <${USER_CONFDIR}/.${remote}.param 104 | done 105 | else 106 | echo ".${remote}.param contains bad syntax" 107 | fi 108 | fi 109 | } 110 | 111 | global_params() { 112 | remote=global 113 | custom_params 114 | unset remote 115 | echo 116 | } 117 | 118 | net_chk() { 119 | if [ -z ${NETCHK_IF} ]; then 120 | NETCHK_IF=" " 121 | else 122 | NETCHK_IF=" -I ${NETCHK_IF} " 123 | fi 124 | ping ${NETCHK_IF} -c 5 ${NETCHK_ADDR} 125 | } 126 | 127 | sd_unbind() { 128 | if [[ -z ${SDBINDPOINT} ]]; then 129 | UNBINDPOINT=${BINDPOINT_D}/${remote} 130 | umount -lf ${UNBINDPOINT} >>/dev/null 2>&1 131 | UNBINDPOINT=${BINDPOINT_R}/${remote} 132 | umount -lf ${UNBINDPOINT} >>/dev/null 2>&1 133 | UNBINDPOINT=${BINDPOINT_W}/${remote} 134 | umount -lf ${UNBINDPOINT} >>/dev/null 2>&1 135 | UNBINDPOINT="$SD_BINDPOINT/$remote" 136 | umount -lf "$UNBINDPOINT" >>/dev/null 2>&1 137 | else 138 | USER_BINDPOINT=${SDBINDPOINT} 139 | UNBINDPOINT=${RUNTIME_D}/emulated/${PROFILE}/${USER_BINDPOINT} 140 | umount -lf ${UNBINDPOINT} >>/dev/null 2>&1 141 | UNBINDPOINT=${RUNTIME_R}/emulated/${PROFILE}/${USER_BINDPOINT} 142 | umount -lf ${UNBINDPOINT} >>/dev/null 2>&1 143 | UNBINDPOINT=${RUNTIME_W}/emulated/${PROFILE}/${USER_BINDPOINT} 144 | umount -lf ${UNBINDPOINT} >>/dev/null 2>&1 145 | fi 146 | } 147 | 148 | sd_binder() { 149 | if [[ -d ${RUNTIME_D} ]] && [[ ${BINDSD} = 1 ]]; then 150 | if [[ -z ${SDBINDPOINT} ]]; then 151 | mkdir -p ${DATA_MEDIA}/${PROFILE}/Cloud/${remote} 152 | chown media_rw:media_rw ${DATA_MEDIA}/${PROFILE}/Cloud/$remote 153 | 154 | BINDPOINT=${BINDPOINT_D}/${remote} 155 | 156 | mount --bind ${CLOUDROOTMOUNTPOINT}/${remote} ${BINDPOINT} >>/dev/null 2>&1 157 | 158 | BINDPOINT=${BINDPOINT_R}/${remote} 159 | 160 | if ! mount | grep -q ${BINDPOINT}; then 161 | mount --bind ${CLOUDROOTMOUNTPOINT}/${remote} ${BINDPOINT} >>/dev/null 2>&1 162 | fi 163 | 164 | BINDPOINT=${BINDPOINT_W}/${remote} 165 | 166 | if ! mount | grep -q ${BINDPOINT}; then 167 | mount --bind ${CLOUDROOTMOUNTPOINT}/${remote} ${BINDPOINT} >>/dev/null 2>&1 168 | fi 169 | 170 | BINDPOINT="$SD_BINDPOINT/$remote" 171 | 172 | if ! mount | grep -q "$BINDPOINT"; then 173 | mount --bind "$CLOUDROOTMOUNTPOINT/$remote" "$BINDPOINT" >>/dev/null 2>&1 174 | fi 175 | 176 | echo "[$remote] available at: -> [/sdcard/Cloud/${remote}] BINDPOINT=$BINDPOINT" 177 | else 178 | mkdir ${DATA_MEDIA}/${PROFILE}/${SDBINDPOINT} >>/dev/null 2>&1 179 | chown media_rw:media_rw ${DATA_MEDIA}/${PROFILE}/${SDBINDPOINT} 180 | 181 | USER_BINDPOINT=${SDBINDPOINT} 182 | BINDPOINT=${RUNTIME_D}/emulated/${PROFILE}/${USER_BINDPOINT} 183 | 184 | mount --bind ${CLOUDROOTMOUNTPOINT}/${remote} ${BINDPOINT} >>/dev/null 2>&1 185 | 186 | BINDPOINT=${RUNTIME_R}/emulated/${PROFILE}/${USER_BINDPOINT} 187 | 188 | if ! mount | grep -q ${BINDPOINT}; then 189 | mount --bind ${CLOUDROOTMOUNTPOINT}/${remote} ${BINDPOINT} >>/dev/null 2>&1 190 | fi 191 | 192 | BINDPOINT=${RUNTIME_W}/emulated/${PROFILE}/${USER_BINDPOINT} 193 | 194 | if ! mount | grep -q ${BINDPOINT}; then 195 | mount --bind ${CLOUDROOTMOUNTPOINT}/${remote} ${BINDPOINT} >>/dev/null 2>&1 196 | fi 197 | echo "[$remote] available at: -> [/storage/emulated/${PROFILE}/${SDBINDPOINT}]" 198 | unset BINDPOINT 199 | fi 200 | fi 201 | } 202 | 203 | syncd_service() { 204 | if [[ ! -z ${SDSYNCDIRS} ]]; then 205 | export PIDFILE=${MODDIR}/.tmp/${remote}-syncd.pids 206 | kill -9 $(cat ${PIDFILE}) >>/dev/null 2>&1 207 | rm ${PIDFILE} >>/dev/null 2>&1 208 | 209 | if [[ ! -d ${MODDIR}/.tmp ]]; then 210 | mkdir -p ${MODDIR}/.tmp 211 | fi 212 | 213 | export CLOUDROOTMOUNTPOINT 214 | export PROFILE 215 | export MODDIR 216 | export remote 217 | export SYNCWIFI 218 | export SYNC_BATTLVL 219 | export SYNC_CHARGE 220 | export NETCHK_ADDR 221 | 222 | IFS=$':' 223 | for SYNCDIR in ${SDSYNCDIRS[@]}; do 224 | export SYNCDIR 225 | ${MODDIR}/syncd.sh >>/dev/null 2>&1 & 226 | done 227 | fi 228 | 229 | unset IFS 230 | unset SDSYNCDIRS 231 | unset SYNCDIR 232 | SYNC_BATTLVL=0 233 | SYNC_WIFI=1 234 | SYNC_CHARGE=0 235 | } 236 | 237 | reset_params() { 238 | unset IFS 239 | unset SDBINDPOINT 240 | unset BINDSD 241 | unset ISOLATE 242 | unset RCLONE_PARAMS 243 | unset REPLACE_PARAMS 244 | unset ADD_PARAMS 245 | unset SYNCDIR 246 | unset SDSYNCDIRS 247 | unset PIDFILE 248 | unset SUBPATH 249 | LOGFILE=${USER_CONFDIR}/rclone.log 250 | LOGLEVEL=NOTICE 251 | CACHEMODE=off 252 | READCHUNKSIZE=1M 253 | CACHEMAXSIZE=1G 254 | CHUNKSIZE=1M 255 | CHUNKTOTAL=1G 256 | CACHEWORKERS=1 257 | CACHEINFOAGE=1h0m0s 258 | DIRCACHETIME=30m0s 259 | ATTRTIMEOUT=30s 260 | BUFFERSIZE=0 261 | READAHEAD=128k 262 | M_UID=0 263 | M_GID=1015 264 | DIRPERMS=0775 265 | FILEPERMS=0644 266 | UMASK=002 267 | PROFILE=0 268 | SYNC_WIFI=1 269 | SYNC_BATTLVL=0 270 | SYNC_CHARGE=0 271 | } 272 | 273 | rclone_mount() { 274 | if [[ ${READONLY} = 1 ]]; then 275 | READONLY=" --read-only " 276 | else 277 | READONLY=" " 278 | fi 279 | 280 | if [[ ${ADD_PARAMS} = 0 ]]; then 281 | unset ADD_PARAMS 282 | fi 283 | 284 | if [[ ${REPLACE_PARAMS} = 0 ]]; then 285 | unset REPLACE_PARAMS 286 | fi 287 | 288 | if [[ -z ${REPLACE_PARAMS} ]]; then 289 | RCLONE_PARAMS=" --log-file ${LOGFILE} --log-level ${LOGLEVEL} --vfs-cache-mode ${CACHEMODE} --cache-dir ${CACHE} --cache-chunk-path ${CACHE_BACKEND} --cache-db-path ${CACHE_BACKEND} --cache-tmp-upload-path ${CACHE} --vfs-read-chunk-size ${READCHUNKSIZE} --vfs-cache-max-size ${CACHEMAXSIZE} --cache-chunk-size ${CHUNKSIZE} --cache-chunk-total-size ${CHUNKTOTAL} --cache-workers ${CACHEWORKERS} --cache-info-age ${CACHEINFOAGE} --dir-cache-time ${DIRCACHETIME} --attr-timeout ${ATTRTIMEOUT} --cache-chunk-no-memory --use-mmap --buffer-size ${BUFFERSIZE} --max-read-ahead ${READAHEAD} --no-modtime --no-checksum --uid ${M_UID} --gid ${M_GID} --allow-other --dir-perms ${DIRPERMS} --file-perms ${FILEPERMS} --umask ${UMASK} ${READONLY} ${ADD_PARAMS} " 290 | elif [[ ! -z ${REPLACE_PARAMS} ]]; then 291 | RCLONE_PARAMS=" ${REPLACE_PARAMS} " 292 | fi 293 | 294 | if [[ -z ${ADD_PARAMS} ]]; then 295 | ADD_PARAMS=" " 296 | elif [[ ! -z ${ADD_PARAMS} ]]; then 297 | ADD_PARAMS=" ${ADD_PARAMS} " 298 | fi 299 | 300 | echo "[${remote}] available at: -> [${CLOUDROOTMOUNTPOINT}/${remote}]" 301 | mkdir -p ${CLOUDROOTMOUNTPOINT}/${remote} 302 | nice -n 19 ionice -c 2 -n 7 ${MODDIR}/rclone mount "${remote}:${SUBPATH}" ${CLOUDROOTMOUNTPOINT}/${remote} --config ${CONFIGFILE} ${RCLONE_PARAMS} --daemon >>/dev/null 2>&1 & 303 | } 304 | 305 | COUNT=0 306 | 307 | if [[ ${INTERACTIVE} = 0 ]]; then 308 | until [[ $(getprop sys.boot_completed) = 1 ]] && [[ $(getprop dev.bootcomplete) = 1 ]] && [[ $(getprop init.svc.bootanim) = stopped ]] && [[ -e ${USER_CONF} ]] || [[ ${COUNT} -eq 240 ]]; do 309 | sleep 5 310 | ((++COUNT)) 311 | done 312 | fi 313 | 314 | DECRYPT_CHK() { 315 | ls sdcard | grep -q -w "Android" 316 | } 317 | 318 | if [[ ${COUNT} -eq 240 ]] || [[ ! -d /sdcard/Android ]]; then 319 | exit 0 320 | fi 321 | 322 | if [[ ! -d ${USER_CONFDIR} ]]; then 323 | mkdir ${USER_CONFDIR} 324 | fi 325 | 326 | if [[ -e ${USER_CONFDIR}/.disable ]] && [[ ${INTERACTIVE} = 0 ]]; then 327 | exit 0 328 | fi 329 | 330 | if [[ ${INTERACTIVE} = 0 ]]; then 331 | export INTERACTIVE=1 332 | ${MODDIR}/service.sh 333 | exit 334 | fi 335 | 336 | global_params 337 | 338 | if [ ! -d "$CLOUDROOTMOUNTPOINT" ]; then 339 | mkdir -p "$CLOUDROOTMOUNTPOINT" 340 | chown root:sdcard_rw "$CLOUDROOTMOUNTPOINT" 341 | touch "$CLOUDROOTMOUNTPOINT"/.nomedia 342 | chown root:sdcard_rw "$CLOUDROOTMOUNTPOINT"/.nomedia 343 | chmod 0775 "$CLOUDROOTMOUNTPOINT"/.nomedia 344 | fi 345 | 346 | if [ ! -f "$CLOUDROOTMOUNTPOINT/.nomedia" ]; then 347 | touch "$CLOUDROOTMOUNTPOINT"/.nomedia 348 | chown root:sdcard_rw "$CLOUDROOTMOUNTPOINT"/.nomedia 349 | chmod 0644 "$CLOUDROOTMOUNTPOINT"/.nomedia 350 | fi 351 | 352 | if [[ ! -d ${CACHE} ]]; then 353 | mkdir -p ${CACHE} 354 | chown root:sdcard_rw ${CACHE} 355 | chmod 0775 ${CACHE} 356 | fi 357 | 358 | if [[ -d ${CACHE} ]]; then 359 | chown root:sdcard_rw ${CACHE} 360 | chmod 0775 ${CACHE} 361 | fi 362 | 363 | if [[ ! -d ${CACHE_BACKEND} ]]; then 364 | mkdir -p ${CACHE_BACKEND} 365 | fi 366 | 367 | if [[ -d ${CACHE_BACKEND} ]]; then 368 | chown root:sdcard_rw ${CACHE_BACKEND} 369 | chmod 0775 ${CACHE_BACKEND} 370 | fi 371 | 372 | if [[ ! -L ${RUNTIME_R}/cloud ]]; then 373 | ln -sf ${CLOUDROOTMOUNTPOINT} ${RUNTIME_R}/cloud 374 | fi 375 | 376 | if [[ ! -L ${RUNTIME_W}/cloud ]]; then 377 | ln -sf ${CLOUDROOTMOUNTPOINT} ${RUNTIME_W}/cloud 378 | fi 379 | 380 | if [[ ! -L ${RUNTIME_D}/cloud ]]; then 381 | ln -sf ${CLOUDROOTMOUNTPOINT} ${RUNTIME_D}/cloud 382 | fi 383 | 384 | if [[ ! -L "$BINDPOINT_P" ]]; then 385 | ln -sf "$CLOUDROOTMOUNTPOINT" "$BINDPOINT_P" 386 | fi 387 | 388 | if [ ! -f "$BINDPOINT_P/.nomedia" ]; then 389 | touch "$BINDPOINT_P"/.nomedia 390 | chown root:sdcard_rw "$BINDPOINT_P"/.nomedia 391 | chmod 0644 "$BINDPOINT_P"/.nomedia 392 | fi 393 | 394 | if [[ -e ${USER_CONF} ]]; then 395 | cp ${USER_CONF} ${CONFIGFILE} 396 | chmod 0600 ${CONFIGFILE} 397 | fi 398 | 399 | if [[ ${NETCHK} = 1 ]]; then 400 | until net_chk || [[ ${COUNT} = 60 ]]; do 401 | sleep 5 402 | ((++COUNT)) 403 | done >>/dev/null 2>&1 404 | fi 405 | 406 | echo "Default CACHEMODE ${CACHEMODE}" 407 | sleep 5 408 | 409 | LD_LIBRARY_PATH=${MODDIR} ${MODDIR}/rclone listremotes --config ${CONFIGFILE} | cut -f1 -d: | 410 | while read remote; do 411 | echo 412 | list_remote=${remote} 413 | CLOUDROOTMOUNTPOINT=/mnt/cloud 414 | PROFILE=0 415 | DISABLE=0 416 | READONLY=0 417 | global_params >>/dev/null 2>&1 418 | remote=${list_remote} 419 | custom_params 420 | if [[ ${ISOLATE} = 1 ]] && [[ ${PROFILE} -gt 0 ]] && [[ ${BINDSD} = 1 ]]; then 421 | CLOUDROOTMOUNTPOINT=/data/media/${PROFILE}/.cloud 422 | fi 423 | 424 | if [[ ${DISABLE} = 1 ]] || [[ -e ${USER_CONFDIR}/.${remote}.disable ]]; then 425 | echo "${remote} disabled by user" 426 | continue 427 | fi 428 | sd_unbind 429 | rclone_mount 430 | sd_binder 431 | syncd_service 432 | reset_params 433 | done 434 | echo 435 | 436 | if [[ ${HTTP} = 1 ]]; then 437 | if (${MODDIR}/rclone serve http ${CLOUDROOTMOUNTPOINT} --addr ${HTTP_ADDR} --no-checksum --no-modtime --read-only >>/dev/null 2>&1 &) then 438 | echo "HTTP Server: http://${HTTP_ADDR}" 439 | fi 440 | fi 441 | 442 | if [[ ${FTP} = 1 ]]; then 443 | if (${MODDIR}/rclone serve ftp ${CLOUDROOTMOUNTPOINT} --addr ${FTP_ADDR} --no-checksum --no-modtime --read-only >>/dev/null 2>&1 &) then 444 | echo "FTP Server: ftp://${FTP_ADDR}" 445 | fi 446 | fi 447 | 448 | if [[ ${SFTP} = 1 ]] && [[ ! -z ${SFTP_USER} ]] && [[ ! -z ${SFTP_PASS} ]]; then 449 | if (${MODDIR}/rclone serve sftp ${CLOUDROOTMOUNTPOINT} --addr ${SFTP_ADDR} --user ${SFTP_USER} --pass ${SFTP_PASS} --no-checksum --no-modtime --read-only >>/dev/null 2>&1 &) then 450 | echo "SFTP Server: sftp://${SFTP_ADDR}" 451 | fi 452 | fi 453 | 454 | exit 455 | --------------------------------------------------------------------------------