Improve install, service, wrapper etc

This commit is contained in:
geofferey 2019-07-15 06:50:40 +00:00
parent 3f8565c399
commit 01da615111
7 changed files with 69 additions and 103 deletions

View file

@ -120,6 +120,13 @@ For more detailed configuration of rclone please refer to [official documentatio
* Add wrapper cmds to `rclone help`
* Make remount possible without adb via `su -M -c`
### v1.5
* Add arm/arm64 1.48 bins compiled using Termux
* Support for mounting to SD
* Squash missing rclone.conf install bug
* Tune default parameters
* Include a wrap for `rclone config`
</p> </details>
<br>

View file

@ -1,79 +0,0 @@
#!/system/bin/sh
# Do NOT assume where your module will be located.
# ALWAYS use $MODDIR if you need to know where this script
# and module is placed.
# This will make sure your module will still work
# if Magisk change its mount point in the future
MODDIR=${0%/*}
. $MODDIR/module.prop
IMGDIR=/sbin/.core/img
if [ -d $IMGDIR/$id ]; then
ln -sf $IMGDIR/$id/rclone /sbin/rclone
ln -sf $IMGDIR/$id/fusermount /sbin/fusermount
else
ln -sf $MODDIR/rclone /sbin/rclone
ln -sf $MODDIR/fusermount /sbin/fusermount
fi
#RCLONE PARAMETERS
BUFFERSIZE=8M
CACHEMAXSIZE=256M
DIRCACHETIME=24h
READAHEAD=128k
USER_CONF=/sdcard/rclone.conf
CONFIGFILE=$MODDIR/rclone.conf
LOGFILE=/sdcard/rclone.log
HOME=/mnt
CLOUDROOTMOUNTPOINT=$HOME/cloud
CACHE=/mnt/runtime/default/rclone-cache
CACHE_BACKEND=/mnt/runtime/default/rc-cache-backend
if [[ ! -d $CLOUDROOTMOUNTPOINT ]]; then
mkdir -p $CLOUDROOTMOUNTPOINT
fi
if [[ ! -d $CACHE ]]; then
mkdir -p $CACHE
fi
if [[ ! -d $CACHE_BACKEND ]]; then
mkdir -p $CACHE_BACKEND
fi
ln -sf $CLOUDROOTMOUNTPOINT /mnt/runtime/read/cloud
ln -sf $CLOUDROOTMOUNTPOINT /mnt/runtime/write/cloud
if [[ -e $USER_CONFIG ]]; then
cp $USER_CONFIG $CONFIGFILE
chmod 0600 $CONFIGFILE
fi
#sh -c "$MODDIR/system/bin/rclone mount piyushDOTgarg_shopDOTmega: ${CLOUDROOTMOUNTPOINT}/piyushDOTgarg_shopDOTmega -vv --config ${CONFIGFILE} --attr-timeout 10m --cache-dir=/storage/cache --vfs-cache-mode writes --vfs-cache-max-age 168h0m0s --log-file /sdcard/dns.log --allow-other --gid 1015" &
$MODDIR/rclone listremotes --config ${CONFIGFILE}|cut -f1 -d: |
while read line; do
echo "mounting... $line"
mkdir -p ${CLOUDROOTMOUNTPOINT}/${line}
$MODDIR/rclone mount ${line}: ${CLOUDROOTMOUNTPOINT}/${line} --config ${CONFIGFILE} --max-read-ahead ${READAHEAD} --buffer-size ${BUFFERSIZE} --dir-cache-time ${DIRCACHETIME} --poll-interval 5m --attr-timeout ${DIRCACHETIME} --vfs-cache-mode writes --vfs-read-chunk-size 2M --vfs-read-chunk-size-limit 10M --vfs-cache-max-age 168h0m0s --vfs-cache-max-size ${CACHEMAXSIZE} --cache-dir=/storage/cache --cache-chunk-path /storage/cache-backend/ --cache-chunk-clean-interval 10m0s --log-file ${LOGFILE} --allow-other --gid 1015 --daemon
sleep 5
done
echo "...done"

View file

@ -50,6 +50,8 @@ unmount () {
echo "Killing & Unmounting Remotes...."
echo
kill $(pgrep -f rclone| grep -v ${SCRIPTPID}) >> /dev/null 2>&1
sleep 1
@ -58,17 +60,16 @@ unmount () {
umount -lf ${CLOUDROOTMOUNTPOINT} >> /dev/null 2>&1
#if [[ -e ${USER_CONFDIR}/.bindsd ]]; then
umount -lf ${RUNTIME_MNT_DEF}/ >> /dev/null 2>&1
umount -lf ${RUNTIME_MNT_DEF} >> /dev/null 2>&1
su -M -c $HOME/rclone purge ${RUNTIME_MNT_DEF} >> /dev/null 2>&1
su -M -c $HOME/rclone purge ${DATA_MNT} >> /dev/null 2>&1
#fi
$HOME/rclone purge ${CLOUDROOTMOUNTPOINT} >> /dev/null 2>&1
@ -95,6 +96,12 @@ elif [[ ${1} = unmount ]]; then
elif [[ ${1} = config ]]; then
if [[ -e ${USER_CONFDIR}/rclone.conf ]]; then
cp ${USER_CONFDIR}/rclone.conf ${HOME}/.config/rclone/rclone.conf
fi
${HOME}/rclone config && cp ${HOME}/.config/rclone/rclone.conf ${USER_CONFDIR}/rclone.conf && echo && ${HOME}/rclone-wrapper.sh remount
elif [[ ${1} = help ]]; then

View file

@ -18,3 +18,10 @@
* Add ability to disable a remote
* Add a wrapper script for rclone
* Make remount possible via `su --mount-master`
## v1.5
* Add arm/arm64 1.48 bins compiled using Termux
* Support for mounting to SD
* Squash missing rclone.conf install bug
* Tune default parameters
* Include a wrap for `rclone config`

View file

@ -168,8 +168,12 @@ if [[ ! -d ${CACHE} ]]; then
fi
chown root:sdcard_rw ${CACHE}
chmod 0775 ${CACHE}
if [[ -d ${CACHE} ]]; then
chown root:sdcard_rw ${CACHE}
chmod 0775 ${CACHE}
fi
if [[ ! -d ${CACHE_BACKEND} ]]; then
@ -177,8 +181,12 @@ if [[ ! -d ${CACHE_BACKEND} ]]; then
fi
chown root:sdcard_rw ${CACHE_BACKEND}
chmod 0775 ${CACHE_BACKEND}
if [[ -d ${CACHE_BACKEND} ]]; then
chown root:sdcard_rw ${CACHE_BACKEND}
chmod 0775 ${CACHE_BACKEND}
fi
if [[ ! -L ${RUNTIME_R}/cloud ]]; then
@ -204,8 +212,12 @@ if [[ ! -d ${SD_BINDPOINT} ]] && [[ -e $USER_CONFDIR/.bindsd ]]; then
fi
chown root:sdcard_rw ${SD_BINDPOINT}
chmod 0775 ${SD_BINDPOINT}
if [[ -d ${SD_BINDPOINT} ]]; then
chown root:sdcard_rw ${SD_BINDPOINT}
chmod 0775 ${SD_BINDPOINT}
fi
if [[ -d ${RUNTIME_DEF} ]] && [[ ! -e ${SD_BINDPOINT}/.bound ]] && [[ -e $USER_CONFDIR/.bindsd ]]; then
@ -291,13 +303,17 @@ ${HOME}/rclone listremotes --config ${CONFIGFILE}|cut -f1 -d: |
echo
/sbin/rclone serve http ${CLOUDROOTMOUNTPOINT} --addr ${HTTP_ADDR} --no-checksum --no-modtime --read-only >> /dev/null 2>&1 &
if $(/sbin/rclone serve http ${CLOUDROOTMOUNTPOINT} --addr ${HTTP_ADDR} --no-checksum --no-modtime --read-only >> /dev/null 2>&1 &); then
echo "Notice: /mnt/cloud served via HTTP at: http://${HTTP_ADDR}"
echo "Notice: /mnt/cloud served via HTTP at: http://${HTTP_ADDR}"
/sbin/rclone serve ftp ${CLOUDROOTMOUNTPOINT} --addr ${FTP_ADDR} --no-checksum --no-modtime --read-only >> /dev/null 2>&1 &
fi
echo "Notice: /mnt/cloud served via FTP at: ftp://${FTP_ADDR}"
if $(/sbin/rclone serve ftp ${CLOUDROOTMOUNTPOINT} --addr ${FTP_ADDR} --no-checksum --no-modtime --read-only >> /dev/null 2>&1 &); then
echo "Notice: /mnt/cloud served via FTP at: ftp://${FTP_ADDR}"
fi
echo
echo "...done"

View file

@ -128,7 +128,7 @@ print_modname() {
ui_print "* Magisk Module *"
ui_print "* by: piyushgarg *"
ui_print "*******************************"
ui_print "*rclone: (v1.47.0) mod: (v1.5)*"
ui_print "*rclone: (v1.48.0) mod: (v1.5)*"
ui_print "*******************************"
}
@ -157,8 +157,6 @@ on_install() {
unzip -p "$ZIPFILE" binary/rclone-${ARCH} > $MODPATH/rclone
ui_print "+ Extracting fusermount-$ARCH to $MODPATH/fusermount"
unzip -p "$ZIPFILE" binary/fusermount-${ARCH} > $MODPATH/fusermount
ui_print "+ Extracting rclone-mount script to $MODPATH/rclone-mount"
unzip -p "$ZIPFILE" binary/rclone-mount > $MODPATH/rclone-mount
ui_print "+ Extracting rclone-wrapper.sh script to $MODPATH/rclone-mount"
unzip -p "$ZIPFILE" binary/rclone-wrapper.sh > $MODPATH/rclone-wrapper.sh
}
@ -173,7 +171,6 @@ set_permissions() {
set_perm_recursive $MODPATH 0 0 0755 0644
set_perm $MODPATH/rclone 0 0 0755
set_perm $MODPATH/fusermount 0 0 0755
set_perm $MODPATH/rclone-mount 0 0 0755
set_perm $MODPATH/service.sh 0 0 0500
set_perm $MODPATH/rclone-wrapper.sh 0 0 0500
ln -sf $MODPATH/rclone-wrapper.sh /sbin/rclone
@ -181,8 +178,19 @@ set_permissions() {
ui_print "+ Attempting to mount your [Remotes]:"
ui_print "+ please wait..."
ui_print ""
if [[ -e /sdcard/.rclone.conf ]]; then
export INTERACTIVE=1
$MODPATH/rclone-wrapper.sh remount
else
echo "'/sdcard/.rclone/rclone.conf' not found"
echo "Please run rclone config in su terminal"
fi
# Here are some examples:
# set_perm_recursive $MODPATH/system/lib 0 0 0755 0644
# set_perm $MODPATH/system/bin/app_process32 0 2000 0755 u:object_r:zygote_exec:s0

View file

@ -2,7 +2,7 @@ id=com.piyushgarg.rclone
name=rclone-mount
modVer=1.5
BinVer=1.48
version=rclone: (v1.47.0) mod: (v1.5)
version=rclone: (v1.48.0) mod: (v1.5)
versionCode=105
author=piyushgarg @ github.com
description=Mount cloud storage locally using rclone & fusermount. Virtually limitless storage expansion with support for dozens of cloud providers. Extremely useful for streaming large media files without need for full caching. Binaries obtained directly from rclone.org. Please refer to README.md for more info.