How do I run uci commands in a .sh executable?

I'm trying to create a custom docker image for tor-enabled OpenWrt (It's a modification of Oofnikj's solution ), and found that I needed to run the configuration commands with a .sh file to get the cat command to work right. However, whenever the process that builds the image gets to a uci command, I get an error that says:

/etc/tor/torconf.sh: line14: can't create /etc/sysupgrade.conf: interrupted system call
The command '/bin/sh -c sh /etc/tor/torconf.sh' returned a non-zero code: 1
make: *** [Makefile:7: build] Error 1

all the code in the file torconf.sh is pulled directly from that wiki page, and oofnik's image is modified to copy that file into the container then run it to set up the tor client. so What am i doing wrong?

I'm not familiar w/ making docker images, but...

for 'can't create /etc/sysupgrade.conf' maybe /etc doesn't exist or more likely the process doesn't have write permission to /etc/

can you do it step by step manually and test the torconf.sh script to see the problem directly?

how would i go about running it step by step by step? just run each command in the docker file?

also i am no longer getting the sysupgrade error, but im still unable to run the shell file. basically the first line is now gone, but the last two lines of the error remain.

Something like that. Maybe build the docker without the tor stuff. Then ssh to it and run the tor script manually and see where it errors out.

For your original question running uci in a Bash script (.sh). You just put the uci command you would type in the script. For, the sections in the Tor Client page you could just copy to a file tor1.sh, make it executable chmod +x tor1.sh and then run it ./tor1.sh
For another example of uci commands in a script, see tyrekick.sh

You should first start a shell in the container and test the commands, but I'm 99% sure that the container has no access to the files.

That's what I did, and after testing it with shellcheck there weren't any errors. but trying to run it in the docker container just doesn't work.

Here's the terminal output that i got from the latest attempted fix

./build.sh
--2022-09-27 20:02:55--  https://downloads.openwrt.org/snapshots/targets/armvirt/64/openwrt-armvirt-64-default-rootfs.tar.gz
Resolving downloads.openwrt.org (downloads.openwrt.org)... 168.119.138.211, 2a01:4f8:251:321::2
Connecting to downloads.openwrt.org (downloads.openwrt.org)|168.119.138.211|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3627720 (3.5M) [application/octet-stream]
Saving to: ‘rootfs.tar.gz’

rootfs.tar.gz        100%[======================>]   3.46M   670KB/s    in 5.3s    

2022-09-27 20:03:01 (670 KB/s) - ‘rootfs.tar.gz’ saved [3627720/3627720]

--2022-09-27 20:03:01--  https://downloads.openwrt.org/snapshots/targets/armvirt/64/version.buildinfo
Resolving downloads.openwrt.org (downloads.openwrt.org)... 168.119.138.211, 2a01:4f8:251:321::2
Connecting to downloads.openwrt.org (downloads.openwrt.org)|168.119.138.211|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 18 [text/plain]
Saving to: ‘version.buildinfo’

version.buildinfo    100%[======================>]      18  --.-KB/s    in 0s      

2022-09-27 20:03:02 (2.44 MB/s) - ‘version.buildinfo’ saved [18/18]

Sending build context to Docker daemon  3.785MB
Step 1/19 : FROM scratch
 ---> 
Step 2/19 : USER root
 ---> Using cache
 ---> d428bf124178
Step 3/19 : ADD rootfs.tar.gz /
 ---> Using cache
 ---> 91e55a1350ff
Step 4/19 : RUN mkdir -p /var/lock
 ---> Using cache
 ---> e2bfdb2d332d
Step 5/19 : RUN opkg remove --force-depends 		dnsmasq* 		wpad* 		iw* &&     opkg update &&     opkg install luci     	bash 		wpad-wolfssl 		iw-full 		ip-full 		kmod-mac80211 		dnsmasq-full 		iptables-mod-checksum 		tor 		iptables-mod-extra
 ---> Running in 7d65045c90e5
