2

I've made a basic script to run my Discord bot however, I can't get it to run on startup. I keep on getting an error saying. I'm using this Run bash script on startup and I still get an error " 'Run.sh' has missing LSB tags and overrides" Here is the script:

#! /bin/bash
#! /bin/sh

cd /media/root/NEW/ VOLUME/FurBot
node bot.js

I hope you can help :P

Titchy2005
  • 63
  • 1
  • 1
  • 6

2 Answers2

5

Unfortunately the Q&A you are consulting is

  • Mostly obsolete, since the accepted answer uses SysV init style methods instead of systemd ones. These are both init systems. The former is used on v. <= 7 Raspbian (unless I am remembering wrong, there's actually no < 7 since Raspbian follows Debian version numbering, and Debian has been evolving for a few decades). The latter is used on the previous (8, jessie) and current (9, stretch) versions. It supports SysV scripts for backward compatibility, but...

  • The accepted answer in that Q&A does not actually explain how to write a SysV style script, just how to enable one. And that's why you get the "missing LSB tags" error. The script is missing a lot of things that would make it SysV compliant.

There's no point in learning how to write such a script, however (it is a bit ornate), since the system is obsolete.

The easiest thing to do there would be to just add something to the end of /etc/rc.local (but before the final exit 0 line):

export PATH=/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin

cd /media/root/NEW\ VOLUME/FurBot
setsid node bot.js &> /dev/null

Notice I inverted the slash in NEW\ VOLUME. Command line parameters cannot have unescaped spaces in them; I presume that's what you mean to do. You can instead use quotes:

cd "/media/root/NEW VOLUME/FurBot"

setsid maybe spurious here but doesn't hurt. See man setsid for what it does.

If you want to get fancier, you can write a systemd service file for it -- you will find a lot of examples of such for node.js online -- but if this works for you, then don't worry about it.

goldilocks
  • 58,859
  • 17
  • 112
  • 227
2

There's an extra space in your #! line. And you only need one.

This should work better:

#!/bin/bash

cd /media/root/NEW/ VOLUME/FurBot
node bot.js

The extra #! is treated as a comment so it wasn't breaking anything. But the extra space after the ! will break it.

chicks
  • 121
  • 3