Replace printf boot script with individual echo commands for mobile
printf \n escapes also get mangled by Android clipboard (expanded to real newlines). Individual echo >> commands are the only reliable approach for copy-pasting multi-line scripts to a mobile terminal. Bunker Admin
This commit is contained in:
parent
a8de30cf8e
commit
5461ebd187
@ -447,11 +447,14 @@ export default function SmsSetupPage() {
|
|||||||
<Divider style={{ margin: '12px 0' }} />
|
<Divider style={{ margin: '12px 0' }} />
|
||||||
<Paragraph strong>Auto-start on phone reboot:</Paragraph>
|
<Paragraph strong>Auto-start on phone reboot:</Paragraph>
|
||||||
<Paragraph type="secondary">
|
<Paragraph type="secondary">
|
||||||
Install <Text strong>Termux:Boot</Text> from F-Droid, then run these two commands:
|
Install <Text strong>Termux:Boot</Text> from F-Droid, then run these commands one at a time:
|
||||||
</Paragraph>
|
</Paragraph>
|
||||||
<div style={{ background: 'rgba(0,0,0,0.1)', padding: 12, borderRadius: 6 }}>
|
<div style={{ background: 'rgba(0,0,0,0.1)', padding: 12, borderRadius: 6 }}>
|
||||||
<CmdLine comment="Create the boot scripts directory" cmd="mkdir -p ~/.termux/boot" />
|
<CmdLine comment="Create boot dir + first line of script" cmd="mkdir -p ~/.termux/boot && echo '#!/data/data/com.termux/files/usr/bin/bash' > ~/.termux/boot/start-sms-server" />
|
||||||
<CmdLine comment="Create boot script that starts the watchdog on phone reboot" cmd={"printf '#!/data/data/com.termux/files/usr/bin/bash\\ntermux-wake-lock\\ncd ~/sms-server/android\\nnohup bash sms-watchdog.sh >> ~/logs/watchdog.log 2>&1 &\\n' > ~/.termux/boot/start-sms-server && chmod +x ~/.termux/boot/start-sms-server"} />
|
<CmdLine cmd="echo 'termux-wake-lock' >> ~/.termux/boot/start-sms-server" />
|
||||||
|
<CmdLine cmd="echo 'cd ~/sms-server/android' >> ~/.termux/boot/start-sms-server" />
|
||||||
|
<CmdLine cmd="echo 'nohup bash sms-watchdog.sh >> ~/logs/watchdog.log 2>&1 &' >> ~/.termux/boot/start-sms-server" />
|
||||||
|
<CmdLine comment="Make it executable" cmd="chmod +x ~/.termux/boot/start-sms-server" />
|
||||||
</div>
|
</div>
|
||||||
<Paragraph type="secondary" style={{ marginTop: 8, marginBottom: 0 }}>
|
<Paragraph type="secondary" style={{ marginTop: 8, marginBottom: 0 }}>
|
||||||
Also disable battery optimization: Android Settings → Apps → Termux → Battery → Unrestricted.
|
Also disable battery optimization: Android Settings → Apps → Termux → Battery → Unrestricted.
|
||||||
|
|||||||
@ -162,16 +162,19 @@ This is **required** regardless of which method you use below:
|
|||||||
|
|
||||||
Install [Termux:Boot](https://f-droid.org/packages/com.termux.boot/) from F-Droid (must be same source as Termux), then open it once to register with Android.
|
Install [Termux:Boot](https://f-droid.org/packages/com.termux.boot/) from F-Droid (must be same source as Termux), then open it once to register with Android.
|
||||||
|
|
||||||
```bash
|
Run each command one at a time (copy-paste friendly):
|
||||||
# Create the boot scripts directory
|
|
||||||
mkdir -p ~/.termux/boot
|
|
||||||
|
|
||||||
# Create the auto-start script (single command, no heredoc)
|
```bash
|
||||||
printf '#!/data/data/com.termux/files/usr/bin/bash\nsource ~/.bashrc\ntermux-wake-lock\nmkdir -p ~/logs\nnohup python ~/sms-server/android/termux-sms-api-server.py >> ~/logs/sms-api.log 2>&1 &\n' > ~/.termux/boot/start-sms-server && chmod +x ~/.termux/boot/start-sms-server
|
mkdir -p ~/.termux/boot && echo '#!/data/data/com.termux/files/usr/bin/bash' > ~/.termux/boot/start-sms-server
|
||||||
|
echo 'source ~/.bashrc' >> ~/.termux/boot/start-sms-server
|
||||||
|
echo 'termux-wake-lock' >> ~/.termux/boot/start-sms-server
|
||||||
|
echo 'mkdir -p ~/logs' >> ~/.termux/boot/start-sms-server
|
||||||
|
echo 'nohup python ~/sms-server/android/termux-sms-api-server.py >> ~/logs/sms-api.log 2>&1 &' >> ~/.termux/boot/start-sms-server
|
||||||
|
chmod +x ~/.termux/boot/start-sms-server
|
||||||
```
|
```
|
||||||
|
|
||||||
!!! tip "Why printf instead of heredoc?"
|
!!! tip "Why individual echo commands?"
|
||||||
Heredoc (`<< 'EOF'`) blocks are unreliable when copy-pasting on mobile devices — trailing whitespace or clipboard quirks prevent the `EOF` from being recognized. The `printf` one-liner is more reliable for mobile copy-paste.
|
Heredocs and `printf` with `\n` are unreliable when copy-pasting to a mobile terminal — the clipboard mangles escape sequences or adds trailing whitespace. Individual `echo >>` commands are the most reliable approach for mobile copy-paste.
|
||||||
|
|
||||||
#### C. Watchdog (auto-restart on crash)
|
#### C. Watchdog (auto-restart on crash)
|
||||||
|
|
||||||
@ -193,9 +196,11 @@ The watchdog:
|
|||||||
For maximum reliability, use the watchdog as your boot script:
|
For maximum reliability, use the watchdog as your boot script:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
mkdir -p ~/.termux/boot
|
mkdir -p ~/.termux/boot && echo '#!/data/data/com.termux/files/usr/bin/bash' > ~/.termux/boot/start-sms-server
|
||||||
|
echo 'termux-wake-lock' >> ~/.termux/boot/start-sms-server
|
||||||
printf '#!/data/data/com.termux/files/usr/bin/bash\ntermux-wake-lock\ncd ~/sms-server/android\nnohup bash sms-watchdog.sh >> ~/logs/watchdog.log 2>&1 &\n' > ~/.termux/boot/start-sms-server && chmod +x ~/.termux/boot/start-sms-server
|
echo 'cd ~/sms-server/android' >> ~/.termux/boot/start-sms-server
|
||||||
|
echo 'nohup bash sms-watchdog.sh >> ~/logs/watchdog.log 2>&1 &' >> ~/.termux/boot/start-sms-server
|
||||||
|
chmod +x ~/.termux/boot/start-sms-server
|
||||||
```
|
```
|
||||||
|
|
||||||
#### D. Quick Background (simplest)
|
#### D. Quick Background (simplest)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user