https://github.com/ali-raheem/jukebox-rust
🎹 Implementation of my jukebox application in rust.
https://github.com/ali-raheem/jukebox-rust
database jukebox rfid-tags
Last synced: 6 months ago
JSON representation
🎹 Implementation of my jukebox application in rust.
- Host: GitHub
- URL: https://github.com/ali-raheem/jukebox-rust
- Owner: ali-raheem
- License: other
- Created: 2015-10-11T17:27:50.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2022-01-20T13:43:59.000Z (over 4 years ago)
- Last Synced: 2025-02-13T11:50:13.598Z (over 1 year ago)
- Topics: database, jukebox, rfid-tags
- Language: Rust
- Homepage:
- Size: 2.89 MB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Jukebox-rust
Rust application that links RFID tags to scripts - tap a card to play an album, open a picture, or trigger any action.
GPLv2 | v0.3.0
## Usage
```
jukebox [options]
Options:
-h, --help Print this usage information.
-n, --new Start new database.
-a, --add Add mode, add new action triggers to database.
-f, --database PATH Database file (default: ./jukebox.db)
-p, --port PATH Serial port (default: /dev/ttyACM0)
-s, --split START:LENGTH
Key trimming parameters (default: 3:10)
-d, --scripts PATH Script directory (default: /etc/jukebox.d)
```
## Building
Requires sqlite3 development libraries:
```bash
# Fedora/RHEL
sudo dnf install libsqlite3x-devel
# Debian/Ubuntu
sudo apt install libsqlite3-dev
```
Build:
```bash
cargo build --release
```
## Setup
### 1. Create script directory
```bash
sudo mkdir -p /etc/jukebox.d
sudo chown root:root /etc/jukebox.d
sudo chmod 755 /etc/jukebox.d
```
### 2. Add scripts
Create executable scripts for each action. Example:
```bash
# /etc/jukebox.d/play_jazz
#!/bin/bash
mpv /music/jazz/
```
Make scripts executable:
```bash
sudo chmod +x /etc/jukebox.d/*
```
### 3. Create database and register cards
```bash
jukebox -n -a
```
This creates a new database and enters add mode. The available scripts are listed. Tap a card, then enter the script name to associate with it. Repeat for each card. Press Ctrl+C when done.
### 4. Run in production
```bash
jukebox -f /etc/jukebox.db
```
## Security
This version uses a **script directory approach** instead of arbitrary shell commands:
- Only scripts in the designated directory (`/etc/jukebox.d`) can be executed
- Script names cannot contain path separators (no `../` attacks)
- Scripts are executed directly (no shell interpretation)
Recommendations:
- **Do not run jukebox as root** - spawned scripts inherit privileges
- Make scripts root-owned: `sudo chown root:root /etc/jukebox.d/*`
- Make database root-owned but world-readable
- Add your user to the `dialout` group for serial device access:
```bash
sudo usermod -a -G dialout $USER
```
## Migrating from 0.2.x
Version 0.3.0 introduces breaking changes:
1. Commands are no longer stored in the database - only script names
2. You must create scripts in `/etc/jukebox.d/` (or custom `-d` path)
3. Re-register your cards with `jukebox -a` using script names
## Changelog
See [CHANGELOG.md](CHANGELOG.md)