2023-01-18 01:53:50 +00:00
|
|
|
"postContent": "(Old post, reposted from my old blog.)\n\nSo, it's 00:12 here. I was (still am) setting up my brand new RPi4, the shiny 8GB version to replace my old cranky RPi3b. New hardware, same hell as always with Raspbian (or RaspiOS or Raspberry Pi OS or however the hell they call it these days). \n\nI run on it some apps I use on my local network (basically my fancy app hub) and one of these apps is a Node.js API. Usually one would say “oh that's simple use PM2 and that's it!” but for some god forsaken reason it didn't work on me. \n\nI had just finished configuring Nextcloud and Gitea (and that went fine, as you can define the word…) and went to bring back up my Node API. As mentioned PM2 didn't work, so I went the classic way of having LXDE start a terminal and run a bash script with the commands needed. \n\nNo biggie, right? No. \n\nThe documentation for the RPi is… Well, fiddly. If you can call it that. I absolutely despise the crazy mish-mash of things you have on the internet regarding Raspbian/RaspiOS (starting by the friggin' name change!) because you simply can't easily find what works or doesn't with newer versions. \n\nSo this blog post is both a reminder to ME and a tutorial to you, fellow internet traveler that ever happens to stumble across it if you need to do the same thing. \n\n# HOW TO START A TERMINAL AND LAUNCH A BASH SCRIPT ON THE RASPBERRY PI OS: THE F*CKING TUTORIAL \n\n1. Boot your Pi to the GUI, not command line, obviously. \n\n2. Write your script and test it on the terminal (and for fuck's sake remember that the FIRST LINE should always be #!/bin/bash). \n\n3. Save your script in an easy path to access (such as /home/pi) and with the .sh extension. \n\n4. Open a terminal and run: sudo chmod +x /home/pi/your_script.sh \n\n5. Open an text editor with the sudo command (any you prefer, but IT NEEDS TO BE AS ROOT). \n\n6. Navigate to /etc/xdg/lxsession/LXDE-pi \n\n7. Open the file called autostart \n\n8. BEFORE THE LINE THAT STARTS WITH @XSCREENSAVER add a new line: @lxterminal --command \"/home/pi/your_script.sh\" (Why before @xscreensaver? Who knows. Do after it and you'll never see it execute.) \n\n9. DO FUCKING NOT put a . (dot) before the path, and INCLUDE THE DOUBLE QUOTES IN THE PATH. \n\n10. That's it. \n\nBeware that if your script does something (like launching a node app that auto-closes) and then closes after (or the app crashes…), you may want to add something like a sleep or pause command, if you want to see it running or its output. \n\nPS: I know the tone of the text is “violent”, this is literally how I write notes to myself so I can remember things. (Why? Because I'm a dumbass.) \nI usually don't share these, but considering the hellish experience I had with the PiOS (both on my 3 and 4), I wanted to share it at least so I have a permanent archive on the internet with it. \n\nHope it was helpful to someone out there. \n\nI gathered all content/commands from here: [https://www.raspberrypi.org/forums/viewtopic.php?t=65607](https:\/\/www.raspberrypi.org\/forums\/viewtopic.php?t=65607)",
|