forked from memehammad/jellyfinbackdrops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjellyfin_enable_backdrops_userscript.sh
50 lines (40 loc) · 1.37 KB
/
jellyfin_enable_backdrops_userscript.sh
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
#!/bin/bash
echo "Starting script..."
# Docker container name
CONTAINER_NAME="jellyfin"
# Path to the file inside the container
FILE_PATH="/usr/share/jellyfin/web/main.jellyfin.bundle.js"
# Backup directory (same as file location)
BACKUP_DIR="/usr/share/jellyfin/web/backups"
# Execute the replacement inside the Docker container
docker exec "$CONTAINER_NAME" /bin/bash -c '
# Create backup directory if it does not exist
mkdir -p "'$BACKUP_DIR'"
# Check if replacement is needed
if grep -q "enableBackdrops:function(){return R}" "'$FILE_PATH'"; then
echo "Modification needed. Proceeding with changes."
# Generate timestamp for backup filename
TIMESTAMP=$(date +"%Y%m%d_%H%M%S")
# Create backup of the original file
cp "'$FILE_PATH'" "'$BACKUP_DIR'/main.jellyfin.bundle.js.backup_$TIMESTAMP"
# Perform the replacement
sed -i "s/enableBackdrops:function(){return R}/enableBackdrops:function(){return E}/" "'$FILE_PATH'"
if [ $? -eq 0 ]; then
echo "Replacement completed successfully"
echo "Backup saved to: '$BACKUP_DIR'/main.jellyfin.bundle.js.backup_$TIMESTAMP"
else
echo "Replacement failed"
exit 1
fi
else
echo "No modification required. Existing configuration is correct."
exit 0
fi
'
# Check the exit status of the docker exec command
if [ $? -eq 0 ]; then
echo "Script completed successfully"
else
echo "Script failed"
exit 1
fi