-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathvolume-restore
More file actions
71 lines (62 loc) · 1.57 KB
/
Copy pathvolume-restore
File metadata and controls
71 lines (62 loc) · 1.57 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
#
# HiFiBerry Volume Restore Wrapper
#
# This script provides a simple interface to the volume restoration functionality
# and is designed to be called by systemd services or administrators.
#
set -e
# Default paths
PYTHON_SCRIPT="/usr/lib/python3/dist-packages/configurator/volume.py"
PYTHON_CMD="python3"
# Function to display usage
usage() {
echo "Usage: $0 [--store|--restore] [--verbose]"
echo " --store Store current volume settings"
echo " --restore Restore saved volume settings"
echo " --verbose Enable verbose output"
echo " --help Show this help message"
exit 1
}
# Function to check if the Python script exists
check_script() {
if [ ! -f "$PYTHON_SCRIPT" ]; then
echo "Error: Volume script not found at $PYTHON_SCRIPT" >&2
exit 1
fi
}
# Parse command line arguments
ACTION=""
VERBOSE=""
while [[ $# -gt 0 ]]; do
case $1 in
--store)
ACTION="--store"
shift
;;
--restore)
ACTION="--restore"
shift
;;
--verbose|-v)
VERBOSE="--verbose"
shift
;;
--help|-h)
usage
;;
*)
echo "Unknown option: $1" >&2
usage
;;
esac
done
# Check if action is specified
if [ -z "$ACTION" ]; then
echo "Error: Must specify either --store or --restore" >&2
usage
fi
# Check if the Python script exists
check_script
# Execute the Python script with the specified action
exec $PYTHON_CMD "$PYTHON_SCRIPT" $ACTION $VERBOSE