Startup scripts finally working

scrubolio

Cadet
Joined
Mar 19, 2018
Messages
4
Being a total linux/freensd noob, I had no idea why my scripts were running on boot. they were throwing all kinds of errors. So I'm trying to post what I finally got to work here so others don't have to struggle for as long as I did...someone please correct me if I'm wrong

1. in your script file, make sure the VERY FIRST line of the script is #!/bin/bash #!/usr/bin/env bash or whatever sell you intend to use. - I originally had some what I thought were commented out lines at the very top and it just threw constant errors EVEN THOUGH I was able to run it normally when logged in via SSH.

2. also in your script file, when you refer to a command (like smartctl or tmux or ipmitool), make sure to list its FULL path. ie: /usr/local/sbin/smartctl OR /usr/local/bin/tmux OR /usr/local/bin/tmux. tip: if you want to find which directory the command you want to use is, for example type:
find . "ipmitool"
replacing ipmitool with your command, keep the double quotes.

3. in order to run a script in tmux (so it can run I the background, not in your main shell), in the Freenas GUI, run a command NOT a script like:
/usr/local/bin/tmux new-session -d -s SESSION-NAME /mnt/YOURPOOL/YOURscriptFOLDER/script.sh

in order to get back to that tmux session, goto shell and type:
tmux a -t SESSION-NAME

*replace SESSION-NAME with your name of choice
*replace YOURPOOL with your pool name
*replace YOURscriptFOLDER with your path to the script
*replace script.sh with your script name

4. you may or may NOT? need to chmod your script file to be executable via:
chmod +x /mnt/YOURPOOL/YOURscriptFOLDER/script.sh
*replace YOURPOOL with your pool name
*replace YOURscriptFOLDER with your path to the script
*replace script.sh with your script name

hope this helps some other linux newbie...
 
Last edited:

tprelog

Patron
Joined
Mar 2, 2016
Messages
297
2. also in your script file, when you refer to a command (like smartctl or tmux or ipmitool), make sure to list its FULL path

Thanks for this. I was pulling my hair out. So simple I never thought about it.
 

scrubolio

Cadet
Joined
Mar 19, 2018
Messages
4
So glad this helped someone! I was also tearing my hair out for a long long time...
 
Top