5

How do I make a HTTPS (or HTTP) request in Ubuntu Core? The curl and wget are unavailable (and I don't know of any alternatives).

I am trying to update the DtDns with this line: https://www.dtdns.com/api/autodns.cfm?<options>

--

Edit
Wasn't able to find any quick'n'easy solution therefore took a longer detour and learned about creating snaps with snapcraft (in classic mode). Then simply included curl in the snap along with my bash script. Here is an excerpt from my snap.yaml:

apps:
  my-app:
    command: my-app.sh
    daemon: simple
    restart-condition: always

parts:
  client:
    plugin: dump
    source: my-app-src/
    stage-packages: 
      - curl

A good starting point: How to build a snap – tutorial.

Maciek Rek
  • 1,525
  • 2
  • 14
  • 18

2 Answers2

7

You should install the classic snap, which allows you to use tools like curl and wget. From the developer tools page:

$ snap install classic --edge --devmode

Then get into the classic shell (allowing you to use apt):

$ sudo classic
kyrofa
  • 1,759
  • 1
  • 14
  • 19
  • 1
    how true are the warnings that the snap will break security provisions of the normal system? – Florian Heigl Jun 04 '20 at 21:02
  • Yes you can but... one of the reasons I went for Ubuntu Core was security, so running the device in the `classic` mode wouldn’t make much sense as it is much easier to just use a more ‘normal' os with apt-get and so on, such as Ubuntu Server. I understand `classic` mode is meant for development. – Maciek Rek Jun 05 '20 at 09:18
  • The classic snap is essentially a chroot. It does include all sorts of software you wouldn't want on a production device, but once you remove it it's gone. It doesn't make system-wide modifications to the length of my knowledge. – kyrofa Jun 05 '20 at 15:51
4

I'm not 100% sure it's in Ubuntu Core, but a very fundamental and common program is netcat, for sending arbitrary data over TCP or UDP. See:

Asking a HTTP GET request with netcat

here on the site.

einpoklum
  • 118,144
  • 57
  • 340
  • 684
  • Yes, the nc exist in Core though I'm struggling with the syntax of the multiline request in my script lol, thanks – Maciek Rek Feb 18 '18 at 16:28