forked from tom472/mediabox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmediabox.sh
157 lines (139 loc) · 5.49 KB
/
mediabox.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#!/bin/bash
# Get local Username
localuname=`id -u -n`
# Get PUID
PUID=`id -u $localuname`
# Get GUID
PGID=`id -g $localuname`
# Get Hostname
thishost=`hostname`
# Get IP Address
locip=`hostname -I | awk '{print $1}'`
# Get Time Zone
time_zone=`cat /etc/timezone`
# CIDR - this assumes a 255.255.255.0 netmask - If your config is different use the custom CIDR line
lannet=`hostname -I | awk '{print $1}' | sed 's/\.[0-9]*$/.0\/24/'`
# Custom CIDR (comment out the line above if using this)
# Uncomment the line below and enter your CIDR info so the line looks like: lannet=xxx.xxx.xxx.0/24
#lannet=
# Get Private Internet Access Info
read -p "What is your PIA Username?: " piauname
read -s -p "What is your PIA Password? (Will not be echoed): " piapass
printf "\n\n"
# Get info needed for PLEX Official image
read -p "Which PLEX release do you want to run? By default 'public' will be used. (latest, public, plexpass): " pmstag
read -p "If you have PLEXPASS what is your Claim Token: (Optional) " pmstoken
# If not set - set PMS Tag to Public:
if [ -z "$pmstag" ]; then
pmstag=public
fi
# Get the info for the style of Portainer to use
read -p "Which style of Portainer do you want to use? By default 'No Auth' will be used. (noauth, auth): " portainerstyle
if [ -z "$portainerstyle" ]; then
portainerstyle=--no-auth
elif [ $portainerstyle == "noauth" ]; then
portainerstyle=--no-auth
elif [ $portainerstyle == "auth" ]; then
portainerstyle=
fi
# Create the directory structure
`mkdir -p content/completed`
`mkdir -p content/incomplete`
`mkdir -p content/movies`
#`mkdir -p /mnt/rclone-move/movies`
`mkdir -p content/tv`
#`mkdir -p /mnt/rclone-move/tv`
`mkdir -p couchpotato`
`mkdir -p delugevpn`
`mkdir -p delugevpn/config/openvpn`
`mkdir -p ombi`
`mkdir -p "plex/Library/Application Support/Plex Media Server/Logs"`
`mkdir -p plexpy`
`mkdir -p portainer`
`mkdir -p radarr`
`mkdir -p sickrage`
`mkdir -p sabnzbd`
`mkdir -p www`
# Move the PIA VPN files
`mv us-east.ovpn delugevpn/config/openvpn/us-east.ovpn`
`mv ca.ovpn delugevpn/config/openvpn/ca.ovpn`
`mv germany.ovpn delugevpn/config/openvpn/germany.ovpn`
`mv ca.rsa.2048.crt delugevpn/config/openvpn/ca.rsa.2048.crt`
`mv crl.rsa.2048.pem delugevpn/config/openvpn/crl.rsa.2048.pem`
###################
# TROUBLESHOOTING #
###################
# If you are having issues with any containers starting
# Or the .env file is not being populated with the correct values
# Uncomment the necessary line(s) below to see what values are being generated
# printf "### Collected Variables are echoed below. ###\n"
# printf "\n"
# printf "The username is: $localuname\n"
# printf "The PUID is: $PUID\n"
# printf "The PGID is: $PGID\n"
# printf "The current directory is: $PWD\n"
# printf "The IP address is: $locip\n"
# printf "The CIDR address is: $lannet\n"
# printf "The PIA Username is: $piauname\n"
# printf "The PIA Password is: $piapass\n"
# printf "The Hostname is: $thishost\n"
# printf "The Timezone is: $timezone\n"
# printf "The Plex version is: $pmstag\n"
# printf "The Plexpass Claim token is: $pmstoken\n"
# printf "The Portainer style is: $portainerstyle\n"
# printf "Note: A Portainer style of 'blank' = the 'Normal Auth' style\n"
# Create the .env file
echo "Creating the .env file with the values we have gathered"
printf "\n"
echo "LOCALUSER=$localuname" >> .env
echo "HOSTNAME=$thishost" >> .env
echo "IP_ADDRESS=$locip" >> .env
echo "PUID=$PUID" >> .env
echo "PGID=$PGID" >> .env
echo "PWD=$PWD" >> .env
echo "PIAUNAME=$piauname" >> .env
echo "PIAPASS=$piapass" >> .env
echo "CIDR_ADDRESS=$lannet" >> .env
echo "TZ=$time_zone" >> .env
echo "PMSTAG=$pmstag" >> .env
echo "PMSTOKEN=$pmstoken" >> .env
echo "PORTAINERSTYLE=$portainerstyle" >> .env
echo ".env file creation complete"
printf "\n\n"
# Download & Launch the containers
echo "The containers will now be pulled and launched"
echo "This may take a while depending on your download speed"
read -p "Press any key to continue... " -n1 -s
printf "\n\n"
`docker-compose up -d`
printf "\n\n"
# Let's configure the access to the Deluge Daemon for CouchPotato
echo "CouchPotato requires access to the Deluge daemon port and needs credentials set."
read -p "What would you like to use as the daemon access username?: " daemonun
read -p "What would you like to use as the daemon access password?: " daemonpass
printf "\n\n"
# Finish up the config
printf "Configuring Deluge daemon access - UHTTPD index file - Permissions \n\n"
# Configure DelugeVPN: Set Daemon access on, delete the core.conf~ file
`while [ ! -f delugevpn/config/core.conf ]; do sleep 1; done`
`docker stop delugevpn > /dev/null 2>&1`
`rm delugevpn/config/core.conf~ > /dev/null 2>&1`
`sed -i 's/"allow_remote": false,/"allow_remote": true,/g' delugevpn/config/core.conf`
`sed -i 's/"move_completed": false,/"move_completed": true,/g' delugevpn/config/core.conf`
`docker start delugevpn > /dev/null 2>&1`
# Push the Deluge Daemon Access info the to Auth file
`echo $daemonun:$daemonpass:10 >> ./delugevpn/config/auth`
# Configure UHTTPD settings and Index file
`docker stop uhttpd > /dev/null 2>&1`
`mv index.html www/index.html`
`sed -i "s/locip/$locip/g" www/index.html`
`sed -i "s/daemonun/$daemonun/g" www/index.html`
`sed -i "s/daemonpass/$daemonpass/g" www/index.html`
`cp .env www/env.txt`
`docker start uhttpd > /dev/null 2>&1`
# Fix the Healthcheck in Minio
docker exec minio sed -i "s/404/403/g" /usr/bin/healthcheck.sh
# Adjust the permissions on the content folder
`chmod -R 0777 content/`
printf "Setup Complete - Open a browser and go to: \n\n"
printf "http://$locip OR http://$thishost \n"