UBports Robot Logo UBports Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    SystemD service to auto-mount the Waydroid folder on UT side

    Scheduled Pinned Locked Moved Waydroid
    2 Posts 1 Posters 351 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • SentinelS Offline
      Sentinel
      last edited by Sentinel

      @projectmoon said in Smooth Edges (name pending) - Let's Fix the Bugs That Drive You Mad:

      @Sentinel said:

      Lack of easy access to Waydroid files (and Waydroid not having easy access to any UT files) is kind of a big issue. I've created a SystemD service to auto-mount the Waydroid folder on UT side, but most people won't be able to do that.

      Could you share that system unit in another topic maybe? 😄

      I'm embarrassed to make a thread for such a small thing, especially as I'm sure other people must have done better jobs than my quick hack. But since you asked, here are the contents of the files I created to do this:

      phablet@ubuntu-phablet:~$ ll /etc/systemd/system/autostart.service /home/phablet/.autostart /home/phablet/Scripts/Mount_WaydroidHome.sh
      -rw-r--r-- 1 root    root    156 Oct 22 22:24 /etc/systemd/system/autostart.service
      -rw-r--r-- 1 phablet phablet  57 Oct 22 22:29 /home/phablet/.autostart
      -rwxrw-r-- 1 phablet phablet 243 Dec 13 18:53 /home/phablet/Scripts/Mount_WaydroidHome.sh*
      phablet@ubuntu-phablet:~$ cat /etc/systemd/system/autostart.service
      [Unit]
      Description=Autostart user-defined script on boot
      
      [Service]
      ExecStart=/usr/bin/bash /home/phablet/.autostart
      
      [Install]
      WantedBy=multi-user.target
      
      phablet@ubuntu-phablet:~$ cat /home/phablet/.autostart
      #!/bin/bash
      /home/phablet/Scripts/Mount_WaydroidHome.sh
      
      phablet@ubuntu-phablet:~$ cat /home/phablet/Scripts/Mount_WaydroidHome.sh
      #!/bin/bash
      #mkdir ~/WaydroidHome
      #chmod 755 ~/WaydroidHome
      #sudo chmod 777 ~/.local/share/waydroid/data/media/0
      /usr/bin/mount --bind /home/phablet/.local/share/waydroid/data/media/0 /home/phablet/WaydroidHome
      while /usr/bin/true; do
              /usr/bin/sleep 5
              if [[ ! "$(/usr/bin/stat -c "%a" /home/phablet/WaydroidHome)" == *5 ]]; then
                      /usr/bin/chmod o+rx /home/phablet/WaydroidHome
              fi
      done
      

      EDIT #2: The above "Mount_WaydroidHome.sh" script has been updated to work-around a problem.

      I'm intentionally not providing precise instructions on how to install these files, because if you don't know enough to do that, then you probably shouldn't be messing about with this stuff in the first place.

      But as the #comments of the last script hint, you need to run these commands once before it will work:

      mkdir ~/WaydroidHome
      chmod 755 ~/WaydroidHome
      sudo chmod 777 ~/.local/share/waydroid/data/media/0
      

      WARNING: The above scripts work for me, but I haven't tested it thoroughly, or even for that long, and it may contain security flaws. It is (as I said before) just a 'quick hack'. In the spirit of open source, I hope other people will provide improvements to it.

      THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

      SentinelS 1 Reply Last reply Reply Quote 0
      • SentinelS Offline
        Sentinel @Sentinel
        last edited by

        I've updated the "Mount_WaydroidHome.sh" script, so the WaydroidHome folder is writable from Ubuntu Touch (without using sudo):

        #!/bin/bash
        ## Set-up commands
        #mkdir ~/WaydroidHome
        #chmod 755 ~/WaydroidHome
        #sudo chmod 777 ~/.local/share/waydroid/data/media/0
        
        ## Bind mount Waydroid's home folder if it's not already mounted, and then ensure it (and all sub-folders) stay read/write-able by the Ubuntu Touch user
        set -e
        /usr/bin/findmnt -rno SOURCE,TARGET /home/phablet/WaydroidHome >/dev/null || /usr/bin/mount --bind /home/phablet/.local/share/waydroid/data/media/0 /home/phablet/WaydroidHome
        while /usr/bin/true; do
                /usr/bin/sleep 5
                if [[ ! "$(/usr/bin/stat -c "%a" /home/phablet/WaydroidHome)" == *7 ]]; then
                        /usr/bin/find /home/phablet/WaydroidHome -type d ! -perm -o+rwx -print0 | /usr/bin/xargs -0 -I {} /usr/bin/chmod o+rwx '{}'
                fi
        done
        

        WARNING: The above scripts work for me, but I haven't tested it thoroughly, or even for that long, and it may contain security flaws. It is (as I said before) just a 'quick hack'. In the spirit of open source, I hope other people will provide improvements to it.

        1 Reply Last reply Reply Quote 0

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • First post
          Last post