-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path20-couchpotato
89 lines (72 loc) · 3.8 KB
/
20-couchpotato
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/with-contenv bash
# permissions (recursive)
chown -R abc:abc \
/config
# If config doesn't exist yet, start couchpotato for 10 seconds to build config, then stop.
if ! [ -f /config/config.ini ]; then
timeout 10 /etc/services.d/couchpotato/run
fi
# set urlbase/webroot
sed -i '/\[core\]/,/^$/ s/url_base = .*/url_base = couchpotato/' /config/config.ini
# Set movie location
sed -i '/\[renamer\]/,/^$/ s/from = .*/from = \/downloads\/Downloads\/movie/' /config/config.ini
sed -i '/\[renamer\]/,/^$/ s/to = .*/to = \/downloads\/Movies/' /config/config.ini
sed -i '/\[manage\]/,/^$/ s/library = .*/library = \/downloads\/Movies/' /config/config.ini
sed -i '/\[manage\]/,/^$/ s/enabled = .*/enabled = 1/' /config/config.ini
#Set Transmission settings
#Set Transmission Host
sed -i '/\[transmission\]/,/^$/ s/host = .*/host = http:\/\/transmission:9091/' /config/config.ini
#Set Torrent Location
sed -i '/\[transmission\]/,/^$/ s/directory = .*/directory = \/downloads\/Downloads\/movie/' /config/config.ini
#Disable Blackhole
sed -i '/\[blackhole\]/,/^$/ s/enabled = .*/enabled = False/' /config/config.ini
#Set Sabnzbd category
sed -i '/\[sabnzbd\]/,/^$/ s/category = .*/category = movie/' /config/config.ini
#Set Sabnzbd host
sed -i '/\[sabnzbd\]/,/^$/ s/host = .*/host = http:\/\/sabnzbd:8080/' /config/config.ini
#Set Sabnzbd API key
sbAPI=$(cat /sabnzbdconfig/sabnzbd.ini | grep -m1 "api_key = ................................" | cut -d, -f2 | grep "api_key = ................................" | cut -d= -f2)
sed -i "/\[sabnzbd\]/,/^$/ s/api_key = .*/api_key =$sbAPI/" /config/config.ini
#Set nzb2media renamer settings
sed -i '/\[renamer\]/,/^$/ s/run_every = .*/run_every = 0/' /config/config.ini
sed -i '/\[renamer\]/,/^$/ s/force_every = .*/force_every = 0/' /config/config.ini
sed -i '/\[renamer\]/,/^$/ s/next_on_failed = .*/next_on_failed = False/' /config/config.ini
sed -i '/\[renamer\]/,/^$/ s/enabled = .*/enabled = 1/' /config/config.ini
#Set up nzbtomedia
### Copy the api key from the CP config file
### Write the API key for couchpotato
cpAPI=$(cat /config/config.ini | grep -m1 "api_key = ................................" | cut -d, -f2 | grep "api_key = ................................" | cut -d= -f2)
while [ ! -f /nzbtomedia/autoProcessMedia.cfg ]; do
sleep 1
echo "Waiting for nzbtomedia volume to be ready"
done
sleep 5
# Set couchpotato host
php /phpsed.php "/\[CouchPotato\].*?\[\[movie\]\].*?host =\K.*?$/sm" "couchpotato" /nzbtomedia/autoProcessMedia.cfg
php /phpsed.php "/\[CouchPotato\].*?\[\[movie\]\].*?apikey =\K.*?$/sm" "$cpAPI" /nzbtomedia/autoProcessMedia.cfg
## Enable CouchPotato post-processing
php /phpsed.php "/\[CouchPotato\].*?\[\[movie\]\]([^\[]*)\benabled =\s\K\S*/s" "1" /nzbtomedia/autoProcessMedia.cfg
php /phpsed.php "/\[CouchPotato\].*?\[\[movie\]\].*?web_root =\K.*?$/sm" " /couchpotato" /nzbtomedia/autoProcessMedia.cfg
# nzbToCouchPotato Post-Processing Settings
## Delete Failed, ignored.
php /phpsed.php "/\[CouchPotato\].*?\[\[movie\]\].*?delete_failed =\K.*?$/sm" " 1" /nzbtomedia/autoProcessMedia.cfg
php /phpsed.php "/\[CouchPotato\].*?\[\[movie\]\].*?delete_ignored =\K.*?$/sm" " 1" /nzbtomedia/autoProcessMedia.cfg
php /phpsed.php "/\[CouchPotato\].*?\[\[movie\]\].*?Torrent_NoLink =\K.*?$/sm" " 1" /nzbtomedia/autoProcessMedia.cfg
while [ ! -f /hydra2config/nzbhydra.yml ]; do
sleep 1
echo "Waiting for hydra2 config to be ready"
done
#Set Hydra2API
hydra2Api=$(php /phpmatchecho.php '/(?<=main:).*apiKey:\s"\K..........................(?=")/s' /hydra2config/nzbhydra.yml)
hydra2config=$(
cat <<-EOF
use = 1
extra_score = 1
enabled = True
custom_categories = 2000,2000,2000,2000,2000,2000
host = http://hydra2:5076/nzbhydra/
custom_tag = ,,,,,,
api_key = ,,,,,,$hydra2Api
EOF
)
php /phpsed.php '/\[newznab\]\s\K.*?(?=\n\n\[)/s' "$hydra2config" /config/config.ini