Removing package dnsmasq from root...
Failed to connect to ubus
Downloading https://downloads.openwrt.org/snapshots/targets/armvirt/64/packages/Packages.gz
Updated list of available packages in /var/opkg-lists/openwrt_core
Downloading https://downloads.openwrt.org/snapshots/targets/armvirt/64/packages/Packages.sig
Signature check passed.
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/base/Packages.gz
Updated list of available packages in /var/opkg-lists/openwrt_base
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/base/Packages.sig
Signature check passed.
Downloading https://downloads.openwrt.org/snapshots/targets/armvirt/64/kmods/5.15.69-1-933e1624111388a2bba909a95b1d2302/Packages.gz
Updated list of available packages in /var/opkg-lists/openwrt_kmods
Downloading https://downloads.openwrt.org/snapshots/targets/armvirt/64/kmods/5.15.69-1-933e1624111388a2bba909a95b1d2302/Packages.sig
Signature check passed.
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/luci/Packages.gz
Updated list of available packages in /var/opkg-lists/openwrt_luci
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/luci/Packages.sig
Signature check passed.
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/packages/Packages.gz
Updated list of available packages in /var/opkg-lists/openwrt_packages
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/packages/Packages.sig
Signature check passed.
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/routing/Packages.gz
Updated list of available packages in /var/opkg-lists/openwrt_routing
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/routing/Packages.sig
Signature check passed.
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/telephony/Packages.gz
Updated list of available packages in /var/opkg-lists/openwrt_telephony
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/telephony/Packages.sig
Signature check passed.
Installing luci (git-20.074.84698-ead5e81) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/luci/luci_git-20.074.84698-ead5e81_all.ipk
Installing uhttpd (2022-08-12-e3395cd9-1) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/base/uhttpd_2022-08-12-e3395cd9-1_aarch64_cortex-a53.ipk
Installing uhttpd-mod-ubus (2022-08-12-e3395cd9-1) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/base/uhttpd-mod-ubus_2022-08-12-e3395cd9-1_aarch64_cortex-a53.ipk
Installing liblua5.1.5 (5.1.5-10) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/base/liblua5.1.5_5.1.5-10_aarch64_cortex-a53.ipk
Installing lua (5.1.5-10) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/base/lua_5.1.5-10_aarch64_cortex-a53.ipk
Installing luci-lib-nixio (git-22.222.71555-88b9088) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/luci/luci-lib-nixio_git-22.222.71555-88b9088_aarch64_cortex-a53.ipk
Installing luci-lib-ip (git-20.250.76529-62505bd) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/luci/luci-lib-ip_git-20.250.76529-62505bd_aarch64_cortex-a53.ipk
Installing rpcd (2022-09-12-e80d0b2d-1) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/base/rpcd_2022-09-12-e80d0b2d-1_aarch64_cortex-a53.ipk
Installing libubus-lua (2022-06-01-2bebf93c-1) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/base/libubus-lua_2022-06-01-2bebf93c-1_aarch64_cortex-a53.ipk
Installing luci-lib-jsonc (git-22.079.54693-45f411b) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/luci/luci-lib-jsonc_git-22.079.54693-45f411b_aarch64_cortex-a53.ipk
Installing liblucihttp0 (2022-07-08-6e68a106-1) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/luci/liblucihttp0_2022-07-08-6e68a106-1_aarch64_cortex-a53.ipk
Installing liblucihttp-lua (2022-07-08-6e68a106-1) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/luci/liblucihttp-lua_2022-07-08-6e68a106-1_aarch64_cortex-a53.ipk
Installing luci-lib-base (git-20.232.39649-1f6dc29) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/luci/luci-lib-base_git-20.232.39649-1f6dc29_all.ipk
Installing rpcd-mod-file (2022-09-12-e80d0b2d-1) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/base/rpcd-mod-file_2022-09-12-e80d0b2d-1_aarch64_cortex-a53.ipk
Installing rpcd-mod-luci (20210614) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/luci/rpcd-mod-luci_20210614_aarch64_cortex-a53.ipk
Installing cgi-io (2022-08-10-901b0f04-21) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/packages/cgi-io_2022-08-10-901b0f04-21_aarch64_cortex-a53.ipk
Installing luci-base (git-22.260.19132-34dd31a) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/luci/luci-base_git-22.260.19132-34dd31a_aarch64_cortex-a53.ipk
Installing libiwinfo-data (2022-09-22-4a43b0d4-1) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/base/libiwinfo-data_2022-09-22-4a43b0d4-1_aarch64_cortex-a53.ipk
Installing libiwinfo20210430 (2022-09-22-4a43b0d4-1) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/base/libiwinfo20210430_2022-09-22-4a43b0d4-1_aarch64_cortex-a53.ipk
Installing libiwinfo-lua (2022-09-22-4a43b0d4-1) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/base/libiwinfo-lua_2022-09-22-4a43b0d4-1_aarch64_cortex-a53.ipk
Installing luci-mod-status (git-22.261.29474-6a03a88) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/luci/luci-mod-status_git-22.261.29474-6a03a88_aarch64_cortex-a53.ipk
Installing luci-mod-system (git-22.264.46061-944b557) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/luci/luci-mod-system_git-22.264.46061-944b557_all.ipk
Installing rpcd-mod-iwinfo (2022-09-12-e80d0b2d-1) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/base/rpcd-mod-iwinfo_2022-09-12-e80d0b2d-1_aarch64_cortex-a53.ipk
Installing luci-mod-network (git-22.244.54536-2c3c7f5) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/luci/luci-mod-network_git-22.244.54536-2c3c7f5_all.ipk
Installing luci-mod-admin-full (git-19.253.48496-3f93650) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/luci/luci-mod-admin-full_git-19.253.48496-3f93650_all.ipk
Installing luci-theme-bootstrap (git-22.175.85350-d4c4afe) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/luci/luci-theme-bootstrap_git-22.175.85350-d4c4afe_all.ipk
Installing luci-app-firewall (git-22.089.67453-0eb3aeb) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/luci/luci-app-firewall_git-22.089.67453-0eb3aeb_all.ipk
Installing luci-app-opkg (git-22.213.50348-43cea79) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/luci/luci-app-opkg_git-22.213.50348-43cea79_all.ipk
Installing luci-proto-ppp (git-21.158.38888-88b9d84) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/luci/luci-proto-ppp_git-21.158.38888-88b9d84_all.ipk
Installing luci-proto-ipv6 (git-21.148.48881-79947af) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/luci/luci-proto-ipv6_git-21.148.48881-79947af_all.ipk
Installing rpcd-mod-rrdns (20170710) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/luci/rpcd-mod-rrdns_20170710_aarch64_cortex-a53.ipk
Installing bash (5.1.16-1) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/packages/bash_5.1.16-1_aarch64_cortex-a53.ipk
Installing terminfo (6.3-1) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/base/terminfo_6.3-1_aarch64_cortex-a53.ipk
Installing libncurses6 (6.3-1) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/base/libncurses6_6.3-1_aarch64_cortex-a53.ipk
Installing libreadline8 (8.1.2-1) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/base/libreadline8_8.1.2-1_aarch64_cortex-a53.ipk
Installing wpad-wolfssl (2022-07-29-b704dc72-3) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/base/wpad-wolfssl_2022-07-29-b704dc72-3_aarch64_cortex-a53.ipk
Installing hostapd-common (2022-07-29-b704dc72-3) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/base/hostapd-common_2022-07-29-b704dc72-3_aarch64_cortex-a53.ipk
Installing iw-full (5.19-1) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/base/iw-full_5.19-1_aarch64_cortex-a53.ipk
Installing ip-full (5.19.0-5) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/base/ip-full_5.19.0-5_aarch64_cortex-a53.ipk
Installing zlib (1.2.12-4) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/base/zlib_1.2.12-4_aarch64_cortex-a53.ipk
Installing libelf1 (0.187-1) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/base/libelf1_0.187-1_aarch64_cortex-a53.ipk
Installing libbpf20220308 (2022-03-08-04c465fd-1) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/base/libbpf20220308_2022-03-08-04c465fd-1_aarch64_cortex-a53.ipk
Installing kmod-mac80211 (5.15.69+5.15.58-1-2) to root...
Downloading https://downloads.openwrt.org/snapshots/targets/armvirt/64/kmods/5.15.69-1-933e1624111388a2bba909a95b1d2302/kmod-mac80211_5.15.69%2b5.15.58-1-2_aarch64_cortex-a53.ipk
Installing iwinfo (2022-09-22-4a43b0d4-1) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/base/iwinfo_2022-09-22-4a43b0d4-1_aarch64_cortex-a53.ipk
Installing wireless-regdb (2022.08.12-1) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/base/wireless-regdb_2022.08.12-1_all.ipk
Installing kmod-cfg80211 (5.15.69+5.15.58-1-2) to root...
Downloading https://downloads.openwrt.org/snapshots/targets/armvirt/64/kmods/5.15.69-1-933e1624111388a2bba909a95b1d2302/kmod-cfg80211_5.15.69%2b5.15.58-1-2_aarch64_cortex-a53.ipk
Installing kmod-crypto-cmac (5.15.69-1) to root...
Downloading https://downloads.openwrt.org/snapshots/targets/armvirt/64/kmods/5.15.69-1-933e1624111388a2bba909a95b1d2302/kmod-crypto-cmac_5.15.69-1_aarch64_cortex-a53.ipk
Installing kmod-crypto-null (5.15.69-1) to root...
Downloading https://downloads.openwrt.org/snapshots/targets/armvirt/64/kmods/5.15.69-1-933e1624111388a2bba909a95b1d2302/kmod-crypto-null_5.15.69-1_aarch64_cortex-a53.ipk
Installing kmod-crypto-aead (5.15.69-1) to root...
Downloading https://downloads.openwrt.org/snapshots/targets/armvirt/64/kmods/5.15.69-1-933e1624111388a2bba909a95b1d2302/kmod-crypto-aead_5.15.69-1_aarch64_cortex-a53.ipk
Installing kmod-crypto-manager (5.15.69-1) to root...
Downloading https://downloads.openwrt.org/snapshots/targets/armvirt/64/kmods/5.15.69-1-933e1624111388a2bba909a95b1d2302/kmod-crypto-manager_5.15.69-1_aarch64_cortex-a53.ipk
Installing kmod-crypto-hmac (5.15.69-1) to root...
Downloading https://downloads.openwrt.org/snapshots/targets/armvirt/64/kmods/5.15.69-1-933e1624111388a2bba909a95b1d2302/kmod-crypto-hmac_5.15.69-1_aarch64_cortex-a53.ipk
Installing kmod-crypto-sha256 (5.15.69-1) to root...
Downloading https://downloads.openwrt.org/snapshots/targets/armvirt/64/kmods/5.15.69-1-933e1624111388a2bba909a95b1d2302/kmod-crypto-sha256_5.15.69-1_aarch64_cortex-a53.ipk
Installing kmod-crypto-rng (5.15.69-1) to root...
Downloading https://downloads.openwrt.org/snapshots/targets/armvirt/64/kmods/5.15.69-1-933e1624111388a2bba909a95b1d2302/kmod-crypto-rng_5.15.69-1_aarch64_cortex-a53.ipk
Installing kmod-crypto-seqiv (5.15.69-1) to root...
Downloading https://downloads.openwrt.org/snapshots/targets/armvirt/64/kmods/5.15.69-1-933e1624111388a2bba909a95b1d2302/kmod-crypto-seqiv_5.15.69-1_aarch64_cortex-a53.ipk
Installing kmod-crypto-ctr (5.15.69-1) to root...
Downloading https://downloads.openwrt.org/snapshots/targets/armvirt/64/kmods/5.15.69-1-933e1624111388a2bba909a95b1d2302/kmod-crypto-ctr_5.15.69-1_aarch64_cortex-a53.ipk
Installing kmod-crypto-ccm (5.15.69-1) to root...
Downloading https://downloads.openwrt.org/snapshots/targets/armvirt/64/kmods/5.15.69-1-933e1624111388a2bba909a95b1d2302/kmod-crypto-ccm_5.15.69-1_aarch64_cortex-a53.ipk
Installing kmod-crypto-gf128 (5.15.69-1) to root...
Downloading https://downloads.openwrt.org/snapshots/targets/armvirt/64/kmods/5.15.69-1-933e1624111388a2bba909a95b1d2302/kmod-crypto-gf128_5.15.69-1_aarch64_cortex-a53.ipk
Installing kmod-crypto-ghash (5.15.69-1) to root...
Downloading https://downloads.openwrt.org/snapshots/targets/armvirt/64/kmods/5.15.69-1-933e1624111388a2bba909a95b1d2302/kmod-crypto-ghash_5.15.69-1_aarch64_cortex-a53.ipk
Installing kmod-crypto-gcm (5.15.69-1) to root...
Downloading https://downloads.openwrt.org/snapshots/targets/armvirt/64/kmods/5.15.69-1-933e1624111388a2bba909a95b1d2302/kmod-crypto-gcm_5.15.69-1_aarch64_cortex-a53.ipk
Installing dnsmasq-full (2.86-14) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/base/dnsmasq-full_2.86-14_aarch64_cortex-a53.ipk
Installing libgmp10 (6.2.1-1) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/base/libgmp10_6.2.1-1_aarch64_cortex-a53.ipk
Installing libnettle8 (3.8.1-2) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/base/libnettle8_3.8.1-2_aarch64_cortex-a53.ipk
Installing kmod-nf-ipt (5.15.69-1) to root...
Downloading https://downloads.openwrt.org/snapshots/targets/armvirt/64/kmods/5.15.69-1-933e1624111388a2bba909a95b1d2302/kmod-nf-ipt_5.15.69-1_aarch64_cortex-a53.ipk
Installing kmod-ipt-core (5.15.69-1) to root...
Downloading https://downloads.openwrt.org/snapshots/targets/armvirt/64/kmods/5.15.69-1-933e1624111388a2bba909a95b1d2302/kmod-ipt-core_5.15.69-1_aarch64_cortex-a53.ipk
Installing kmod-ipt-ipset (5.15.69-1) to root...
Downloading https://downloads.openwrt.org/snapshots/targets/armvirt/64/kmods/5.15.69-1-933e1624111388a2bba909a95b1d2302/kmod-ipt-ipset_5.15.69-1_aarch64_cortex-a53.ipk
Installing libnfnetlink0 (1.0.2-1) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/base/libnfnetlink0_1.0.2-1_aarch64_cortex-a53.ipk
Installing kmod-nf-conntrack-netlink (5.15.69-1) to root...
Downloading https://downloads.openwrt.org/snapshots/targets/armvirt/64/kmods/5.15.69-1-933e1624111388a2bba909a95b1d2302/kmod-nf-conntrack-netlink_5.15.69-1_aarch64_cortex-a53.ipk
Installing libnetfilter-conntrack3 (1.0.9-2) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/base/libnetfilter-conntrack3_1.0.9-2_aarch64_cortex-a53.ipk
Installing iptables-mod-checksum (1.8.8-1) to root...
Downloading https://downloads.openwrt.org/snapshots/targets/armvirt/64/packages/iptables-mod-checksum_1.8.8-1_aarch64_cortex-a53.ipk
Installing libxtables12 (1.8.8-1) to root...
Downloading https://downloads.openwrt.org/snapshots/targets/armvirt/64/packages/libxtables12_1.8.8-1_aarch64_cortex-a53.ipk
Installing kmod-ipt-checksum (5.15.69-1) to root...
Downloading https://downloads.openwrt.org/snapshots/targets/armvirt/64/kmods/5.15.69-1-933e1624111388a2bba909a95b1d2302/kmod-ipt-checksum_5.15.69-1_aarch64_cortex-a53.ipk
Installing tor (0.4.7.8-1) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/packages/tor_0.4.7.8-1_aarch64_cortex-a53.ipk
Installing libevent2-7 (2.1.12-1) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/base/libevent2-7_2.1.12-1_aarch64_cortex-a53.ipk
Installing libopenssl1.1 (1.1.1q-1) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/base/libopenssl1.1_1.1.1q-1_aarch64_cortex-a53.ipk
Installing libcap (2.65-3) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/base/libcap_2.65-3_aarch64_cortex-a53.ipk
Installing iptables-mod-extra (1.8.8-1) to root...
Downloading https://downloads.openwrt.org/snapshots/targets/armvirt/64/packages/iptables-mod-extra_1.8.8-1_aarch64_cortex-a53.ipk
Installing Failed to connect to ubus
kmod-ipt-extra (5.15.69-1) to root...
Downloading https://downloads.openwrt.org/snapshots/targets/armvirt/64/kmods/5.15.69-1-933e1624111388a2bba909a95b1d2302/kmod-ipt-extra_5.15.69-1_aarch64_cortex-a53.ipk
Configuring terminfo.
Configuring libiwinfo-data.
Configuring libiwinfo20210430.
Configuring iwinfo.
Configuring liblucihttp0.
Configuring cgi-io.
Configuring liblua5.1.5.
Configuring lua.
Configuring luci-lib-nixio.
Configuring luci-lib-ip.
Configuring luci-lib-jsonc.
Configuring liblucihttp-lua.
Configuring luci-lib-base.
Configuring kmod-crypto-gf128.
Configuring libxtables12.
Configuring kmod-nf-ipt.
Configuring kmod-ipt-core.
Configuring kmod-ipt-extra.
Configuring iptables-mod-extra.
Configuring luci-app-opkg.
Configuring kmod-crypto-null.
Configuring kmod-crypto-aead.
Configuring kmod-crypto-manager.
Configuring rpcd.
Configuring kmod-crypto-hmac.
Configuring kmod-crypto-sha256.
Configuring kmod-crypto-rng.
Configuring kmod-crypto-seqiv.
Configuring kmod-crypto-ctr.
Configuring zlib.
Configuring libelf1Failed to connect to ubus
Failed to connect to ubus
Failed to connect to ubus
/luci-static/bootstrap
Failed to connect to ubus
Failed to connect to ubus
.
Configuring libbpf20220308.
Configuring ip-full.
Configuring libubus-lua.
Configuring libiwinfo-lua.
Configuring libncurses6.
Configuring libreadline8.
Configuring bash.
Configuring rpcd-mod-file.
Configuring rpcd-mod-luci.
Configuring luci-base.
Configuring luci-mod-system.
Configuring luci-theme-bootstrap.
Configuring iw-full.
Configuring libcap.
Configuring libnfnetlink0.
Configuring kmod-nf-conntrack-netlink.
Configuring libnetfilter-conntrack3.
Configuring luci-mod-status.
Configuring luci-app-firewall.
Configuring kmod-ipt-checksum.
Configuring kmod-crypto-ghash.
Configuring libgmp10.
Configuring kmod-crypto-ccm.
Configuring luci-proto-ppp.
Configuring rpcd-mod-iwinfo.
Configuring luci-mod-network.
Configuring luci-mod-admin-full.
Configuring libnettle8.
Configuring wireless-regdb.
Configuring kmod-cfg80211.
Configuring kmod-crypto-cmac.
Configuring kmod-crypto-gcm.
Configuring hostapd-common.
Configuring kmod-mac80211.
Configuring libopenssl1.1.
Configuring luci-proto-ipv6.
Configuring iptables-mod-checksum4+0 records in
4+0 records out
Failed to connect to ubus
Failed to connect to ubus
4+0 records in
4+0 records out
Failed to connect to ubus
Failed to connect to ubus
touch: /tmp/resolv.conf.d/resolv.conf.auto: No such file or directory
Failed to connect to ubus
Failed to connect to ubus
Failed to connect to ubus
.
Configuring kmod-ipt-ipset.
Configuring uhttpd.
Configuring libevent2-7.
Configuring tor.
Configuring uhttpd-mod-ubus.
Configuring rpcd-mod-rrdns.
Configuring luci.
Configuring wpad-wolfssl.
Configuring dnsmasq-full.
Removing intermediate container 7d65045c90e5
 ---> 9946f3674529
