What's new

[Rclone] Some problems with chroot debian

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

stebrick

Regular Contributor
If I mount a webdav via Rclone to the Debian's EXT_DIR (see the S99debian script below), everything just works fine and I have no problem seeing the contents inside the chroot. However, if I mount it to its subfolder, says, "debian_sharedfolder/abcwebdav", I cant see the contents so mounted inside chroot at all. I did change chmod 755 for the subfolder and I'm not sure what else is wrong :(

My rclone mounting command is:
Code:
rclone mount abcwebdav:/ /tmp/mnt/sda2/debian_sharedfolder/abcwebdav --cache-dir /tmp --umask 000 --allow-other --vfs-cache-mode writes --allow-non-empty --daemon

The 2nd problem is automount. I cant seem to find a script online that'd do a rclone automount in asuswrt scenario. How should it look like? I believe it's a simple one but I'm not very good in linux. If there's a full script template I'd be much appreciated.


Code:
#!/bin/sh

PATH=/opt/bin:/opt/sbin:/sbin:/bin:/usr/sbin:/usr/bin

# Folder with Debian Bullseye

CHROOT_DIR=/tmp/mnt/sda2/entware/debian

# Some folder outside of sandbox,
# will be mounted to /mnt folder in Debian
# Uncommented "EXT_DIR=" line if you need to
# mount a folder inside debian (remove #)

EXT_DIR=/tmp/mnt/sda2/debian_sharedfolder/

CHROOT_SERVICES_LIST=/opt/etc/chroot-services.list

if [ ! -e "$CHROOT_SERVICES_LIST" ]; then
    echo "Please, define Debian services to start in $CHROOT_SERVICES_LIST first!"
    echo "One service per line. Hint: this is a script names from Debian's /etc/init.d/"
    exit 1
fi

MountedDirCount="$(mount | grep $CHROOT_DIR | wc -l)"

start() {
    if [ $MountedDirCount -gt 0 ]; then
        echo "Chroot'ed services seems to be already started, exiting..."
        exit 1
    fi

    echo "Starting chroot'ed Debian services..."

    for dir in dev proc sys; do
        mount -o bind /$dir $CHROOT_DIR/$dir
    done

    [ -z "$EXT_DIR" ] || mount -o bind $EXT_DIR $CHROOT_DIR/mnt

    for item in $(cat $CHROOT_SERVICES_LIST); do
        chroot $CHROOT_DIR /etc/init.d/$item start
    done
}

stop() {
    if [ $MountedDirCount -eq 0 ]; then
        echo "Chroot'ed services seems to be already stopped, exiting..."
        exit 1
    fi

    echo "Stopping chroot'ed Debian services..."

    for item in $(cat $CHROOT_SERVICES_LIST); do
        chroot $CHROOT_DIR /etc/init.d/$item stop
        sleep 2
    done

    umount /opt/debian/dev/pts

    mount | grep $CHROOT_DIR | awk '{print $3}' | xargs umount -l
}

restart() {
    if [ $MountedDirCount -eq 0 ]; then
        echo "Chroot'ed services seems to be already stopped"
        start
    else
        echo "Stopping chroot'ed Debian services..."

        for item in $(cat $CHROOT_SERVICES_LIST); do
            chroot $CHROOT_DIR /etc/init.d/$item stop
            sleep 2
        done

        mount | grep $CHROOT_DIR | awk '{print $3}' | xargs umount -l

        echo "Restarting chroot'ed Debian services..."

        for dir in dev proc sys; do
            mount -o bind /$dir $CHROOT_DIR/$dir
        done

        [ -z "$EXT_DIR" ] || mount -o bind $EXT_DIR $CHROOT_DIR/mnt

        for item in $(cat $CHROOT_SERVICES_LIST); do
            chroot $CHROOT_DIR /etc/init.d/$item start
        done 
    fi
}

enter() {
    [ -z "$EXT_DIR" ] || mount -o bind $EXT_DIR $CHROOT_DIR/mnt

    mount -o bind /dev/ /opt/debian/dev/
    mount -o bind /dev/pts /opt/debian/dev/pts
    mount -o bind /proc/ /opt/debian/proc/
    mount -o bind /sys/ /opt/debian/sys/

    chroot /opt/debian /bin/bash
}

status() {
    if [ $MountedDirCount -gt 0 ]; then
        echo "Chroot'ed services running..."
    else
        echo "Chroot'ed services not running!"
    fi
}

case "$1" in
start)
    start
    ;;
stop)
    stop
    ;;
restart)
    restart
    ;;
enter)
    enter
    ;;
status)
    status
    ;;
*)
    echo "Usage: (start|stop|restart|enter|status)"
    exit 1
    ;;
esac
echo Done.
exit 0
EOF
 
Last edited:

Similar threads

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top