-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmkPlex-iocage.sh
73 lines (63 loc) · 2.83 KB
/
mkPlex-iocage.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
#iocage Plex jail creation script
#User-defined vars
version='11.2-RELEASE'
name='plex'
plexpass=true
pkglist='plexpkglist'
notes='Plex: A media server application'
#If set to true, specify the proper paths below to create mount points, otherwise set as false
mount_movies=true
mount_tv=true
mount_music=true
#Put your desired MAC address here (useful for DHCP reservations)
macaddr='01234567890a'
#Should point to a dataset in a volume where Tautulli db/files will be stored outside of the jail
plexdata_mount_src='/path/on/volume/to/plexdataset'
#Path to Plex db/metadata in the jail, don't change unless you know what you're doing
plexdata_mount_dest='/usr/local/plexdata-plexpass'
movie_mount_src='/path/on/volume/to//movies'
movie_mount_dest='/path/in/jail/to/movies'
tv_mount_src='/path/on/volume/to//tv'
tv_mount_dest='/path/in/jail/to/tv'
music_mount_src='/path/on/volume/to//music'
music_mount_dest='/path/in/jail/to/music'
#Install plexmediaserver
if [ "$plexpass" == "true" ]; then
echo '{"pkgs":["plexmediaserver-plexpass"]}' > /tmp/$pkglist
else
echo '{"pkgs":["plexmediaserver"]}' > /tmp/$pkglist
fi
#Create the jail
iocage create -r $version -n $name -p /tmp/$pkglist vnet='on' host_hostname="$name" boot='on' notes="$notes" \
interfaces='vnet0:bridge0' dhcp='on' vnet0_mac="$macaddr" bpf='yes'
#Cleanup temp file
rm -f /tmp/$pkglist
#Enable Plex on boot and start the service
if [ "$plexpass" == "true" ]; then
iocage exec $name "pkg update && pkg upgrade; \
printf '\n#Plex Media Server\nplexmediaserver_plexpass_enable=\"YES\"\n' >> /etc/rc.conf; \
service plexmediaserver_plexpass start"
else
iocage exec $name "pkg update && pkg upgrade; \
printf '\n#Plex Media Server\nplexmediaserver_enable=\"YES\"\n' >> /etc/rc.conf; \
service plexmediaserver start"
fi
#Stop jail to add mount points
iocage stop $name
#Mount Plex dataset on volume to plexdata dir in jail
iocage fstab -a $name "$plexdata_mount_src $plexdata_mount_dest nullfs ro 0 0"
#Create media mount points
if [ "$mount_movies" == "true" ]; then iocage fstab -a $name "$movie_mount_src $movie_mount_dest nullfs rw 0 0"; fi
if [ "$mount_tv" == "true" ]; then iocage fstab -a $name "$tv_mount_src $tv_mount_dest nullfs rw 0 0"; fi
if [ "$mount_music" == "true" ]; then iocage fstab -a $name "$music_mount_src $music_mount_dest nullfs rw 0 0"; fi
#Change pkg to use the latest releases instead of quarterly, update pkg repo and upgrade existing pkgs, add rad motd
iocage exec $name "sed -i '' 's/quarterly/latest/' /etc/pkg/FreeBSD.conf; \
pkg update && pkg upgrade -y; \
tee /etc/motd << 'EOF'
______ __ ______ __ __
/\ == \ /\ \ /\ ___\ /\_\_\_\
\ \ _-/ \ \ \____ \ \ __\ \/_/\_\/_
\ \_\ \ \_____\ \ \_____\ /\_\/\_\
\/_/ \/_____/ \/_____/ \/_/\/_/
EOF"