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

Auto Execute Startup Scripts

Scheduled Pinned Locked Moved Unsolved Support
6 Posts 3 Posters 1.2k Views 4 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.
    • D Offline
      davedanger
      last edited by 5 Sept 2021, 02:35

      Is there any commands or something that have to be run in the terminal for a script to start at boot? Scripts run fine using $ bash script.sh but when run through crontab, /etc/init.d/script, and the like to start at boot, the scripts don't function properly.

      F 1 Reply Last reply 5 Sept 2021, 19:41 Reply Quote 0
      • F Offline
        flohack @davedanger
        last edited by 5 Sept 2021, 19:41

        @davedanger No because Ubuntu Touch is not like a desktop/server Linux distro. Its mainly centered around using Apps in a heavily confined environment. First of all you should not do anything that needs to make the rootfs writable. ITs readonly so it can be upgraded through imagebased delta upgrades.
        Then, what exactly should this script achieve?

        My languages: πŸ‡¦πŸ‡Ή πŸ‡©πŸ‡ͺ πŸ‡¬πŸ‡§ πŸ‡ΊπŸ‡Έ

        D 1 Reply Last reply 5 Sept 2021, 21:36 Reply Quote 0
        • D Offline
          davedanger @flohack
          last edited by 5 Sept 2021, 21:36

          @flohack It's a vpn auto-connect script

          S 1 Reply Last reply 6 Sept 2021, 06:19 Reply Quote 0
          • S Offline
            sven @davedanger
            last edited by 6 Sept 2021, 06:19

            @davedanger Can you share it here (at least its core)? Maybe someone can help you.

            VollaPhone22 (dual-boot of VollaOS and UT 20.04 OTA-5), Pocophone F1 (pmOS, edge)

            1 Reply Last reply Reply Quote 0
            • S Offline
              sven
              last edited by 6 Sept 2021, 10:58

              You can add upstart scripts in user space. Example: put into .config/upstart/local-init.conf:

              description "run script local-init"
              start on started unity8
              exec /home/phablet/local/bin/local-init
              

              and add your commands into the file given in the exec line.

              VollaPhone22 (dual-boot of VollaOS and UT 20.04 OTA-5), Pocophone F1 (pmOS, edge)

              1 Reply Last reply Reply Quote 1
              • D Offline
                davedanger
                last edited by Keneda 5 Sept 2022, 08:32 6 Sept 2021, 17:17

                The script is:

                #!/bin/bash
                        while [ "true" ]
                        do
                         VPNCON=$(nmcli con status)
                         if [[ $VPNCON != *MyVPNConnectionName* ]]; then
                         echo "Disconnected, trying to reconnect..."
                         (sleep 1s && nmcli con up uuid d******c-d***-4***-b***-3**********4)
                         else
                         echo "Already connected !"
                         fi
                         sleep 30
                         done
                

                The UUID of your personal VPN can be found with: nmcli con

                If I run this script in the terminal with bash script.sh or just copy/paste, it works great. My VPN toggles 'on' automatically, and if I turn off my VPN it toggles itself back 'on' so long as I keep my terminal open. However, if I run the script as any kind of startup script, after I reboot, the VPN will toggle 'on' then 'off' and I get a VPN Failed message. And this will keep happening at whatever duration you have set in the script. This generic script is 30secs, I set my personal one to 5secs and it toggles 'on' fails then toggles 'off' every 5secs.

                1 Reply Last reply Reply Quote 0
                • K Keneda referenced this topic on 9 May 2022, 08:27
                • K Keneda referenced this topic on 9 May 2022, 13:13
                3 out of 6
                • First post
                  3/6
                  Last post