How can I execute shell, to do create nfs shares?

Status
Not open for further replies.

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
You don't. You create NFS shares in FreeNAS using the WebGUI. While you could, in theory, force shares to be created and completely bypass the WebGUI, you'd be in for a shocker when FreeNAS tells you off and removes them on reboot or a cycle of the service because it recreates the nfs config files and it wouldn't include the shares you forced in.

So use the WebGUI and be happy. If this isn't satisfactory your option is to go to FreeBSD.
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
Yeah.. shell script won't even cover that. You could probably script something to use the FreeNAS API, but that's the closest to automating creation of large numbers of NFS shares without doing it manually.
 

freenas1

Dabbler
Joined
Feb 19, 2013
Messages
16
hello,
as i need it, here is the solution (temporary) i used to create nfs share without using WebGUI.
  • i have FreeNAS 8.3.1 and no API REST avalaible
  • i'm confident with django
My "script" is something like that:
Code:
from sharing.models import *
list_username = ('john', 'jean', ....)
for username in list_username:
  share = NFS_Share.objects.create(nfs_network='192.168.1.0/24 192.168.2.0/24', nfs_alldirs=True)
  share_path = NFS_Share_Path.objects.create(share=share, path='/mnt/rz2pool/accounts/%s' % username)

after that, i use two more commands:
Code:
service ix-nfsd start

Code:
kill -HUP `cat /var/run/mountd.pid`
 
J

jkh

Guest
Well, I guess we should be happy that at least you used django's ORM to make the changes rather than just banging on the sqlite database directly. ;-)

I think you did the best you could under the circumstances, and I see nothing wrong with your approach. For more recent versions of FreeNAS, using the REST API is definitely the preferred method, since we may someday change the underlying django implementation and the web API provides the right abstraction layer.
 

freenas1

Dabbler
Joined
Feb 19, 2013
Messages
16
you used django's ORM to make the changes rather than just banging on the sqlite database directly
this is just because i like Django (a very good choice imo), and i never use sqlite.

since we may someday change the underlying django implementation
but should you stay with Django?
 
Status
Not open for further replies.
Top