WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: wireguard on piCore 13  (Read 3135 times)

Offline glennr

  • Newbie
  • *
  • Posts: 14
wireguard on piCore 13
« on: October 06, 2021, 09:22:10 PM »
I'm wanting to get wireguard working on a headless pi running piCore 13 with the intention of using it as a UPS monitoring machine at a remote location.

I have made a tcz package with the required modules using the procedure described here http://forum.tinycorelinux.net/index.php/topic,20692.msg129171.html#msg129171 and I am able to successfully load the wireguard module.

I now need  a setup script and the wireguard tools.
 
tce-ab doesn't find anything related to wireguard so I guess that means I need to build it myself.

Is there an example I can follow for both getting the wireguard tools built into a tcz and for the setup scripts?

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11695
Re: wireguard on piCore 13
« Reply #1 on: October 06, 2021, 10:03:24 PM »
Hi glennr
... Is there an example I can follow for both getting the wireguard tools built into a tcz ...
You can find build notes here:
http://tinycorelinux.net/11.x/x86_64/tcz/src/wireguard/
and here:
http://tinycorelinux.net/10.x/x86/tcz/src/wireguard/

Quote
... and for the setup scripts?
You can download and unpack one of the extensions and look at the included files. There are only 4 of them:
/usr/local/tce.installed/wireguard-tools
/usr/local/bin/stat
/usr/local/bin/wg-quick
/usr/local/bin/wg

The first one is a script. It's possible 1 or 2 of the files in  /usr/local/bin/  are also scripts.

Here are a couple of threads on the subject by GNUser who submitted the extensions and build notes:
http://forum.tinycorelinux.net/index.php/topic,23867.0.html
http://forum.tinycorelinux.net/index.php/topic,23873.0.html
http://forum.tinycorelinux.net/index.php/topic,24677.msg156878.html#msg156878

Offline glennr

  • Newbie
  • *
  • Posts: 14
Re: wireguard on piCore 13
« Reply #2 on: October 06, 2021, 10:17:40 PM »
[Edit: posted this before I saw the previous response, will review after following those suggestions]
[Edit2: after reviewing the above:
The wireguard.ko module is provided in http://www.tinycorelinux.net/13.x/armv6/releases/RPi/src/kernel/5.10.16-piCore_modules.tar.xz and I already have that and its dependencies loading ok.
Building wireguard-tools fails as described below]

Following the instructions here https://www.wireguard.com/compilation/

I've installed bunutils, gcc, make, git, linux-5.10.y_api_headers.tcz, libelf-dev, libmnl-dev, glibc_base-dev.tcz

The asm/socket.h header is missing:

Code: [Select]
$   CC      config.o
In file included from /usr/include/sys/socket.h:33,
                 from /usr/include/netinet/in.h:23,
                 from /usr/include/arpa/inet.h:22,
                 from config.c:6:
/usr/include/bits/socket.h:354:11: fatal error: asm/socket.h: No such file or directory

On raspbian it looks like that file is at
/usr/include/arm-linux-gnueabihf/asm/socket.h
which is provided by linux-libc-dev.

What package provides that file in piCore?
« Last Edit: October 06, 2021, 10:31:20 PM by glennr »

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11695
Re: wireguard on piCore 13
« Reply #3 on: October 06, 2021, 10:38:31 PM »
Hi glennr
According to this:
http://tinycorelinux.net/13.x/armv6/tcz/linux-5.10.y_api_headers.tcz.list
it contains:
usr/include/asm/socket.h

Offline glennr

  • Newbie
  • *
  • Posts: 14
Re: wireguard on piCore 13
« Reply #4 on: October 06, 2021, 10:50:33 PM »
Thanks @Rich
I had installed but forgot to do
tce-load -i linux-5.10.y_api_headers.tcz

It's building now.

Once I have this working can I contribute it back to the project?

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11695
Re: wireguard on piCore 13
« Reply #5 on: October 06, 2021, 11:04:37 PM »
Hi glennr
Instructions for submitting extensions can be found here:
https://web.archive.org/web/20200208152109/http://wiki.tinycorelinux.net/wiki:creating_extensions#submitting

Use the  tcesubmit  email address, not the  picoresubmit  address.

Offline glennr

  • Newbie
  • *
  • Posts: 14
Re: wireguard on piCore 13
« Reply #6 on: October 07, 2021, 12:21:42 AM »
Thanks.

I have it nearly working now, just lacking persistence of the wg config.

Some notes:

After compiling wireguard-tools I made a tcz to install wg and the wg-quick script to /usr/local/bin using the above procedure[1].

The wg-quick script requires bash, /sbin/ip and stat
tce-load -iw bash
tce-load -iw iproute2
tce-load -iw coreutils

I made /etc/wireguard/wg0.conf with an appropriate configuration and brought the link up with

wg-quick up wg0

Now I need to figure out how to persist the /etc/wireguard/* files and sort out the rest of the packaging such as dependencies and documentation, and possibly add an init.d script.

[1] which I would post in this thread if I could but the server gives me a 500 when I try

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11695
Re: wireguard on piCore 13
« Reply #7 on: October 07, 2021, 12:35:35 AM »
Hi glennr
I just downloaded and unpacked  http://tinycorelinux.net/10.x/x86/tcz/wireguard-tools.tcz.
The  tce.installed  script looks like this:
Code: [Select]
tc@E310:~/wg$ cat squashfs-root/usr/local/tce.installed/wireguard-tools
#!/bin/sh

modprobe -a ipv6 wireguard

The extension also contains an empty  /etc/wireguard/  directory.