[systemd] Add path check for MP3 scrobbles
This commit is contained in:
27
bin/.bin/usb-move.sh
Executable file
27
bin/.bin/usb-move.sh
Executable file
@ -0,0 +1,27 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
SRC_DIR="/media/username/SANSA"
|
||||||
|
DEST_DIR="/home/powellc/var/rockbox/"
|
||||||
|
FILENAME="scrobbles.tsv"
|
||||||
|
|
||||||
|
WEBDAV_URL="https://box.unbl.ink/cloud/files/var/"
|
||||||
|
WEBDAV_USER="colin@unbl.ink"
|
||||||
|
WEBDAV_PASS=""
|
||||||
|
|
||||||
|
# Wait a moment to ensure mount is complete
|
||||||
|
sleep 2
|
||||||
|
|
||||||
|
if [ -f "$SRC_DIR/$FILENAME" ]; then
|
||||||
|
TIMESTAMP=$(date +"%Y%m%d-%H%M%S")
|
||||||
|
NEW_NAME="scrobbles-$TIMESTAMP.tsv"
|
||||||
|
|
||||||
|
# Backup locally
|
||||||
|
mv "$SRC_DIR/$FILENAME" "$DEST_DIR/$NEW_NAME"
|
||||||
|
|
||||||
|
# Send to WebDAV
|
||||||
|
curl -s --netrc -T "$LOCAL_PATH" "${WEBDAV_URL}${NEW_NAME}"
|
||||||
|
|
||||||
|
# Notify user
|
||||||
|
curl -s -d "Backed up $FILENAME locally and sent to Webdav" https://ntfy.unbl.ink/life >/dev/null
|
||||||
|
fi
|
||||||
9
systemd/.config/systemd/user/usb-move.path
Normal file
9
systemd/.config/systemd/user/usb-move.path
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Watch for USB mount to trigger file move
|
||||||
|
|
||||||
|
[Path]
|
||||||
|
PathExists=/media/powellc/SANSA
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=default.target
|
||||||
|
|
||||||
6
systemd/.config/systemd/user/usb-move.service
Normal file
6
systemd/.config/systemd/user/usb-move.service
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Move scrobble file when Sansa device is mounted
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=%h/.local/bin/usb-move.sh
|
||||||
Reference in New Issue
Block a user