How does one upload scripts to FreeNAS and where?

Status
Not open for further replies.

mike360x1

Contributor
Joined
Dec 25, 2012
Messages
107
Hey guys,

Context(Don't have to read):

I am a FreeNAS Noobie looking to setup his own home file server. And, one concern I had after setting up everything was how I was going to monitor the temperature settings.

In the FreeNAS GUI, there is a "reporting" tab which displays common system health info such as CPU usage , Ram or SWAP usage, Network Utilization etc. What it doesn't display is the CPU Temperatures, and HDD temperatures. So off I went to google and I found various useful scripts that did just that and more.

Problem:
So I found this very useful thread posted by Bidule0hm and read the "Script basics" instructions posted at the bottom of his entry. It gave step by step instructions on how to upload a script onto FreeNAS via SSH and NANO text editor. However, there were some issues I ran into while trying to create my script on my machine

1. When he refers to directory "/home/your_user_name/scripts/" there is no explicit folder named "home" and when I login to FreeNAS SSH Via Putty, (using root account) I end up in the root directory.

For my users I have setup the home directory for each user as "\nonexistant" which I assume is the folder right after the root. (correct me if I'm wrong) So, there is no "home" directory that I can refer to. Moreover, the only places I can assign a home directory for my users are in a mount point somewhere in my data sets. So I assume scripts can only be installed somewhere on a ZFS Pool in a dataset?

2. Where is the best/ideal place to place scripts? Does it have to be on a dataset or can it be somewhere in the bootdisk. I heard that /bin and other system file folders are not great places to setup scripts. I heard that if the script is left on the ZFS pool when its idle then, the drives will have to spin up every time the system needs to access the script. That would cause a lot of wear and tear.

3. He (Biduleohm) also mentioned to directly copy from the pastebin and paste directly into nano using the right click button. This did not work for me, it simply just outputted a single blank line. How would I go about copy and pasting code into nano from another program?

4. Side question: when I enter in "ls" into putty console. it brings up the entries "./" and "../" what does that indicate? I assume "../" is the root directory and "./" is the home?

5. Sorry for this long string of questions, I have searched on the forums and there doesn't seem to be any easy place to start if I want to learn about installing scripts (most of them just assume you have prior knowledge about the file system and how to operate the associated programs).
 

BigDave

FreeNAS Enthusiast
Joined
Oct 6, 2013
Messages
2,479
@Bidule0hm recommended to me that I could just create a dataset for my scripts. I named it scripts.
I copied the script (as per his instructions) and then started the cron job pointing to the file in the dataset.
My one and only script emails me every morning @ 5am with my disk temps and the more important
values of smart output, this once a day cron job does not cause excessive wear.
 

BigDave

FreeNAS Enthusiast
Joined
Oct 6, 2013
Messages
2,479

mike360x1

Contributor
Joined
Dec 25, 2012
Messages
107
Awesome, I think I'm starting to get it now. What if the script needed to be installed to the boot drive? (Hypothetically)

Also, Executing the script seems to be a problem. It returns a "Command not found" error for me:

Code:
[root@TankBox] /scripts# ./temp_test.sh
./temp_test.sh: Command not found.
[root@TankBox] /scripts# temp_test.sh
temp_test.sh: Command not found.
[root@TankBox] /scripts# /scripts/temp_test.sh
/scripts/temp_test.sh: Command not found.
[root@TankBox] /scripts# chmod +xtemptest.sh
usage: chmod [-fhv] [-R [-H | -L | -P]] mode file ...
[root@TankBox] /scripts# chmod+x temp_test.sh
chmod+x: Command not found.
[root@TankBox] /scripts# chmod +xtemp_test.sh
usage: chmod [-fhv] [-R [-H | -L | -P]] mode file ...
[root@TankBox] /scripts# ./temp_test.sh
./temp_test.sh: Command not found.
[root@TankBox] /scripts# ls -l
total 5
drwxr-xr-x   2 root  wheel     3 May 11 19:04 ./
drwxr-xr-x  21 root  wheel    28 May 11 15:13 ../
-rwxr-xr-x   1 root  wheel  1319 May 11 19:04 temp_test.sh*


I've tried various forms of the chmod command but with no success :(
 

mike360x1

Contributor
Joined
Dec 25, 2012
Messages
107
Awesome, Everything is golden, Thanks for your help guys ! :D
 

ethereal

Guru
Joined
Sep 10, 2012
Messages
762
i used to have my scripts on the boot device - but usually this is a single device with no redundancy.
i did loose a usb and all the hard work on my scripts - i now have a scripts folder on one of my pools.
now if i loose my boot drive or have to do a reinstall it makes it much easier with the scripts one of my pools.
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
sh ./temp_test.sh

It's a better idea to use a shebang: put #!/bin/sh at the top of your script ;)

Then you can just do ./your_script.sh and your script will always run with the same shell.
 

mike360x1

Contributor
Joined
Dec 25, 2012
Messages
107
i used to have my scripts on the boot device - but usually this is a single device with no redundancy.
i did loose a usb and all the hard work on my scripts - i now have a scripts folder on one of my pools.
now if i loose my boot drive or have to do a reinstall it makes it much easier with the scripts one of my pools.

Way ahead of ya bro :) already made a copy of scripts on both the pool and boot disk. :) (But I will be running scripts from boot drive)

It's a better idea to use a shebang: put #!/bin/sh at the top of your script ;)

Then you can just do ./your_script.sh and your script will always run with the same shell.

Noted: Thank you for your help :D
 

Glorious1

Guru
Joined
Nov 23, 2014
Messages
1,211
I put my scripts in a bin subfolder of my home folder. That way when I SSH in they are right there handy.
 
Status
Not open for further replies.
Top