Start python script on jail startup

nvasile

Dabbler
Joined
Sep 12, 2020
Messages
17
Hello,

I've been trying to get a python discord bot I wrote for me and my friends running on jail startup for a few days now. I feel like every link is purple at the moment and linking lengthy paragraphs of documentation from before I was born DOES NOT help. Where I am now:
  • bot pulled from github, dependencies installed. manual startup is 100% working
  • executable rc script created: /etc/rc.d/disord_bot
  • rc config calling rc script on startup
  • a unrelated debug command inside the rc script works (printing the date to a file), but the python script will not start
I don't know whats wrong. Is there any other approach that isnt as wildly inconvenient and infuriating as rc.d? I feel like on most other unix-style system, startup scripts are considerably better documented, AND simpler.

/etc/rc.d/discord_bot:
Code:
#!/bin/sh

# PROVIDE: discord_bot

. /etc/rc.subr

name="discord_bot"
rcvar="${name}_enable"
start_cmd="${name}_start"
stop_cmd=":"

discord_bot_start()
{
        date > /my_out.log                                          # WORKS!
        nohup /usr/local/bin/python /discord_polling_bot/bot.py &   # works from a user terminal, but not in here
}

load_rc_config $name
run_rc_command "$1"
 

Jailer

Not strong, but bad
Joined
Sep 12, 2014
Messages
4,977
Run it from cron in the jail and use the @Reboot command.
 

nvasile

Dabbler
Joined
Sep 12, 2020
Messages
17
Run it from cron in the jail and use the @Reboot command.

I used crontab -e to add this line: (there is no space after the @ in the cron file)
@ reboot python /discord_polling_bot/bot.py
I rebooted the VM and it didnt work, when i run man cron, the word reboot isn't present
 
Last edited:
Top