*New 11.4 series Release:
2020-07-03: XigmaNAS 11.4.0.4.7633 - released!

*New 12.1 series Release:
2020-04-17: XigmaNAS 12.1.0.4.7542 - released


We really need "Your" help on XigmaNAS https://translations.launchpad.net/xigmanas translations. Please help today!

Producing and hosting XigmaNAS costs money. Please consider donating for our project so that we can continue to offer you the best.
We need your support! eg: PAYPAL

A small script problem

XigmaNAS Scripts and shell tips
Forum rules
Set-Up GuideFAQsForum Rules
Post Reply
redline
Starter
Starter
Posts: 69
Joined: 29 Dec 2012 19:23
Status: Offline

A small script problem

#1

Post by redline »

Hello
I have made a small script for an rsync job and it runs quite well. My problem is that i would like to execute it now from wherever i am in the directory tree.
I tried to add a new search directory in the path variable. So i edited the /etc/profile.

But it seems after a restart the profile file is allways exchanged against a standard file on the USB stick. I have choosed the embedded install for Nas4free.

Can someone please give me a tip how i can edit the path variable so the change is permanent.
Or, alternative ... where can i store my script in the given path variable entries .. /usr/bin ... /usr/sbin for example.
I don't know which directory is maybe reserved for custom changes and also permanent and not allways overwritten during the boot process.

Sorry, but i'm new to this and couldn't find a solution here, searching for Path enviroment

User avatar
raulfg3
Site Admin
Site Admin
Posts: 5116
Joined: 22 Jun 2012 22:13
Location: Madrid (ESPAÑA)
Contact:
Status: Offline

Re: A small script problem

#2

Post by raulfg3 »

to save files in embeded mode, you need to save on /mnt/yourpool/YourFolder.

eg: save in /mnt/NAS-A/Scripts you can also share /scrips to easy change /edit of scripts.
12.0.0.4 (revision 6766)+OBI on SUPERMICRO X8SIL-F 8GB of ECC RAM, 12x3TB disk in 3 vdev in RaidZ1 = 32TB Raw size only 22TB usable

Wiki
Last changes

HP T510

redline
Starter
Starter
Posts: 69
Joined: 29 Dec 2012 19:23
Status: Offline

Re: A small script problem

#3

Post by redline »

>eg: save in /mnt/NAS-A/Scripts you can also share /scrips to easy change /edit of scripts

So, "/mnt/NAS-A/Scripts" is not a very special secret directory for N4F.
It's only an example from you and if i share this via CIFS i can edit it easily.
I can change the "browsable" option then if needed. Okay, fine.

But how can i expand the PATH enviroment variable permanent with "/mnt/NAS-A/Scripts" ??
My small rsync script uses the actual directory and the above to work properly.
It's a bit complicated to explain. But i need to save many hardlinks from a Pool to a Backup Harddisk which is
smaller then the Pool itself. Because of this i have to do split it into smaller chunks ...
I go over Putty SSH into this directory and start my script.

It looks like this ...

# Identitfy over inode number (here -samefile) all hardlinks belonging to this directory and create a positive include list
# with absolute path for rsync. All other ways via " include, exclude, pattern " didn't worked for me.
#
# /Pool1/HD1_1TB/1000 musikvideos <- This shall be synced to external Backup Harddisk 1TB
# /Pool1/HD2_1TB/900 musikvideos <- This shall be synced to another external Backup Harddisk 1TB
# /Pool1/Link Directory/All 1900 musikvideos hardlinked twice to above directories. Once sorted for Title and once for Year using only once diskspace
#
# Sense : I want to preserve the over the years handmade hardlinks. It's a kind of sorting for external media player
#
# \Titel\AC DC - Back in Black (1980) (HD) (720p).mkv
# .. 1899 other files
# \Year\1980 - AC DC - Back In Black.mkv
# .. 1899 other files
#
# \XBMC\AC DC - Back In Black.mkv ( coming soon .. without all HD, 720p. year , source etc - scraper results are better without all that)

rm ln.txt
workdir=$(pwd)
cd ..
searchdir=$(pwd)
cd $workdir

for datei in *

do
find $searchdir -xdev -samefile "$datei" -type f >> ln.txt
done

