npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-fstab

v1.0.16

Published

fstab management with node.js

Downloads

1,298

Readme

node-fstab

by Moe Alam, Shinobi Systems

Currently for internal use at Shinobi Systems and is included in ShinobiCCTV software.

The node-fstab module provides a suite of tools for managing filesystem mounts in a Unix-like environment using Node.js. It includes functions to create mount points, mount/unmount filesystems, update and remove entries in /etc/fstab, list mounts, and retrieve disk usage information.

Installation

npm install node-fstab

Usage

Importing the Module

const { createMountPoint, mount, update, remove, list, remountAll, remount, unmount, getDiskUsage, writeReadStream, checkDiskPathExists, execAsync } = require('node-fstab');

Functions

createMountPoint(path)

Creates a directory for a mount point if it doesn’t already exist.

  • path: String - Path of the mount point.
  • Returns: An object with ok status and error message if any.

mount(server, remotePath, localPath, type = 'cifs', options = 'username=username,password=password')

Mounts a filesystem (e.g., CIFS or NFS) with customizable options.

  • server: String - The server IP or hostname.
  • remotePath: String - The remote directory to mount.
  • localPath: String - The local mount point path.
  • type: String - Filesystem type (default: 'cifs').
  • options: String - Mount options, such as credentials.

update(sourceTarget, localPath, mountType = 'cifs', fstabOptions = 'username=username,password=password,rw,iocharset=utf8,file_mode=0777,dir_mode=0777 0 0')

Updates or adds an entry in /etc/fstab. Removes any existing entry with the same localPath before appending a new entry.

  • sourceTarget: String - The source device or server path.
  • localPath: String - The mount point on the local system.
  • mountType: String - Type of filesystem (e.g., 'cifs').
  • fstabOptions: String - Mount options to be used in /etc/fstab.

remove(localPath)

Removes a mount entry from /etc/fstab based on localPath.

  • localPath: String - The mount point path to remove from /etc/fstab.

list()

Lists all entries in /etc/fstab as an array of objects.

  • Returns: An array of objects, each with device, mountPoint, type, and options.

remountAll()

Remounts all filesystems listed in /etc/fstab.

  • Returns: An object with ok status and message upon completion.

remount(mountPath)

Remounts a specific mount point defined in /etc/fstab.

  • mountPath: String - Path of the mount point to remount.

unmount(localPath)

Unmounts a specified mount point.

  • localPath: String - The local path to unmount.

getDiskUsage()

Provides disk usage information using df -h as an array of objects.

  • Returns: An array of objects, each with fields from df -h such as filesystem, size, used, avail, use%, and mounted.

checkDiskPathExists(localPath)

Checks if a specific path exists among the mounted filesystems.

  • localPath: String - The path to check.

writeReadStream(readerStream, outputFile)

Pipes data from a read stream to an output file with error handling.

  • readerStream: Stream - The read stream to pipe data from.
  • outputFile: String - The output file to write data to.

Examples

Mount a CIFS Share

const { mount } = require('node-fstab');

(async () => {
  const server = '192.168.1.200';
  const remotePath = '/shared/folder';
  const localPath = '/mnt/cifs_share';
  const options = 'username=myuser,password=mypass';

  const response = await mount(server, remotePath, localPath, 'cifs', options);
  if (response.ok) {
    console.log(`Mounted CIFS share at ${localPath}`);
  } else {
    console.error(`Error: ${response.error}`);
  }
})();

License

This project is licensed under the MIT License.