Replace heredoc boot scripts with printf one-liners for mobile copy-paste reliability
Heredocs fail silently on Android Termux when copy-pasting from the admin GUI (trailing whitespace from clipboard prevents EOF recognition). Switched to printf commands in both the setup wizard and MkDocs docs. Also added source ~/.bashrc and boot script steps directly in the wizard Step 4. Bunker Admin
This commit is contained in:
parent
6b47f67d8a
commit
a8de30cf8e
@ -433,6 +433,7 @@ export default function SmsSetupPage() {
|
||||
<div>
|
||||
<Paragraph>With the API key set, start the Flask server:</Paragraph>
|
||||
<div style={{ background: 'rgba(0,0,0,0.1)', padding: 12, borderRadius: 6 }}>
|
||||
<CmdLine comment="Reload .bashrc so the API key is available" cmd="source ~/.bashrc" />
|
||||
<CmdLine comment="Create logs dir and start the SMS API server" cmd="mkdir -p ~/logs && cd ~/sms-server/android && python termux-sms-api-server.py" />
|
||||
</div>
|
||||
<Paragraph style={{ marginTop: 8 }}>
|
||||
@ -443,8 +444,16 @@ export default function SmsSetupPage() {
|
||||
<div style={{ background: 'rgba(0,0,0,0.1)', padding: 12, borderRadius: 6 }}>
|
||||
<CmdLine comment="Run the watchdog (auto-restarts server if it crashes)" cmd="nohup bash ~/sms-server/android/sms-watchdog.sh >> ~/logs/sms-watchdog.log 2>&1 &" />
|
||||
</div>
|
||||
<Divider style={{ margin: '12px 0' }} />
|
||||
<Paragraph strong>Auto-start on phone reboot:</Paragraph>
|
||||
<Paragraph type="secondary">
|
||||
Install <Text strong>Termux:Boot</Text> from F-Droid, then run these two commands:
|
||||
</Paragraph>
|
||||
<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 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"} />
|
||||
</div>
|
||||
<Paragraph type="secondary" style={{ marginTop: 8, marginBottom: 0 }}>
|
||||
For auto-start on phone reboot, install <Text strong>Termux:Boot</Text> from F-Droid.
|
||||
Also disable battery optimization: Android Settings → Apps → Termux → Battery → Unrestricted.
|
||||
</Paragraph>
|
||||
</div>
|
||||
|
||||
@ -166,20 +166,12 @@ Install [Termux:Boot](https://f-droid.org/packages/com.termux.boot/) from F-Droi
|
||||
# Create the boot scripts directory
|
||||
mkdir -p ~/.termux/boot
|
||||
|
||||
# Create the auto-start script
|
||||
cat > ~/.termux/boot/start-sms-server << 'EOF'
|
||||
#!/data/data/com.termux/files/usr/bin/sh
|
||||
termux-wake-lock
|
||||
export SMS_API_SECRET="YOUR_KEY_HERE"
|
||||
mkdir -p ~/logs
|
||||
nohup python ~/sms-server/android/termux-sms-api-server.py >> ~/logs/sms-api.log 2>&1 &
|
||||
EOF
|
||||
|
||||
chmod +x ~/.termux/boot/start-sms-server
|
||||
# Create the auto-start script (single command, no heredoc)
|
||||
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
|
||||
```
|
||||
|
||||
!!! warning "Replace YOUR_KEY_HERE"
|
||||
Edit the script and replace `YOUR_KEY_HERE` with your actual API key. Or if you've already saved it in `~/.bashrc`, replace the export line with `source ~/.bashrc`.
|
||||
!!! tip "Why printf instead of heredoc?"
|
||||
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.
|
||||
|
||||
#### C. Watchdog (auto-restart on crash)
|
||||
|
||||
@ -201,13 +193,9 @@ The watchdog:
|
||||
For maximum reliability, use the watchdog as your boot script:
|
||||
|
||||
```bash
|
||||
cat > ~/.termux/boot/start-sms-server << 'EOF'
|
||||
#!/data/data/com.termux/files/usr/bin/sh
|
||||
source ~/.bashrc
|
||||
nohup bash ~/sms-server/android/sms-watchdog.sh >> ~/logs/sms-watchdog.log 2>&1 &
|
||||
EOF
|
||||
mkdir -p ~/.termux/boot
|
||||
|
||||
chmod +x ~/.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
|
||||
```
|
||||
|
||||
#### D. Quick Background (simplest)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user