smart testing of pool drives no longer working

Status
Not open for further replies.

BigDave

FreeNAS Enthusiast
Joined
Oct 6, 2013
Messages
2,479

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
Perfect.

So now you just need to follow this:

Maximize your SSH window if it wasn't already maximized (to avoid breaking long lines in the script when you'll paste it).

Go to your pool (you can go to a dataset in the pool if you want, just avoid a dataset where the script can bother you on the client side): cd /mnt/your_pool/

Then create a directory (if you want) to put your scripts in: mkdir scripts

Go in this directory if you created it (cd scripts) and open a new a file: nano your_script.sh

Copy the raw paste data of the script on pastebin (at the bottom of the page), be careful to not forget the first or last line, the best thing to do is to click on the text, do a Ctrl + A and then a Ctrl + C.

Paste the data in the file you created by right-clicking (on the UNIX systems if you highlight something it'll be copied to the clipboard and if you middle-click (right-click on Putty) you'll paste whatever is currently in the clipboard).

Check rapidly that everything is as it should, do the changes you want to make (email address, ...) then save and quit the editor (for nano: Ctrl + O then Enter, and then Ctrl + X).

Add execution rights to the file: chmod +x your_script.sh

Now you should have a working script, you can test it like this: ./your_script.sh

Please note that several (all?) of my scripts needs root rights so use the root account to execute them (but as you've SSH'ed with the root account it shouldn't be a problem).

Once you tested that everything works as it should you can add a CRON task in the web GUI if you want to execute the script regularly. Make sure you select "root" as the user and use the absolute path to your script as the command (for example: /mnt/your_pool/scripts/your_script.sh).
 
Last edited:

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,994
Here you go, this link jumps to what I created a while back and you can modify the script to you liking.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
Go in this directory if you created it (cd scripts) and open a new a file: nano your_script.sh
...and if any of the lines in the script are long enough to wrap, you can use the -w flag for nano to turn that off: nano -w your_script.sh.
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
Interesting, didn't know that. I'll search about this flag and add it if appropriate, thanks ;)
 

BigDave

FreeNAS Enthusiast
Joined
Oct 6, 2013
Messages
2,479
Ok, that was AWESOME :D
I made a few mistakes and got hung up a couple of times,
but figured out how to remove the directory and start fresh.

Don't you dare make fun of me for not changing the name,
I'm just learning here and I'LL FIX IT LATER :):p

I also figured out the chmod +x your_script did not work until
I removed the space between the x and the name. see below.

I got the email and it's way cool :D now to add the cron in the GUI.

Code:
[root@freenas] /mnt/plumber/scripts# chmod +x your_script.sh
chmod: your_script.sh: Operation not permitted
[root@freenas] /mnt/plumber/scripts# chmod +X your_script.sh
chmod: your_script.sh: Operation not permitted
[root@freenas] /mnt/plumber/scripts# chmod +xyour_script.sh
usage: chmod [-fhv] [-R [-H | -L | -P]] mode file ...
[root@freenas] /mnt/plumber/scripts# ./your_script.sh
[root@freenas] /mnt/plumber/scripts#



Thanks for all the help everyone.
Mark, I'll look at your version after I get more comfortable with this stuff
and maybe get around to doing a bit of editing.
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
I agree, there should be a space. The chmod didn't do anything (when you get an "usage" in return to a command then you've made a mistake in this command).

Can you post the output of ls -l please?

NB: you can use mv to rename a file (and/or move it elsewhere) for example mv your_script.sh another_name.sh ;)
 

BigDave

FreeNAS Enthusiast
Joined
Oct 6, 2013
Messages
2,479
Code:
[root@freenas] ~# ls -l
total 33
drwxr-xr-x  3 root  wheel  18 Sep  5 09:30 ./
drwxr-xr-x  19 root  wheel  27 Oct 25 18:49 ../
-rw-------  1 root  wheel  186 Oct 20 20:24 .bash_history
-rw-r--r--  1 root  wheel  1128 Aug 16 12:38 .bashrc
-rw-r--r--  1 root  wheel  1229 Aug 16 12:38 .cshrc
-rw-------  1 root  wheel  12533 Oct 27 21:15 .history
-rw-r--r--  1 root  wheel  80 Aug 16 12:38 .k5login
-rw-r--r--  1 root  wheel  82 Aug 16 12:38 .login
-rw-r--r--  1 root  wheel  560 Aug 16 12:38 .profile
-rw-r--r--  1 root  wheel  1128 Aug 16 12:38 .shrc
drwxr-xr-x  2 root  wheel  2 Aug 16 18:43 .ssh/
-rw-r--r--  1 root  wheel  0 Sep  5 09:30 100K
-rwxr-xr-x  1 root  wheel  1677 Aug 16 12:38 change_password*
-rwxr-xr-x  1 root  wheel  1630 Aug 16 12:38 save_cfg*
-rwxr-xr-x  1 root  wheel  1591 Aug 16 12:38 save_sshkeys*
-rwxr-xr-x  1 root  wheel  1607 Aug 16 12:38 update*
-rwxr-xr-x  1 root  wheel  2949 Aug 16 12:38 updatep1*
-rwxr-xr-x  1 root  wheel  3225 Aug 16 12:38 updatep2*
[root@freenas] ~#
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
Ah... same command but go in your script directory first please or just use ls -l /mnt/plumber/scripts/ :)
 

