Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[SOLVED/WORKAROUND] Toggle samba share through shell?

Featured Replies

I am trying to turn on/off certain samba shares on a schedule using cron. What's the best command to pass? All I can think of is using sed to edit /etc/samba/smb-shares.conf, but this seems really complicated and would break the webgui options that were set. Is there a command that mimics what the webgui is doing when it turns on/off samba export or changes security options for a given share?

Edited by golli53
solved/workaround

  • 2 weeks later...
  • Author

Couldn't figure this out using the shell, but ended up writing a short Python script to toggle options through HTTP to the webgui. CSRF tokens made it a bit trickier. Can send it out if anyone is also looking for a solution.

1 hour ago, golli53 said:

Couldn't figure this out using the shell, but ended up writing a short Python script to toggle options through HTTP to the webgui. CSRF tokens made it a bit trickier. Can send it out if anyone is also looking for a solution.

So how did you do it? Would be very useful for me to be able to interact with the GUI but I don't know how to do it with Python.

  • Author
6 hours ago, testdasi said:

So how did you do it? Would be very useful for me to be able to interact with the GUI but I don't know how to do it with Python.

def toggle_unraid_share(url, setting=True, share_name='share'):
    from requests_html import HTMLSession
    session = HTMLSession()
    r = session.get(url)
    r.html.render()
    token = re.search(r"csrf_token=([A-Z0-9]+)", r.html.full_text).groups()[0]
    r2 = session.post(f"{url}/update.htm", 
        data={'shareName': share_name, 'shareExport': 'e' if setting else '-', 'shareSecurity': 'public', 'changeShareSecurity': 'Apply', 'csrf_token': token})
    r2.raise_for_status()
    session.close()

Here's the script in function form. Requires Python 3 and requests_html. Should be fairly easy to generalize it to other settings changes (by changing the data argument in the sessions.post call). URL is your unraid address, incl http(s)://

Edited by golli53

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.