rsync -arvHW --human-readable --files-from=ln.txt / /mnt/TOURO4TB/audio/rsync/


Above is only one example. I can use this script in several places and that's why i want to start it everywhere !

User avatar
raulfg3
Site Admin
Site Admin
Posts: 5116
Joined: 22 Jun 2012 22:13
Location: Madrid (ESPAÑA)
Contact:
Status: Offline

Re: A small script problem

#4

Post by raulfg3 »

redline wrote:So, "/mnt/NAS-A/Scripts" is not a very special secret directory for N4F.
It's only an example from you and if i share this via CIFS i can edit it easily.
I can change the "browsable" option then if needed. Okay, fine.
yes is only an example, in your case could be: /mnt/Pool1/Scripts/
redline wrote:how can i expand the PATH enviroment variable permanent with "/mnt/NAS-A/Scripts" ??
Not needed, use full path for all of your commands and scripts.


PD: other workarround is to use full install, if you use full install , you can save your script in /usr/local/sbin/yourscript.sh and is not deleted between reboots. ( advantages and disavantages of full Vs Embeded) read more in wiki and forums
12.0.0.4 (revision 6766)+OBI on SUPERMICRO X8SIL-F 8GB of ECC RAM, 12x3TB disk in 3 vdev in RaidZ1 = 32TB Raw size only 22TB usable

Wiki
Last changes

HP T510

redline
Starter
Starter
Posts: 69
Joined: 29 Dec 2012 19:23
Status: Offline

Re: A small script problem

#5

Post by redline »

>read more in wiki and forums
I have read it before and that's why i choosed embedded.

>Not needed, use full path for all of your commands and scripts.
I was too lazy allways for the long full path. But okay. If that's i have to live with no problem.
I tried to expand the PATH on the CLI. It's changed in the putty session but i cannot start the script this way.
Seems i have to live with the full path. Thank you very much anyway.

User avatar
raulfg3
Site Admin
Site Admin
Posts: 5116
Joined: 22 Jun 2012 22:13
Location: Madrid (ESPAÑA)
Contact:
Status: Offline

Re: A small script problem

#6

Post by raulfg3 »

redline wrote:>read more in wiki and forums
I have read it before and that's why i choosed embedded.
I mean that if you choose embeded to save life of your USB Key, you still have a full install and move all theads that use R/W intensive to your data disk.

EG: You can move logs to your data disk, or if you use fuppes , define your data disk as storage for your DDBB, etc..
Using this I extend my CF life and have no problems in 4 years. (I use a CF and a CF2IDE adapter).


and if you use full and your USB Key is dead, you only need to buy a new one, do a new fresh full install and restore your previosly saved config ( 5 minutes in total), not much for 10$ a USB key , and your data disk are safe all the time.
12.0.0.4 (revision 6766)+OBI on SUPERMICRO X8SIL-F 8GB of ECC RAM, 12x3TB disk in 3 vdev in RaidZ1 = 32TB Raw size only 22TB usable

Wiki
Last changes

HP T510

redline
Starter
Starter
Posts: 69
Joined: 29 Dec 2012 19:23
Status: Offline

Re: A small script problem

#7

Post by redline »

> I mean that if you choose embeded to save life of your USB Key, you still have a full install and move all theads that use R/W intensive to your data disk.
Excuse me that it comes out of topic. I choosed embedded for several reasons.
1. web updates easily , 2 saving one sata port
and off course to save life of the UBS Key. I "expect" when choosing this installation there is NO WRITE operation on the key and all relevant or still
needed write operations are swapped automatically to the harddisk. I don't have an idea what fuppes is right now. I can read that somewhat later.

But for my personal peace of mind it would be nice if you can proof that embedded install is out of the box "safe" for my USB Key
doing nothing else !!!

I have lost nearly 2 weeks in time ( 10 years counting the grey hairs ) that N4F didn't used my 8GB Ram (i read everywhere that over 4Gb ZFS prefetching and
other goodies are automatically) In my case i was puzzled with slow network traffic. I never came to the idea that it was optimized for 512Mb.
After i change loader.conf with variables for 8GB the system flies.
I was not amuzed about this N4F default configuration because often there are hints in the forum to look at the Freebsd forum.
And from there i had the infos that 8GB are out of the box better. Not everyone wants to dive so deep into an OS.

