# ๐ Nofus - The NFS Mount Guardian
[](https://www.rust-lang.org/)
[](LICENSE)
[](https://github.com/kariudo/nofus/actions)
**Nofus** is a _blazingly fast and memory-safe_ Rust-powered daemon that vigilantly monitors your NFS mounts and triggers custom actions based on their availability. Never get caught with stale mounts again! ๐ก๏ธ
<p align="center">
<img src="https://media.giphy.com/media/3o7abKhOpu0NwenH3O/giphy.gif" alt="Important GIF" width="300"/>
</p>
## โจ Features
- ๐ต๏ธ **Real-time NFS Mount Monitoring** using Linux `inotify`
- โก **Configurable System Commands** for mount/unmount events
- ๐งช **Dry-Run Mode** for safe testing
- ๐ **Verbose Logging** for deep insights
- ๐ **Periodic Health Checks** (configurable interval)
- ๐ **YAML Configuration** for easy setup
## ๐ฆ Installation
1. **Prerequisites**: Ensure you have Rust installed (1.60+)
```bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```
2. **Install Nofus**:
```bash
cargo install nofus
```
## โ๏ธ Configuration
Create `config.yml` in your `$HOME/.config/nofus` directory:
```yaml
# Sample Configuration
mount_points:
- "/mnt/nfs/share1"
- "/media/cloud_storage"
delay_seconds: 5 # Check interval
# Commands to execute (supports full shell syntax)
all_mounted_cmd: "systemctl start my-app.service"
any_unmounted_cmd: "systemctl stop my-app.service && wall 'NFS Crisis!'"
```
> Note: If you start nofus without creating a configuration file first,
> one will be created from a template and nofus will exit.
## ๐ฆ Usage
```bash
nofus [OPTIONS]
```
**Options**:
- `--dry-run`: Simulate without executing commands
- `--verbose`: Show debug-level logging
**Example**:
```bash
nofus --verbose --dry-run
```
## ๐ฅ๏ธ Sample Workflow
```text
2023-09-15T14:30:00 [INFO] Initial state: All NFS mounts available โ
2023-09-15T14:35:22 [ERROR] NFS mount disconnected: /mnt/nfs/share1 โ
2023-09-15T14:35:22 [DEBUG] Executing: systemctl stop my-app.service
2023-09-15T14:36:45 [INFO] Mount recovered: /mnt/nfs/share1 โ
```
## ๐ค Contributing
We welcome contributions! Please follow these steps:
1. Fork the repository
2. Create a feature branch (`git checkout -b feat/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feat/amazing-feature`)
5. Open a Pull Request
## ๐ License
MIT License - see [LICENSE](LICENSE) for details.
<p align="center">
Made with โค๏ธ by <a href="https://github.com/kariudo">kariudo</a> |
โ <a href="https://buymeacoffee.com/kariudo">Support the developer</a>
</p>