Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chmod +x $out/etc/init.d/... not working #51

Open
GrumpyMeow opened this issue Dec 30, 2024 · 0 comments
Open

chmod +x $out/etc/init.d/... not working #51

GrumpyMeow opened this issue Dec 30, 2024 · 0 comments

Comments

@GrumpyMeow
Copy link

GrumpyMeow commented Dec 30, 2024

With this perfect, great builder i'm able to initialize, upgrade and provision my router and access points in a matter of minutes. I love it!
I've created a dozen of nix-files which results in installing packages and provisioning uci-defaults files to do all the configuration.
For each OpenWRT-device i do some concatenation like:

        ...
        luci = import ../../modules/openwrt/luci.nix;
        wpad = import ../../modules/openwrt/wpad.nix;
        iperf3 = import ../../modules/openwrt/iperf3.nix;
        watchcat = import ../../modules/openwrt/watchcat.nix;

        config = profiles.identifyProfile "ubnt_unifiac-mesh" // {

          packages = unregulatory.packages ++ zabbix_agentd.packages ++ ttyd.packages ++ usteer.packages ++ dropbear.packages ++ dumbap.packages ++ 
                     luci.packages ++ watchcat.packages ++ wpad.packages ++ iperf3.packages ++ [
            "nano"
          ];
          release = vars.openwrt.release;
          target = "ath79";
          variant = "generic";
          profile = "ubnt_unifiac-mesh";
          EXTRA_IMAGE_NAME = "ap-buiten";
          disabledServices = [ "dnsmasq" "firewall" "odhcpd" ];

          files = pkgs.runCommand "image-files" { } ''

            ${dumbap.snippet}
            ${iperf3.snippet}
            ${luci.snippet}
            ...

One small issue i seem to be running into is that i seem to be unable to get provisioned files to have the executable flag set in the resulting sysupgrade image.
Given the below nix-file which is to enable iperf3 running as a service on all my OpenWRT devices which i have Zabbix configured to test on a regular basis. It exposes a combination of packages and snippet which get concatenated with other nix-files (see the snippet above).

In this specific nix-file i write a service-definition file $out/etc/init.d/iperf3 which needs to be executable. If i add an instruction to add the executable flag on this file, the flag seems to get lost somewhere. I can imagine that this happens during the copying of files to the image.
I can workaround the issue by adding the executable flag from within a uci-defaults file. Which is not a problem, but is not as "clean" as it could be.

let
in
{
  packages = [ "iperf3" ];
  
  snippet = ''
    mkdir -p $out/etc/uci-defaults

    cat > $out/etc/uci-defaults/96-iperf3 <<EOF
     chmod +x /etc/init.d/iperf3       <=== this action does work
     /etc/init.d/iperf3 enable
     /etc/init.d/iperf3 start
EOF

    mkdir -p $out/etc/init.d

    cat > $out/etc/init.d/iperf3 <<EOF
#!/bin/sh /etc/rc.common
# Copyright (C) 2008-2011 OpenWrt.org
START=60
USE_PROCD=1
PROG=/usr/bin/iperf3
start_service() {
    procd_open_instance
    procd_set_param command /usr/bin/iperf3 -s -D
    procd_set_param respawn
    procd_set_param stdout 1
    procd_set_param stderr 1
    procd_close_instance
}

EOF

     chmod +x $out/etc/init.d/iperf3         <=== this action does not work
  '';
}

Is this an issue which might be resolved?

I think i see the same issue when looking at the uci-defaults file in /rom/etc/uci-defaults:
image
This as my custom uci-defaults files are not executable while the OpenWRT ones are.

thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant