-
Notifications
You must be signed in to change notification settings - Fork 0
/
tagmusic
executable file
·50 lines (38 loc) · 1.1 KB
/
tagmusic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
# Check if server argument is supplied
if [ -z "$1" ]
then
echo "No argument supplied"
exit 1
fi
# Get working directory
working_dir=$(dirname -- "$( readlink -f -- "$0")")
# Get the configuration file path
config_file="$working_dir/tagmusic_config.json"
# Get the server directory
server_dir=$1
# Create a temporary mount directory
mount_dir=$(mktemp -d)
# Check if the temporary mount directory was created successfully
if [[ -d "$mount_dir" ]]; then
echo "Temporary directory created: $mount_dir"
cd "$mount_dir" || exit 1
echo "Changed into directory: $(pwd)"
else
echo "Failed to create temporary directory"
exit 1
fi
# Trap cleanup statements
trap "fusermount3 -u -z $mount_dir; rmdir $mount_dir; [[ $? -eq 0 ]] && echo Cleaned up temporary directory" EXIT
# Mount the server directory
sshfs "$server_dir" "$mount_dir"
if [[ $? -ne 0 ]]; then
exit 1
fi
cd "$mount_dir"
# Tag files
onetagger-cli autotagger --config "$config_file" --path "$mount_dir"
# Trap
# fusermount3 -u -z $mount_dir
# rmdir $mount_dir
# [[ $? -eq 0 ]] && echo 'Temporary directory deleted'