BigDave

FreeNAS Enthusiast
Joined
Oct 6, 2013
Messages
2,479
Code:
[root@freenas] ~#  ls -l /mnt/plumber/scripts/
total 26
drwxrwxr-x+ 2 root  nogroup  3 Oct 27 20:43 ./
drwxrwxr-x+ 6 nobody  nogroup  8 Oct 27 20:29 ../
-rwxrwxr-x+ 1 root  nogroup  4196 Oct 27 20:43 your_script.sh*
[root@freenas] ~#
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
Ok, for whatever reason your script is already executable, you don't need to chmod it.

So, it worked when you executed it? I see no output so I guess it's a script who send an email.
 

BigDave

FreeNAS Enthusiast
Joined
Oct 6, 2013
Messages
2,479
Ok, for whatever reason your script is already executable, you don't need to chmod it.

So, it worked when you executed it? I see no output so I guess it's a script who send an email.
Worked perfectly when I tested it with ./your_script.sh
Received the email about two min. after giving the command.
So what's your guess as to why it became exec all by itself???
Not that I'm complaining you understand ;)
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
Ok, perfect. Then you just need to add a cron task if you want or you can just execute it manually from a terminal with /mnt/plumber/scripts/your_script.sh when you need ;)

I guess it's your rights mask who makes the files executable by default.
 

BigDave

FreeNAS Enthusiast
Joined
Oct 6, 2013
Messages
2,479
Then you just need to add a cron task if you want
Already done, gonna get email every morning with coffee :D This will save me about ten min. EVERY DAY !!!
I guess it's your rights mask who makes the files executable by default
Good to know that.
Thanks once again for your help with this, I really appreciate it.
Well, it's past my bedtime so I'll wish you good night...
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
Ok, good.

You're welcome ;)
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
Code:
[root@freenas] ~#  ls -l /mnt/plumber/scripts/
total 26
drwxrwxr-x+ 2 root  nogroup  3 Oct 27 20:43 ./
drwxrwxr-x+ 6 nobody  nogroup  8 Oct 27 20:29 ../
-rwxrwxr-x+ 1 root  nogroup  4196 Oct 27 20:43 your_script.sh*
[root@freenas] ~#
...and as I suspected, you've done this in a directory/dataset with Windows permissions, which is why the chmod command didn't work. For whatever reason, it has the execute permission set, but you aren't going to be able to change permissions from the command line easily.
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
I wonder if it's worth creating a dataset just for the scripts with the right permissions (unix permissions with execution bit set by the mask), it's an idea anyway :)
 

BigDave

FreeNAS Enthusiast
Joined
Oct 6, 2013
Messages
2,479
I wonder if it's worth creating a dataset just for the scripts with the right permissions (unix permissions with execution bit set by the mask), it's an idea anyway :)
Based on what you guys were saying about the share and permissions, I started over and used the GUI to create a new dataset
(named "scripts") within /mnt/plumber with owner root and unix permissions and this time when I added the execution
rights to the file, it executed. :D
When looking at the network from the client, the dataset "scripts" doesn't show up. ;)
Now I'll post the ls -l to see if y'all think it's better.
Code:
[root@freenas] ~# ls -l /mnt/plumber/scripts
total 26
drwx------  2 root  wheel  3 Oct 30 17:23 ./
drwxrwxr-x+ 6 nobody  nogroup  8 Oct 30 16:22 ../
-rwxr-xr-x  1 root  wheel  4263 Oct 30 17:23 smart_email.sh*
[root@freenas] ~#
 

BigDave

FreeNAS Enthusiast
Joined
Oct 6, 2013
Messages
2,479
Status
Not open for further replies.
Top