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

    Run script on boot

    Scheduled Pinned Locked Moved Support
    bootscript
    13 Posts 6 Posters 2.6k Views 2 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.
    • dobeyD Offline
      dobey @thrill_seeker
      last edited by

      @thrill_seeker Or maybe it is in ~/.config/upstart/ instead. I don't recall exactly.

      1 Reply Last reply Reply Quote 0
      • E Offline
        Emphrath @thrill_seeker
        last edited by

        @thrill_seeker Oh wow what a nice script ! Could you share this please ?

        T 1 Reply Last reply Reply Quote 0
        • M Offline
          matteo @thrill_seeker
          last edited by

          @thrill_seeker hi, as @dobey said you should write a simple .conf file to be stored in .config/upstart location. The content of the file should be something like the following:

          description "script by yourName"
          
          start on started unity8
          
          respawn
          
          exec /linkToYourScriptLocation/yourScript.sh
          
          

          The above script is meant to be executed at the fist start-up of the device (when unity8 is started). Please notice this is the simplest as possible .conf file to accomplish the only duty of executing your script. To have additional information on the further commands available, you might be interested in reading the Upstart manual you can find on the internet.

          dobeyD 1 Reply Last reply Reply Quote 0
          • dobeyD Offline
            dobey @matteo
            last edited by

            @matteo I would not include respawn there for something only meant to run on boot. Otherwise it will simply keep re-running it I think.

            1 Reply Last reply Reply Quote 1
            • T Offline
              thrill_seeker
              last edited by

              Hi again, I am sorry but I tried exactly what you said and does not work 😞 I think that maybe anbox is started after unity8 as well, and the script may be run before anbox launches?

              I am not really sure, but thank you very much anyway for your time!

              arubislanderA 1 Reply Last reply Reply Quote 0
              • T Offline
                thrill_seeker @Emphrath
                last edited by thrill_seeker

                @Emphrath Of course! Here you have:

                #!/bin/bash
                
                # Set variables
                filelist_dir=/home/phablet/Documents/anbox
                bk_dir=/home/phablet/Documents/anbox/bk
                files_dir=/home/phablet/.local/share/applications
                filelist=list_files.txt
                
                # Delete dir bk if exists and create it again
                rm -rf $bk_dir
                mkdir $bk_dir
                
                # Get string of files to mv from filelist
                files=$(cat $filelist_dir/$filelist)
                
                # Append files_dir to each file
                files_to_mv=$(for file in $files; do echo $files_dir/$file; done)
                
                # Move all files from files_dir into bk_dir
                for file in $files_to_mv; do mv $file $bk_dir; done
                

                This file is called desktop-delete.sh, and reads a file called list_files.txt that contains all apps to hide. In my case, it contains the following (see .local/share/applications for all apps):

                anbox-com-android-inputmethod-latin.desktop
                anbox-com-android-inputmethod-latin.png
                anbox-com-android-calculator2.desktop
                anbox-com-android-calculator2.png
                anbox-com-android-calendar.desktop
                anbox-com-android-calendar.png
                anbox-com-android-contacts.desktop
                anbox-com-android-contacts.png
                anbox-com-android-deskclock.desktop
                anbox-com-android-deskclock.png
                anbox-com-android-documentsui.desktop
                anbox-com-android-documentsui.png
                anbox-com-android-email.desktop
                anbox-com-android-email.png
                anbox-com-android-gallery3d.desktop
                anbox-com-android-gallery3d.png
                anbox-com-android-music.desktop
                anbox-com-android-music.png
                anbox-com-android-settings.desktop
                anbox-com-android-settings.png
                anbox-org-chromium-webview_shell.desktop
                anbox-org-chromium-webview_shell.png
                

                I have both files contained in this path: Documents/anbox. The file delete-desktop.sh should be executable (do chmod a+x Documents/anbox/delete-desktop.sh).

                Having all this, is just a matter of executing the script (./Documents/anbox/delete-desktop.sh) and should work fine!

                E 1 Reply Last reply Reply Quote 0
                • arubislanderA Offline
                  arubislander @thrill_seeker
                  last edited by

                  @thrill_seeker

                  One way to check if the script is run, but then Anbox regenerates the files is to check the timestamp on the files after a reboot. If they are from before the reboot, then your script was not executed for whatever reason. Otherwise, you might be right, in which case you could add a delay (sleep xx) in your upstart job before your script is executed.

                  πŸ‡¦πŸ‡Ό πŸ‡³πŸ‡± πŸ‡ΊπŸ‡Έ πŸ‡ͺπŸ‡Έ
                  Happily running Ubuntu Touch
                  JingPad (24.04-1.x daily)
                  OnePlus Nord N10 5G (24.04-2.x daily)
                  PinePhone OG (20.04)
                  Meizu Pro 5 (16.04 DEV)

                  T 1 Reply Last reply Reply Quote 0
                  • E Offline
                    Emphrath @thrill_seeker
                    last edited by

                    @thrill_seeker awesome ! thx

                    1 Reply Last reply Reply Quote 1
                    • T Offline
                      thrill_seeker @arubislander
                      last edited by

                      @arubislander Good point! I tried it, but to no avail u.u anyway, thank you for the tip!

                      1 Reply Last reply Reply Quote 0
                      • B Offline
                        BigB
                        last edited by BigB

                        What does exacly exec do?

                        I ask, because sh doesn't work for my script like . does.

                        I'm also interested as I want to run VPN on boot and keep it always on.

                        Here are my scrips and other information.

                        Also, what are the nmcli commands that enable cellular data? I tried to find it and I'm run out of ideas.

                        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