This repository has been archived by the owner on Feb 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathplexidrive.sh
73 lines (62 loc) · 2.07 KB
/
plexidrive.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
##################### PLEXiDRIVE #####################
## This script automates using a single or multiple ##
## Google Drive accounts as storage for a Plex ##
## server. ##
######################################################
# Make sure that this the ONLY instance of this script running
for pid in $(pidof -x plexidrive.sh); do
if [ $pid != $$ ]; then
echo "This script is already running, exiting to avoid duplicate uploads."
exit 1
fi
done
# Directory where this file exists
plexidrive_dir=`dirname $(realpath -s $0)`
cd "$plexidrive_dir"
# Read in configuration file
if [ -e ./plexidrive.conf ] ; then
source ./plexidrive.conf
else
echo "Configuration file - plexidrive.conf - not found."
echo "$(date +%F_%T) Configuration file - plexidrive.conf - not found." >> "$plexidrive_dir/upload-error"
exit 1
fi
# Create blank files if they don't exist yet
touch plex-scan
touch plex-scan.log
touch upload-error
# Check variables
if [ "$num_of_gdrives" -ne ${#drive_names[@]} ] ; then
echo "Number of gdrives does not match the number of drive names! Exiting..."
echo "$(date +%F_%T) Number of gdrives does not match the number of drive names! Exiting." >> "$plexidrive_dir/upload-error"
exit 1
fi
# Upload tv shows, if enabled
if [ "$enable_show_uploads" = true ] ; then
# Run the show upload script
./upload-shows.sh
# Check if script succeeded
if [ $? -ne 0 ]
then
echo "Upload shows script was unsuccessful, exiting plexidrive script."
exit 1
fi
fi
# Upload movies, if enabled
if [ "$enable_movie_uploads" = true ] ; then
# Run the movie upload script
./upload-movies.sh
# Check if script succeeded
if [ $? -ne 0 ]
then
echo "Upload movies script was unsuccessful, exiting plexidrive script."
exit 1
fi
fi
# # Scan new media folders with Plex CLI Scanner tool, if enabled
# if [ "$plex_scan_after_upload" = true ] ; then
# # Run the Plex scan script
# # If scanning enabled, must be ran as root user to execute the plex scanning script as the plex user
# sudo su -c './plex-scan.sh' plex
# fi