a Node.JS script to auto-import USB drives that are attached to a computer. Use it to turn your NAS into a smart photo / file importer.

Overview

File Vacuum 5000

⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️

WARNING: This script is designed to manipulate files on both an external drive and another specified mount point on your file system using the super user account. This can have devestating consequences with the wrong config. I am not responsible for any data loss caused by misuse of this tool. Test it out and make sure you know what it's doing and how it works before using it for important data. You have been warned.

⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️

Import any disk into your computer automatically when it's plugged in. Designed to work with Ubuntu but should work with some other distros too. Written in Node.JS, File Vacuum detects newly plugged in disks, filters through all partitions, mounts them, and then checks for a "sync.json" file in the root of the drive. If the sync.json file is present, it pulls config from the file and beings an rsync of all files on the drive to the computer at a specified location.

Import hard drives, flash drives, or camera SD cards into your computer automatically by just plugging in the device. Email alerts on completion or error. Make your NAS server into a self-feeding file bucket, or install to your laptop for a quick and easy way to import drives.

Full Usage

Requirements

 - Node.JS
 - NPM
 - Yarn (but you could probably use NPM instead...)

MAKE SURE TO BE ROOT. You need root access for this script. It mounts and manipulates drives and filesystems, and root access is the easiest and cleanest way to do this. That means that the script needs to be started with sudo, and that pm2 should run the script as the root user if setting up auto boot.

First, clone the repo:

git clone https://github.com/jarethmt/File-Vacuum-5000

Then install npm dependencies:

yarn install

Now, create a file in the main app directory called "mailSettings.json", and fill it in with the following format, substituting your own email details:

{
    "from":"SERVER NAME <[email protected]>",
    "defaultRecipient": "[email protected]",
    "server":{
        "host": "your.smtp.server.com",
        "port": 465,
        "secure": true,
        "auth": {
            "user": "your_email",
            "pass": "your_password"
        }
    }
}

Start the server with sudo node . from the root directory of the project. You can also create a systemd job, or use pm2 in order to run this script in the background at boot. For example:

sudo su
yarn add pm2
pm2 start ./index.js
pm2 startup
pm2 save

Which will use the Node.JS pm2 package to persist this application in the back end.

After everything is installed and configured, test it out by grabbing a flash drive and loading a few sample files on it. Then, create a sync.json file in the root directory of the flash drive with the following format / details:

{
    email: [email protected],
    syncPath: /home/$USER/last-import,
    deleteAfter: false,
    user: uid,
    group: gid,
    permissions: xxx
}

Where uid is the user ID of the user you'd like the files to be owned by after sync is complete, same for gid. You can obtain these on Ubuntu with id -u $USER and id -g $USER. Permissions should be a 3 digit binary representation

Save this file, eject the drive, and then plug it back in, and you should see the script automatically copy everything over to your specified path on the computer! You'll receive a success email on completion. Even if you specify "true" for "deleteAfter", the sync.json will be preserved and left on the drive so that the next time you plug it in, it will sync again! Very useful for creating a physical drop box of sorts.

TODO

  • Create a safety check on import folder. An array of folders defined in the script which can not be synced to, in order to protect sensitive system directories.
You might also like...

An in-depth implementation of Clean Architecture using NestJS and type-script

Clean Architecture With NestJS Description It's been a while since my last article on how to implement clean architecture on Node.js applications, git

Dec 28, 2022

The Wholesome App. A project that allows you to upload images directly to MongoDB Atlas into your collection, a faster cloud database.

The Wholesome App. A project that allows you to upload images directly to MongoDB Atlas into your collection, a faster cloud database.

The Wholesome App. A project that allows you to upload images directly to MongoDB Atlas into your collection, a faster cloud database. To upload your cute and wholesome images.

Jul 17, 2022

📄 Easily implement pagination into your Knex.js project.

knex-pagination Easily implement pagination into your application. Usage const knex = require('knex'); const paginate = require('knex-pagination'); co

Apr 16, 2022

A JSON Database that saves your Json data in a file and makes it easy for you to perform CRUD operations.