Step 6/19 : RUN cd /etc/tor
 ---> Running in 1861f15a44e5
Removing intermediate container 1861f15a44e5
 ---> c2c7ac73e461
Step 7/19 : COPY torconf.sh /etc/tor
 ---> 6b5c2cd3d585
Step 8/19 : RUN opkg list-upgradable | awk '{print $1}' | xargs opkg upgrade || true
 ---> Running in 6ac79293a55c
opkg: the ``upgrade'' command requires at least one argument
usage: opkg [options...] sub-command [arguments...]
where sub-command is one of:

Package Manipulation:
	update			Update list of available packages
	upgrade <pkgs>		Upgrade packages
	install <pkgs>		Install package(s)
	configure <pkgs>	Configure unpacked package(s)
	remove <pkgs|regexp>	Remove package(s)
	flag <flag> <pkgs>	Flag package(s)
	 <flag>=hold|noprune|user|ok|installed|unpacked (one per invocation)

Informational Commands:
	list			List available packages
	list-installed		List installed packages
	list-upgradable		List installed and upgradable packages
	list-changed-conffiles	List user modified configuration files
	files <pkg>		List files belonging to <pkg>
	search <file|regexp>	List package providing <file>
	find <regexp>		List packages whose name or description matches <regexp>
	info [pkg|regexp]	Display all info for <pkg>
	status [pkg|regexp]	Display all status for <pkg>
	download <pkg>		Download <pkg> to current directory
	compare-versions <v1> <op> <v2>
	                    compare versions using <= < > >= = << >>
	print-architecture	List installable package architectures
	depends [-A] [pkgname|pat]+
	whatdepends [-A] [pkgname|pat]+
	whatdependsrec [-A] [pkgname|pat]+
	whatrecommends[-A] [pkgname|pat]+
	whatsuggests[-A] [pkgname|pat]+
	whatprovides [-A] [pkgname|pat]+
	whatconflicts [-A] [pkgname|pat]+
	whatreplaces [-A] [pkgname|pat]+

Options:
	-A			Query all packages not just those installed
	-V[<level>]		Set verbosity level to <level>.
	--verbosity[=<level>]	Verbosity levels:
					0 errors only
					1 normal messages (default)
					2 informative messages
					3 debug
					4 debug level 2
	-f <conf_file>		Use <conf_file> as the opkg configuration file
	--conf <conf_file>
	--cache <directory>	Use a package cache
	-d <dest_name>		Use <dest_name> as the the root directory for
	--dest <dest_name>	package installation, removal, upgrading.
				<dest_name> should be a defined dest name from
				the configuration file, (but can also be a
				directory name in a pinch).
	-o <dir>		Use <dir> as the root directory for
	--offline-root <dir>	offline installation of packages.
	--verify-program <path>	Use the given program to verify usign signatures
	--add-arch <arch>:<prio>	Register architecture with given priority
	--add-dest <name>:<path>	Register destination with given path

Force Options:
	--force-depends		Install/remove despite failed dependencies
	--force-maintainer	Overwrite preexisting config files
	--force-reinstall	Reinstall package(s)
	--force-overwrite	Overwrite files from other package(s)
	--force-downgrade	Allow opkg to downgrade packages
	--force-space		Disable free space checks
	--force-postinstall	Run postinstall scripts even in offline mode
	--force-remove	Remove package even if prerm script fails
	--force-checksum	Don't fail on checksum mismatches
	--no-check-certificate Don't validate SSL certificates
	--noaction		No action -- test only
	--download-only	No action -- download only
	--nodeps		Do not follow dependencies
	--nocase		Perform case insensitive pattern matching
	--size			Print package size when listing available packages
	--strip-abi		Print package name without appended ABI version
	--force-removal-of-dependent-packages
				Remove package and all dependencies
	--autoremove		Remove packages that were installed
				automatically to satisfy dependencies
	-t			Specify tmp-dir.
	--tmp-dir		Specify tmp-dir.
	-l			Specify lists-dir.
	--lists-dir		Specify lists-dir.

 regexp could be something like 'pkgname*' '*file*' or similar
 e.g. opkg info 'libstd*' or opkg search '*libop*' or opkg remove 'libncur*'
Removing intermediate container 6ac79293a55c
 ---> 0f97f9997558
Step 9/19 : RUN echo "iptables -A POSTROUTING -t mangle -p udp --dport 68 -j CHECKSUM --checksum-fill" >> /etc/firewall.user
 ---> Running in 815964284b02
Removing intermediate container 815964284b02
 ---> d4bf4ffaa46f
Step 10/19 : RUN sed -i '/^exit 0/i cat \/tmp\/resolv.conf > \/etc\/resolv.conf' /etc/rc.local
 ---> Running in 661ce824f315
Removing intermediate container 661ce824f315
 ---> 7b77be96eac1
Step 11/19 : ENV DEBIAN_FRONTEND=noninteractive
 ---> Running in 5523b5d3e5f4
Removing intermediate container 5523b5d3e5f4
 ---> 60d73fbd70c9
Step 12/19 : RUN chmod -x torconf.sh
 ---> Running in c37ca24a77f4
chmod: torconf.sh: No such file or directory
The command '/bin/sh -c chmod -x torconf.sh' returned a non-zero code: 1
make: *** [Makefile:7: build] Error 1

I'm running this using make build in the working directory. Ive copied the shell file to the container. I don't know what I'm doing wrong.

Did you give the packages as arguments?

Container has no access to the files on the main system.

are you sure that:
a) you are in the right directory at step 12? you copied torconf.sh to /etc/tor in step 7, are you in /etc/tor? if not why don't you do use absolute path in step 12?
b) opkg upgrade requires a package name, do you have a non-empty list after opkg list-upgradable? xargs -r is your friend.

and by the way opkg upgrade is not recommended, it has been explained many-many times the rational.

Okay, how do I fix this? I’m just doing what the openwrt tor client documentation tells me, and The opkg upgrade command came from the repo I’m building on top of.

Honestly I’m not sure of anything anymore.

I wasn’t aware of the recommendations against opkg, however. What would you recommend instead?

in short: openwrt is not a regular linux distro with a full blown package manager which would able to deterministically upgrade OS+apps. due to space constrains and other reasons opkg has limited feature set, and upgrade is by default not recommended. unless you really sure to understand the risk how upgrade can go side ways and break the whole system, the usual recommendation is to do sysupgrade instead. which can be done in an easy way (search attended sysupgrade).

build your own owrt with the required packages via https://firmware-selector.openwrt.org/?version=22.03.0&target=x86%2F64&id=generic , use Customized packages, add what you want, remove what you don't need. high level packages are enough, dependencies will be handled. download the created custom rootfs and start from there. you don't need to do opkg remove / update / install steps via docker build. which probably also helps you docker image build process as will create less layers.

if this does not work still you can revert to you current docker build process with the mentioned fixes.

1 Like

Thanks! I’ll try this later today and get back to you on whether or not it worked.

I changed opkg update to opkg sysupgrade and the command BEFORE it started to fail. I switched it back and it’s failing at the same place it was last time.

I think I’m just going to have users run the commands manually, because I’m pretty sure my project is now haunted.

did you apply the recommended fixes too? e.g. use absolute path?