btw: I found several points where forum knowledge tells other stories then found in the N4F Wiki. That's why i not trust the Wiki anymore.

User avatar
raulfg3
Site Admin
Site Admin
Posts: 5116
Joined: 22 Jun 2012 22:13
Location: Madrid (ESPAÑA)
Contact:
Status: Offline

Re: A small script problem

#8

Post by raulfg3 »

sorry you are right , this became off topic.

If you want to continue , perhaps open a new discussion in Newbie Questions
12.0.0.4 (revision 6766)+OBI on SUPERMICRO X8SIL-F 8GB of ECC RAM, 12x3TB disk in 3 vdev in RaidZ1 = 32TB Raw size only 22TB usable

Wiki
Last changes

HP T510

redline
Starter
Starter
Posts: 69
Joined: 29 Dec 2012 19:23
Status: Offline

Re: A small script problem

#9

Post by redline »

> But for my personal peace of mind it would be nice if you can proof that embedded install is out of the box "safe" for my USB Key
> doing nothing else !!!

No , i don't want to continue this topic deeper. Only a short answer on the last above question would be nice.

User avatar
raulfg3
Site Admin
Site Admin
Posts: 5116
Joined: 22 Jun 2012 22:13
Location: Madrid (ESPAÑA)
Contact:
Status: Offline

Re: A small script problem

#10

Post by raulfg3 »

redline wrote:> But for my personal peace of mind it would be nice if you can proof that embedded install is out of the box "safe" for my USB Key
> doing nothing else !!!
YES is safe, but only one matization.

If use fuppes define path for all paths that fuppes want, if not defined (if use default), the default path are /var and /temp ) so your USB is writting by fuppes and can have errors ( not enought space or R/W problems).

The same applies to Transmission (Torrent) service.
12.0.0.4 (revision 6766)+OBI on SUPERMICRO X8SIL-F 8GB of ECC RAM, 12x3TB disk in 3 vdev in RaidZ1 = 32TB Raw size only 22TB usable

Wiki
Last changes

HP T510

redline
Starter
Starter
Posts: 69
Joined: 29 Dec 2012 19:23
Status: Offline

Re: A small script problem

#11

Post by redline »

> matization
I googled for it and also every english translator i know cannot give me a sensefull translation for it.

Fuppes:
I meanwhile googled around. In the moment i don't have plans for any DLNA service. So fuppes is not on my wish list yet.
But i keep your tips in mind if i someday need this. Thanx a lot for your help.

User avatar
raulfg3
Site Admin
Site Admin
Posts: 5116
Joined: 22 Jun 2012 22:13
Location: Madrid (ESPAÑA)
Contact:
Status: Offline

Re: A small script problem

#12

Post by raulfg3 »

Sorry for my englis ; Matization = Clarification or nuance = Matización in Spanish
12.0.0.4 (revision 6766)+OBI on SUPERMICRO X8SIL-F 8GB of ECC RAM, 12x3TB disk in 3 vdev in RaidZ1 = 32TB Raw size only 22TB usable

Wiki
Last changes

HP T510

redline
Starter
Starter
Posts: 69
Joined: 29 Dec 2012 19:23
Status: Offline

Re: A small script problem

#13

Post by redline »

Lol ;) Even with the spanglish translation's it makes no sense in my language (german)
But okay ... Maybe when it happen's some day, i knew what was meaned.
Let's take it as running gag. At least it "sounds" very good ;)

fsbruva
Advanced User
Advanced User
Posts: 378
Joined: 21 Sep 2012 14:50
Status: Offline

Re: A small script problem

#14

Post by fsbruva »

Do you want to run the script from the console? Or as a cron job?

If from the console, then you can just use the alias command. If this works as you expect, then you can modify your ~/.cshrc to setup your alias(es) everytime you log in.

fsbruva
Advanced User
Advanced User
Posts: 378
Joined: 21 Sep 2012 14:50
Status: Offline

Re: A small script problem

#15

Post by fsbruva »

Also, re: your RAM questions - are the loader values similar to this? viewtopic.php?f=66&t=1527

Post Reply

Return to “Scripts and shell tips”