What is dbcopycat A JSON Database that saves your Json data in a file and makes it easy for you to perform CRUD operations. ⚡️ Abilities Creates the f

Jan 8, 2023

An easy-to-use multi SQL dialect ORM tool for Node.js

Sequelize Sequelize is a promise-based Node.js ORM tool for Postgres, MySQL, MariaDB, SQLite and Microsoft SQL Server. It features solid transaction s

Jan 4, 2023

A WebAssembly build of the Tesseract OCR engine for use in the browser and Node

tesseract-wasm A WebAssembly build of the Tesseract OCR engine for use in the browser and Node. tesseract-wasm can detect and recognize text in docume

Dec 28, 2022

Zotero plugin for syncing items into a Notion database

Zotero plugin for syncing items into a Notion database

Notero A Zotero plugin that syncs items into a Notion database when added to a specific collection. Scaffolded with generator-zotero-plugin and built

Jan 9, 2023

Converts a MSSQL Result set into a markdown table, directly to stdout

Converts a MSSQL Result set into a markdown table, directly to stdout

mssql-result-to-md-table Tired of formating all the results of a SQL Server query into a markdown table? Well, well, well your problems are gone! Just

Feb 12, 2022

A tool to inject javascript into the Steam Deck client.

Steam Deck UI Inject A tool to inject javascript into the Steam Deck client. How it works This tool works by taking advantage of the remote debugging

Dec 5, 2022
Owner
null
Add hic et nunc data into your websites and Node.js scripts

hic et nunc API Guide Build websites and Node.js scripts with hic et nunc data hic et nunc is a decentralized NFT marketplace built on the Tezos block

Ian Petrarca 34 May 3, 2022
If you are a Slack browser user, this userscript will allow you to auto-redirect without Slack asking if you want to open on the desktop app.

Auto-redirect for browser Slack users If you are a Slack browser user, this userscript will allow you to auto-redirect without Slack asking if you wan

Felipe Santos (he/him) 6 Aug 23, 2022
Validate and auto-generate TypeScript types from raw SQL queries in PostgreSQL.

SafeQL Write SQL Queries With Confidence • Get started Install I would first recommend follow the instructions in the documentation. npm install --sav

null 747 Dec 28, 2022
Fast File is a quick and easy-to-use library to convert data sources to a variety of options.

Fast File Converter The Express.js's Fast File Converter Library Fast File Converter Library is a quick and easy-to-use library to convert data source

Ali Amjad 25 Nov 16, 2022
A database library stores JSON file for Node.js.

concisedb English | 简体中文 A database library stores JSON file for Node.js. Here is what updated every version if you want to know. API Document Usage B

LKZ烂裤子 3 Sep 4, 2022
Bluzelle is a smart, in-memory data store. It can be used as a cache or as a database.

SwarmDB ABOUT SWARMDB Bluzelle brings together the sharing economy and token economy. Bluzelle enables people to rent out their computer storage space

Bluzelle 225 Dec 31, 2022
Uniswapv2-pool-funding - A "Nugget Standard for Funding" compliant smart contract to provide liquidity to UniswapV2 (clone) pools. (Quickswap in this case)

uniswap(clone)-v2-pool-funding A smart contract that makes it easy to: supply liquidity to a uniswap(clone)-v2 pool using ERC20 or the network native

null 2 May 14, 2022
A Frida script to disable SSL certificate pinning in a target application

frida-android-unpinning A Frida script to disable SSL certificate pinning in a target application For more information and detailed setup instructions

HTTP Toolkit 325 Dec 29, 2022
Bulk follow GitHub users using a NodeJS script.

Github bulk follow Getting Started Prerequisites Clone the project to your local environment: git clone [email protected]:farid-ouachrar/github-bulk-

Farid Ouachrar 3 Sep 27, 2021
Ultimate Script to complete PostgreSQL-to-PostgreSQL Migration right after AWS DMS task done

Ultimate Script to complete PostgreSQL-to-PostgreSQL Migration right after AWS DMS task done

방신우 22 Dec 23, 2022