Custom Statup Script not Executing

I am trying to run a custom script when starting the linuxserver/wireguard container. The script called 00-setup-wireguard is placed in a folder named custom-cont-init.d under the the mapped config folder ~/appdata/wireguard/config according to this article. However, it seems that the script is not run when starting the container. Is there something I might have missed and is there someway I can confirm whether or not the script is is executed on startup (e.g. will it show in the log)?

What does your logs show during the container start up?

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 01-envfile: executing...
[cont-init.d] 01-envfile: exited 0.
[cont-init.d] 10-adduser: executing...
usermod: no changes

-------------------------------------
      _         ()
     | |  ___   _    __
     | | / __| | |  /  \
     | | \__ \ | | | () |
     |_| |___/ |_|  \__/


Brought to you by linuxserver.io
-------------------------------------

To support the app dev(s) visit:
WireGuard: https://www.wireguard.com/donations/

To support LSIO projects visit:
https://www.linuxserver.io/donate/
-------------------------------------
GID/UID
-------------------------------------

User uid:    1000
User gid:    1003
-------------------------------------

[cont-init.d] 10-adduser: exited 0.
[cont-init.d] 30-config: executing...
Uname info: Linux 943314c9719e 5.4.0-66-generic #74-Ubuntu SMP Wed Jan 27 22:54:38 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
**** It seems the wireguard module is already active. Skipping kernel header install and module compilation. ****
**** Client mode selected. ****
**** No client conf found. Provide your own client conf as "/config/wg0.conf" and restart the container. ****

I thought maybe I would see something like [custom-cont-init.d] 00-starup-wireguard: executing …

Remove the 00- bits and just give it a normal name. You should be looking out for

[cont-init.d] 99-custom-files: executing... 
[custom-init] no custom files found exiting...
[cont-init.d] 99-custom-files: exited 0.

Within the logs. Also make sure the file is chmod’ed with +x

admin@prototype:~/appdata/wireguard/config/custom-cont-init.d$ sudo chmod +x setup-wireguard
admin@prototype:~/appdata/wireguard/config/custom-cont-init.d$ ll
total 12
drwxrwxr-x 2 admin media 4096 Mar 12 09:13 ./
drwxrwxr-x 5 admin media 4096 Mar 12 08:50 ../
-rwxr-xr-x 1 admin media   98 Mar 11 20:24 setup-wireguard*
admin@prototype:~/appdata/wireguard/config/custom-cont-init.d$

So removed the 00 (I thought perhaps it was convention to use) and made sure it was executable, but still the log is showing the same after startup.

Please post your docker-compose you’re using to deploy the container + also the script (remove any sensitive information though)

This is the docker-compose.yaml I am using.

services:

  wireguard:

    # Container Image
    image: ghcr.io/linuxserver/wireguard

    # Container Name
    container_name: wireguard

    # Adding Container Capabilities
    cap_add:

      # Allow Network Related Operations
      - NET_ADMIN
      # Allow (Un)Load Kernel Modules
      - SYS_MODULE

    # Environment Variables
    environment:

      # User/Group IDs and Timezone
      - PUID=1000
      - PGID=1003
      - TZ=Europe/Oslo

      # VPN Authentication
      - PIA_USER=${PIA_USER}
      - PIA_PASS=${PIA_PASS}

      # Try Connect After Get
      - PIA_AUTOCONNECT=wireguard

    # Mapped Volumes
    volumes:

      # Configuration Directory
      - type: bind
        source: ~/appdata/wireguard/config
        target: /config

      # Linux Kernel Modules Directory
      - type: bind
        source: /lib/modules
        target: /lib/modules

    # Exposed Ports
    ports:

      # Container External Port
      - target: 51820
        published: 51820
        protocol: udp

      # Transmission Container Port (transmission will be attached to this container's network)
      - target: 9091
        published: 9091

    # Linux Kernel Parameters
    sysctls:

      # Set IPv4 and IPv6 Parameters
      - net.ipv4.conf.all.src_valid_mark=1
      - net.ipv6.conf.all.disable_ipv6=1
      - net.ipv6.conf.default.disable_ipv6=1

… and this is the startup script.

echo "Running PIA Get Region and Token script."
cd /config
./get_region_and_token.sh

As you can see I am using the startup script to start another script (also in the /config file) based on this article to use the Wireguard container with PIA VPN.

I do not think it is anything wrong with the scripts themselves because I am able to exec into the container and run the startup-wireguard script manually which seems to work fine.

Try dropping the extension.

Which extension? On the custom-cont-init.d folder?

The one on the script

oh, you mean the ./get_region_and_token.sh script triggered from the startup script? (the startup script itself has no extension).

That did not seem to have any effect. I’m not sure why you think it should though, as the problem is the startup script not running in the first place. Or did I misunderstand you perhaps?

I somehow thought you had a extention om the startup script, sorry for the confusion

ah, no worries :slight_smile: this is puzzling though … I cannot seem to find anyone else having experienced the same issue

Your container never finishes the earlier init step because you didn’t provide a client wg0.conf

The custom init would run later but the container is already going to sleep before then due to missing conf file

Oh, yes you are correct. That was the issue. I just need an initial wg0.conf file :slight_smile: Thanks!

I’m still having some issues with getting the VPN connection up and running, but I’ll make another post on that if I cannot figure it out.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.