Last active
June 18, 2024 23:49
-
-
Save Limych/eeef7347baab216d73dfb83a6247b676 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Script for automatic installation mediaserver on TrueNAS: | |
# Torrent client, Sonarr, Radarr, Lidarr and some support programs. | |
# Create new TrueNAS jail using "Advanced jail creation". | |
# Ensure for switch on jail flag allow_mlock (REQUIRED) | |
# Jail flag allow_raw_sockets is helpful for troubleshooting (e.g. ping, traceroute) | |
# Setup jail's mountpoints. | |
# I suggest to mount all configs to /config and all media files to /media | |
# After the jail is created it could start automatically. One more property is required | |
# to be set in order for Radarr and Sonarr to see the storage space of your mounted | |
# media locations. Open a root shell on the server and enter these commands: | |
# iocage stop <jailname> | |
# iocage set enforce_statfs=1 <jailname> | |
# iocage start <jailname> | |
# then start this script: | |
# iocage console <jailname> | |
# fetch https://gist.githubusercontent.com/Limych/eeef7347baab216d73dfb83a6247b676/raw/truenas-media-jail.sh | |
# chmod +x truenas-media-jail.sh | |
# ./truenas-media-jail.sh | |
# Main prepare | |
######################################################################################## | |
rm /etc/localtime | |
ln -s /usr/share/zoneinfo/Europe/Moscow /etc/localtime | |
# | |
pw group add -n media -g 8675309 | |
pw user add media -c media -u 8675309 -g media -d /nonexistent -s /usr/bin/nologin | |
# | |
install -d /usr/local/etc/pkg/repos | |
cat >/usr/local/etc/pkg/repos/FreeBSD.conf <<__EOF__ | |
FreeBSD: { | |
url: "pkg+http://pkg.FreeBSD.org/\${ABI}/latest" | |
} | |
__EOF__ | |
# | |
IGNORE_OSVERSION=yes | |
pkg update && pkg upgrade -y | |
pkg install -y mono security/ca_root_nss | |
ln -s /usr/local/bin/mono /usr/bin/mono | |
# | |
BATCH=yes | |
cat >/etc/make.conf <<__EOF__ | |
ALLOW_UNSUPPORTED_SYSTEM=yes | |
__EOF__ | |
portsnap fetch extract | |
cd /usr/ports/ports-mgmt/portmaster | |
make install clean && rehash | |
cat >/usr/local/etc/portmaster.rc <<__EOF__ | |
PM_LOG=/var/log/portmaster.log | |
SAVE_SHARED=wopt | |
SAVE_SHARED=wopt | |
BACKUP=bopt | |
# Always delete stale distfiles without prompting (-d) | |
ALWAYS_SCRUB_DISTFILES=dopt | |
# Install packages for build-only dependencies (–packages-build) | |
PM_PACKAGES_BUILD=pmp_build | |
# Delete build-only dependencies when finished (–delete-build-only) | |
PM_DEL_BUILD_ONLY=pm_dbo | |
#Suppress the build confirmation message (–no-confirm) | |
PM_NO_CONFIRM=pm_no_confirm | |
__EOF__ | |
# Install Transmission | |
######################################################################################## | |
pkg install -y transmission-daemon transmission-web | |
rmdir /usr/local/etc/transmission/home | |
install -o transmission -g transmission -d /config/transmission | |
# | |
pw group mod media -m transmission | |
# | |
sysrc "transmission_enable=YES" | |
sysrc "transmission_conf_dir=/config/transmission/" | |
sysrc "transmission_download_dir=/config/transmission/Downloads" | |
service transmission start | |
# | |
# Install Transmission trackers list | |
pkg install -y transmission-utils | |
install -d /opt/bin | |
fetch -o /opt/bin/add-trackers-auto.sh https://raw.githubusercontent.com/AndrewMarchukov/tracker-add/master/tracker-add-auto.sh | |
fetch -o /usr/local/etc/rc.d/transmission_tracker_add https://raw.githubusercontent.com/AndrewMarchukov/tracker-add/master/transmission_tracker_add | |
chmod +x /opt/bin/add-trackers-auto.sh /usr/local/etc/rc.d/transmission_tracker_add | |
# | |
sed -i -e 's~user:password~\$\(cat /config/transmission/trackerslist.auth\)~' /opt/bin/add-trackers-auto.sh | |
# | |
service transmission_tracker_add start | |
# Install FlareSolverr | |
######################################################################################## | |
pkg install -y git npm-node14 chromium | |
cd /usr/local/share | |
git clone https://github.com/FlareSolverr/FlareSolverr.git | |
# | |
cd /usr/local/share/FlareSolverr | |
git checkout c99101f74 -f | |
setenv PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true | |
setenv PUPPETEER_EXECUTABLE_PATH /usr/local/bin/chrome | |
npm install | |
# | |
# patch away puppeteer's arbitrary FreeBSD blocking 🙄 | |
cd node_modules | |
patch -p1 <<__EOF__ | |
diff -Naur node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserFetcher.js node_modules_fixed/puppeteer/lib/cjs/puppeteer/node/BrowserFetcher.js | |
--- node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserFetcher.js 2022-09-30 11:53:41.991795021 +0100 | |
+++ node_modules_fixed/puppeteer/lib/cjs/puppeteer/node/BrowserFetcher.js 2022-09-30 11:53:10.867991454 +0100 | |
@@ -180,6 +180,8 @@ | |
this._platform = 'linux'; | |
else if (platform === 'win32') | |
this._platform = os.arch() === 'x64' ? 'win64' : 'win32'; | |
+ else if (platform === 'freebsd') | |
+ this._platform = 'linux' | |
else | |
(0, assert_js_1.assert)(this._platform, 'Unsupported platform: ' + platform); | |
} | |
@@ -505,4 +507,4 @@ | |
request.end(); | |
return request; | |
} | |
-//# sourceMappingURL=BrowserFetcher.js.map | |
\ No newline at end of file | |
+//# sourceMappingURL=BrowserFetcher.js.map | |
diff -Naur node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserFetcher.patch node_modules_fixed/puppeteer/lib/cjs/puppeteer/node/BrowserFetcher.patch | |
--- node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserFetcher.patch 1970-01-01 01:00:00.000000000 +0100 | |
+++ node_modules_fixed/puppeteer/lib/cjs/puppeteer/node/BrowserFetcher.patch 2022-09-30 11:52:26.293600027 +0100 | |
@@ -0,0 +1,8 @@ | |
+183,184d182 | |
+< else if (platform === 'freebsd') | |
+< this._platform = 'linux' | |
+510c508 | |
+< //# sourceMappingURL=BrowserFetcher.js.map | |
+--- | |
+> //# sourceMappingURL=BrowserFetcher.js.map | |
+\ No newline at end of file | |
__EOF__ | |
npm run build | |
# | |
cat >/usr/local/etc/rc.d/flaresolverr <<__EOF__ | |
#!/bin/sh | |
# | |
# Author: C. R. Zamana (czamana at gmail dot com) | |
# | |
# PROVIDE: flaresolverr | |
# REQUIRE: networking | |
# KEYWORD: | |
. /etc/rc.subr | |
name="flaresolverr" | |
rcvar="\${name}_enable" | |
load_rc_config \${name} | |
: \${flaresolverr_enable:="NO"} | |
pidfile="/var/run/flaresolverr.pid" | |
start_precmd="flaresolverr_precmd" | |
PATH=\$PATH:/usr/local/bin | |
flaresolverr_precmd() { | |
cd /usr/local/share/FlareSolverr | |
export PUPPETEER_EXECUTABLE_PATH=/usr/local/bin/chrome | |
export HOST=0.0.0.0 | |
} | |
command="/usr/sbin/daemon" | |
command_args="-P \${pidfile} /usr/local/bin/npm start > /dev/null" | |
run_rc_command "\$1" | |
__EOF__ | |
chmod +x /usr/local/etc/rc.d/flaresolverr | |
# | |
sysrc "flaresolverr_enable=YES" | |
service flaresolverr start | |
# Install Jackett | |
######################################################################################## | |
pkg install -y jackett | |
chown -R jackett:jackett /usr/local/share/jackett/ | |
install -o jackett -g jackett -d /config/jackett | |
chown -R jackett:jackett /config/jackett | |
# | |
pw group mod media -m jackett | |
# | |
sysrc "jackett_enable=YES" | |
sysrc "jackett_data_dir=/config/jackett" | |
service jackett start | |
# Install Radarr | |
######################################################################################## | |
pkg install -y radarr | |
chown -R radarr:radarr /usr/local/share/radarr/ | |
install -o radarr -g radarr -d /config/radarr | |
chown -R radarr:radarr /config/radarr | |
# | |
pw group mod media -m radarr | |
# | |
sysrc "radarr_enable=YES" | |
sysrc "radarr_data_dir=/config/radarr" | |
service radarr start | |
# Install Sonarr | |
######################################################################################## | |
pkg install -y sonarr | |
chown -R sonarr:sonarr /usr/local/share/sonarr/ | |
install -o sonarr -g sonarr -d /config/sonarr | |
chown -R sonarr:sonarr /config/sonarr | |
# | |
pw group mod media -m sonarr | |
# | |
sysrc "sonarr_enable=YES" | |
sysrc "sonarr_data_dir=/config/sonarr" | |
service sonarr start | |
# Install Lidarr | |
######################################################################################## | |
pkg install -y lidarr | |
chown -R lidarr:lidarr /usr/local/share/lidarr/ | |
install -o lidarr -g lidarr -d /config/lidarr | |
# | |
pw group mod media -m lidarr | |
# | |
sysrc "lidarr_enable=YES" | |
sysrc "lidarr_data_dir=/config/lidarr" | |
service lidarr start | |
# Install Plex | |
######################################################################################## | |
pkg install -y plexmediaserver | |
chown plex:plex /usr/local/share/plexmediaserver/ | |
install -o plex -g plex -d /config/plex | |
# | |
pw group mod media -m plex | |
# | |
sysrc "plexmediaserver_enable=YES" | |
sysrc "plexmediaserver_support_path=/config/plex/" | |
service plexmediaserver start | |
# Install Tautulli | |
######################################################################################## | |
pkg install -y tautulli | |
chown -R tautulli:tautulli /usr/local/www/tautulli/ | |
install -o tautulli -g tautulli -d /config/tautulli | |
chown -R tautulli:tautulli /config/tautulli | |
rm -Rf /var/db/tautulli | |
ln -s /config/tautulli/ /var/db/tautulli | |
# | |
pw group mod media -m tautulli | |
# | |
sysrc "tautulli_enable=YES" | |
sysrc "tautulli_flags=--datadir /config/tautulli" | |
service tautulli start | |
# Install Bazarr | |
######################################################################################## | |
pkg install -y bazarr | |
chown -R bazarr:bazarr /usr/local/share/bazarr/ | |
install -o bazarr -g bazarr -d /config/bazarr | |
chown -R bazarr:bazarr /config/bazarr | |
# | |
pw group mod media -m bazarr | |
# | |
sysrc "bazarr_enable=YES" | |
sysrc "bazarr_data_dir=/config/bazarr" | |
service bazarr start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment