termux / termux-boot

Termux add-on app allowing programs to be run at boot.
https://f-droid.org/en/packages/com.termux.boot
931 stars 219 forks source link

Help with Termux boot #71

Closed free-150 closed 2 years ago

free-150 commented 2 years ago

hi i would like syncthing to start it at startup. I have tried to do it as the documentation said
here But it doesn't work Things I've made sure to do:

i would then create an executable script at $PREFIX/var/service/syncthing/run with the content

#!/data/data/com.termux/files/usr/bin/sh

syncthing -logflags 0 2>&1

Create the ~/.termux/boot/ directory. Put start-syncthingscripts you want to execute inside the ~/.termux/boot/ directory

#!/data/data/com.termux/files/usr/bin/sh
source /data/data/com.termux/files/usr/etc/profile.d/start-services.sh

start-services.sh

export SVDIR=$PREFIX/var/service
export LOGDIR=$PREFIX/var/log
(service-daemon start >/dev/null 2>&1 & )

System information

Grimler91 commented 2 years ago

Does the service script work when not run through termux-boot? What does sv status syncthing tell you?

free-150 commented 2 years ago

Does the service script work when not run through termux-boot? What does sv status syncthing tell you? It work but i would like syncthing to start it at startup but it doesn't work

Grimler91 commented 2 years ago

Probably needs to be exec syncthing -logflags 0 2>&1 in the script for runit to be able to terminate the process correctly, but don't know if that will affect the integration with termux-boot.

Setup a log service for it as well and see if you get any warnings/errors, you can probably use the svlogger script, so just create a symlink as done here.

free-150 commented 2 years ago

I use this

mkdir -p $PREFIX/var/service/syncthing/log
ln -sf $PREFIX/share/termux-services/svlogger $PREFIX/var/service/syncthing/log/run

in @40000000619a29ac29449d04.u

2021-11-21_10:55:33.17409 [start] INFO: syncthing v1.18.4 "Fermium Flea" (go1.17.2 android-amd64) builder@41452aebfca2 2021-11-02 18:31:22 UTC [noupgrade]
2021-11-21_10:55:33.22070 [CJN4T] INFO: My ID: CJN4TUU-ZZFBBOP-76MX7PO-D3TNAZQ-H2AMVKH-URWTBB7-LIMFYWY-HYDSKQQ
2021-11-21_10:55:34.12148 [CJN4T] INFO: Single thread SHA256 performance is 196 MB/s using minio/sha256-simd (196 MB/s using crypto/sha256).
2021-11-21_10:55:34.60426 [CJN4T] INFO: Hashing performance is 175.96 MB/s
2021-11-21_10:55:34.60457 [CJN4T] INFO: Overall send rate is unlimited, receive rate is unlimited
2021-11-21_10:55:34.60524 [CJN4T] INFO: Using discovery mechanism: global discovery server https://discovery.syncthing.net/v2/?noannounce&id=LYXKCHX-VI3NYZR-ALCJBHF-WMZYSPK-QG6QJA3-MPFYMSO-U56GTUK-NA2MIAW
2021-11-21_10:55:34.60525 [CJN4T] INFO: Using discovery mechanism: global discovery server https://discovery-v4.syncthing.net/v2/?nolookup&id=LYXKCHX-VI3NYZR-ALCJBHF-WMZYSPK-QG6QJA3-MPFYMSO-U56GTUK-NA2MIAW
2021-11-21_10:55:34.60525 [CJN4T] INFO: Using discovery mechanism: global discovery server https://discovery-v6.syncthing.net/v2/?nolookup&id=LYXKCHX-VI3NYZR-ALCJBHF-WMZYSPK-QG6QJA3-MPFYMSO-U56GTUK-NA2MIAW
2021-11-21_10:55:34.60525 [CJN4T] INFO: Using discovery mechanism: IPv4 local broadcast discovery on port 21027
2021-11-21_10:55:34.60527 [CJN4T] INFO: Using discovery mechanism: IPv6 local multicast discovery on address [ff12::8384]:21027
2021-11-21_10:55:34.60577 [CJN4T] INFO: TCP listener ([::]:22000) starting
2021-11-21_10:55:34.60581 [CJN4T] INFO: Relay listener (dynamic+https://relays.syncthing.net/endpoint) starting
2021-11-21_10:55:34.60637 [CJN4T] INFO: Ready to synchronize "shurufa" (udukb-5j7uc) (sendreceive)
2021-11-21_10:55:34.61544 [CJN4T] INFO: GUI and API listening on 127.0.0.1:8384
2021-11-21_10:55:34.61547 [CJN4T] INFO: Access the GUI via the following URL: http://127.0.0.1:8384/
2021-11-21_10:55:34.61774 [CJN4T] INFO: My name is "localhost"
2021-11-21_10:55:34.61823 [CJN4T] INFO: Device ZPUJ7A7-LCZ3GCR-7VT7T3M-Z3ZAZQK-RY5QUXT-PRFF2WB-TOZXMT7-ELCKVAL is "win10 nox" at [dynamic]
2021-11-21_10:55:34.61989 [CJN4T] INFO: QUIC listener ([::]:22000) starting
2021-11-21_10:55:34.61990 2021/11/21 18:55:34 failed to sufficiently increase receive buffer size (was: 208 kiB, wanted: 2048 kiB, got: 512 kiB). See https://github.com/lucas-clemente/quic-go/wiki/UDP-Receive-Buffer-Size for details.
2021-11-21_10:55:34.62741 [CJN4T] INFO: Completed initial scan of sendreceive folder "shurufa" (udukb-5j7uc)
2021-11-21_10:55:36.38286 [CJN4T] INFO: Established secure connection to ZPUJ7A7-LCZ3GCR-7VT7T3M-Z3ZAZQK-RY5QUXT-PRFF2WB-TOZXMT7-ELCKVAL at 172.16.19.15:22000-192.168.195.1:22000/tcp-client/TLS1.3-TLS_AES_128_GCM_SHA256
2021-11-21_10:55:36.38319 [CJN4T] INFO: Device ZPUJ7A7-LCZ3GCR-7VT7T3M-Z3ZAZQK-RY5QUXT-PRFF2WB-TOZXMT7-ELCKVAL client is "syncthing v1.18.4" named "DESKTOP-AB2JCPD" at 172.16.19.15:22000-192.168.195.1:22000/tcp-client/TLS1.3-TLS_AES_128_GCM_SHA256
2021-11-21_10:55:44.66585 [CJN4T] INFO: Detected 0 NAT services
2021-11-21_10:55:54.47509 [CJN4T] INFO: quic://0.0.0.0:22000 detected NAT type: Port restricted NAT
2021-11-21_10:55:54.47511 [CJN4T] INFO: quic://0.0.0.0:22000 resolved external address quic://36.5.127.195:53145 (via stun.syncthing.net:3478)
2021-11-21_10:57:29.05168 [CJN4T] INFO: Joined relay relay://160.16.133.73:22067

I'm brand new to Termux

Grimler91 commented 2 years ago

Looks like syncthing is running fine in that log? You should probably check $PREFIX/var/log/sv/syncthing/current though to see how the current syncthing instance is doing

free-150 commented 2 years ago
2021-11-21_11:31:33.82581 [start] INFO: syncthing v1.18.4 "Fermium Flea" (go1.17.2 android-amd64) builder@41452aebfca2 2021-11-02 18:31:22 UTC [noupgrade]
2021-11-21_11:31:33.86005 [CJN4T] INFO: My ID: CJN4TUU-ZZFBBOP-76MX7PO-D3TNAZQ-H2AMVKH-URWTBB7-LIMFYWY-HYDSKQQ
2021-11-21_11:31:34.75789 [CJN4T] INFO: Single thread SHA256 performance is 195 MB/s using minio/sha256-simd (195 MB/s using crypto/sha256).
2021-11-21_11:31:35.22502 [CJN4T] INFO: Hashing performance is 166.30 MB/s
2021-11-21_11:31:35.22542 [CJN4T] INFO: Overall send rate is unlimited, receive rate is unlimited
2021-11-21_11:31:35.22585 [CJN4T] INFO: Using discovery mechanism: global discovery server https://discovery.syncthing.net/v2/?noannounce&id=LYXKCHX-VI3NYZR-ALCJBHF-WMZYSPK-QG6QJA3-MPFYMSO-U56GTUK-NA2MIAW
2021-11-21_11:31:35.22586 [CJN4T] INFO: Using discovery mechanism: global discovery server https://discovery-v4.syncthing.net/v2/?nolookup&id=LYXKCHX-VI3NYZR-ALCJBHF-WMZYSPK-QG6QJA3-MPFYMSO-U56GTUK-NA2MIAW
2021-11-21_11:31:35.22588 [CJN4T] INFO: Using discovery mechanism: global discovery server https://discovery-v6.syncthing.net/v2/?nolookup&id=LYXKCHX-VI3NYZR-ALCJBHF-WMZYSPK-QG6QJA3-MPFYMSO-U56GTUK-NA2MIAW
2021-11-21_11:31:35.22590 [CJN4T] INFO: Using discovery mechanism: IPv4 local broadcast discovery on port 21027
2021-11-21_11:31:35.22590 [CJN4T] INFO: Using discovery mechanism: IPv6 local multicast discovery on address [ff12::8384]:21027
2021-11-21_11:31:35.22700 [CJN4T] INFO: Ready to synchronize "shurufa" (udukb-5j7uc) (sendreceive)
2021-11-21_11:31:35.22738 [CJN4T] INFO: TCP listener ([::]:22000) starting
2021-11-21_11:31:35.22738 [CJN4T] INFO: Relay listener (dynamic+https://relays.syncthing.net/endpoint) starting
2021-11-21_11:31:35.24751 2021/11/21 19:31:35 failed to sufficiently increase receive buffer size (was: 208 kiB, wanted: 2048 kiB, got: 512 kiB). See https://github.com/lucas-clemente/quic-go/wiki/UDP-Receive-Buffer-Size for details.
2021-11-21_11:31:35.24764 [CJN4T] INFO: QUIC listener ([::]:22000) starting
2021-11-21_11:31:35.24896 [CJN4T] INFO: Completed initial scan of sendreceive folder "shurufa" (udukb-5j7uc)
2021-11-21_11:31:35.26103 [CJN4T] INFO: GUI and API listening on 127.0.0.1:8384
2021-11-21_11:31:35.26104 [CJN4T] INFO: Access the GUI via the following URL: http://127.0.0.1:8384/
2021-11-21_11:31:35.26122 [CJN4T] INFO: My name is "localhost"
2021-11-21_11:31:35.26122 [CJN4T] INFO: Device ZPUJ7A7-LCZ3GCR-7VT7T3M-Z3ZAZQK-RY5QUXT-PRFF2WB-TOZXMT7-ELCKVAL is "win10 nox" at [dynamic]
2021-11-21_11:31:36.42704 [CJN4T] INFO: Established secure connection to ZPUJ7A7-LCZ3GCR-7VT7T3M-Z3ZAZQK-RY5QUXT-PRFF2WB-TOZXMT7-ELCKVAL at 172.16.19.15:22000-192.168.2.8:22000/tcp-client/TLS1.3-TLS_AES_128_GCM_SHA256
2021-11-21_11:31:36.42706 [CJN4T] INFO: Device ZPUJ7A7-LCZ3GCR-7VT7T3M-Z3ZAZQK-RY5QUXT-PRFF2WB-TOZXMT7-ELCKVAL client is "syncthing v1.18.4" named "DESKTOP-AB2JCPD" at 172.16.19.15:22000-192.168.2.8:22000/tcp-client/TLS1.3-TLS_AES_128_GCM_SHA256
2021-11-21_11:31:45.29359 [CJN4T] INFO: Detected 0 NAT services
2021-11-21_11:31:55.11972 [CJN4T] INFO: quic://0.0.0.0:22000 detected NAT type: Port restricted NAT
2021-11-21_11:31:55.11973 [CJN4T] INFO: quic://0.0.0.0:22000 resolved external address quic://36.5.127.195:53946 (via stun.syncthing.net:3478)
2021-11-21_11:33:37.66737 [CJN4T] INFO: Joined relay relay://159.75.90.153:22067

But I can't run syncthing when my phone starts up

Grimler91 commented 2 years ago

Check with adb logcat if you get any warnings or errors when it starts termux-boot

free-150 commented 2 years ago

logcat

agnostic-apollo commented 2 years ago

Have you enabled AutoStart?

https://dontkillmyapp.com/xiaomi

free-150 commented 2 years ago

Have you enabled AutoStart?

https://dontkillmyapp.com/xiaomi

Yes.

Put start-syncthingscripts you want to execute inside the ~/.termux/boot/ directory

I added termux-wake-lock When I restart the device, the following appears

Syncthing is not working

I uploaded the log again log2