nas ops cmd

This is my op script.

This is stupidly simple script to elevate priviledges in order to manage NFS shares on my QNAP NAS.

The idea is that NFS shares do squash-root so admin access is disallowed through NFS. This gives a convenient way to issue root level commands without using NFS but instead use ssh (and ssh authentication) to do this, which should provide stronger security.

This script makes the following assumptions:

  • the user has a ssh-key with admin access on the NAS.
  • NFS is mounted using autofs and is on the /net virtual folder.

The way it works is that it uses the current working directory when the command is launch. It then resolves any symlink path and check is the directory is in the /net/ virtual folder so the NFS server is the second component of the path.