Last active
December 28, 2015 22:59
-
-
Save tonybolzan/7576056 to your computer and use it in GitHub Desktop.
Script para instalar um Media Server completo, Incluindo: plex, owncloud, transmission, bittorrent sync
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/bash | |
# Media Server | |
# Script para instalar um Media Server completo, Incluindo: plex, owncloud, transmission, bittorrent sync | |
# | |
# http://doc.owncloud.org/server/5.0/admin_manual/installation/installation_others.html#nginx-configuration | |
# http://btsync.s3-website-us-east-1.amazonaws.com/BitTorrentSyncUserGuide.pdf | |
# | |
# ownCloud http://localhost | |
# Plex http://localhost/plex | |
# Transmission http://localhost/torrent | |
# BitTorrent Sync http://localhost/sync | |
echo 'deb http://shell.ninthgate.se/packages/debian squeeze main' > /etc/apt/sources.list.d/plex.list | |
curl http://shell.ninthgate.se/packages/shell-ninthgate-se-keyring.key | apt-key add - | |
aptitude update | |
aptitude full-upgrade -y | |
aptitude install -y curl vim transmission-daemon nginx php5 php5-common php5-fpm php5-sqlite php5-gd php-xml-parser ntp plexmediaserver | |
mkdir -p /cloud/{torrent,owncloud} | |
chmod 770 /cloud/owncloud | |
chown www-data:www-data /cloud/owncloud | |
#------------------ | |
# ownCloud install | |
#------------------ | |
wget http://download.owncloud.org/community/owncloud-5.0.13.tar.bz2 | |
mkdir /var/www | |
tar -C /var/www/ -xvpjf owncloud-5.0.13.tar.bz2 | |
chown -R www-data:www-data /var/www | |
#------------------ | |
# btSync install | |
#------------------ | |
wget http://download-lb.utorrent.com/endpoint/btsync/os/linux-x64/track/stable -O btsync_x64.tar.gz | |
tar -C /usr/local/bin/ -xvzpf btsync_x64.tar.gz btsync | |
rm -f btsync_x64.tar.gz | |
chmod 755 /usr/local/bin/btsync | |
mkdir -p /etc/btsync/data | |
cat > /etc/btsync/default.conf <<'EOF' | |
{ | |
"device_name": "Cloud Server", | |
"listening_port" : 0, | |
"storage_path" : "/etc/btsync/data", | |
"pid_file" : "/var/run/btsync.pid", | |
"check_for_updates" : true, | |
"use_upnp" : true, | |
"download_limit" : 0, | |
"upload_limit" : 0, | |
"webui" : { | |
"listen" : "0.0.0.0:8888", | |
"login" : "admin", | |
"password" : "admin" | |
} | |
} | |
EOF | |
cat > /etc/init.d/btsync <<'EOF' | |
#! /bin/sh | |
case "$1" in | |
start) | |
btsync --config /etc/btsync/default.conf | |
;; | |
stop) | |
killall btsync | |
;; | |
restart) | |
killall btsync | |
btsync --config /etc/btsync.conf | |
;; | |
*) | |
echo "Usage: service btsync {start|stop}" | |
exit 1 | |
;; | |
esac | |
exit 0 | |
EOF | |
chmod 755 /etc/init.d/btsync | |
update-rc.d btsync defaults | |
service btsync stop | |
service plexmediaserver stop | |
service transmission-daemon stop | |
service nginx stop | |
#------------------ | |
# Transmission conf | |
#------------------ | |
cat > /etc/transmission-daemon/settings.json <<'EOF' | |
{ | |
"alt-speed-down": 50, | |
"alt-speed-enabled": false, | |
"alt-speed-time-begin": 540, | |
"alt-speed-time-day": 127, | |
"alt-speed-time-enabled": false, | |
"alt-speed-time-end": 1020, | |
"alt-speed-up": 50, | |
"bind-address-ipv4": "0.0.0.0", | |
"bind-address-ipv6": "::", | |
"blocklist-enabled": false, | |
"blocklist-url": "http://www.example.com/blocklist", | |
"cache-size-mb": 4, | |
"dht-enabled": true, | |
"download-dir": "/cloud/torrent/", | |
"download-limit": 100, | |
"download-limit-enabled": 0, | |
"download-queue-enabled": true, | |
"download-queue-size": 5, | |
"encryption": 1, | |
"idle-seeding-limit": 30, | |
"idle-seeding-limit-enabled": false, | |
"incomplete-dir": "/cloud/torrent/", | |
"incomplete-dir-enabled": false, | |
"lpd-enabled": false, | |
"max-peers-global": 200, | |
"message-level": 2, | |
"peer-congestion-algorithm": "", | |
"peer-limit-global": 240, | |
"peer-limit-per-torrent": 60, | |
"peer-port": 51413, | |
"peer-port-random-high": 65535, | |
"peer-port-random-low": 49152, | |
"peer-port-random-on-start": false, | |
"peer-socket-tos": "default", | |
"pex-enabled": true, | |
"port-forwarding-enabled": false, | |
"preallocation": 1, | |
"prefetch-enabled": 1, | |
"queue-stalled-enabled": true, | |
"queue-stalled-minutes": 30, | |
"ratio-limit": 2, | |
"ratio-limit-enabled": false, | |
"rename-partial-files": true, | |
"rpc-enabled": true, | |
"rpc-bind-address": "0.0.0.0", | |
"rpc-port": 9091, | |
"rpc-url": "/torrent", | |
"rpc-authentication-required": true, | |
"rpc-username": "admin", | |
"rpc-password": "admin", | |
"rpc-whitelist": "127.0.0.1", | |
"rpc-whitelist-enabled": true, | |
"scrape-paused-torrents-enabled": true, | |
"script-torrent-done-enabled": false, | |
"script-torrent-done-filename": "", | |
"seed-queue-enabled": false, | |
"seed-queue-size": 10, | |
"speed-limit-down": 100, | |
"speed-limit-down-enabled": false, | |
"speed-limit-up": 100, | |
"speed-limit-up-enabled": false, | |
"start-added-torrents": true, | |
"trash-original-torrent-files": false, | |
"umask": 18, | |
"upload-limit": 100, | |
"upload-limit-enabled": 0, | |
"upload-slots-per-torrent": 14, | |
"utp-enabled": true | |
} | |
EOF | |
#------------------ | |
# Nginx conf | |
#------------------ | |
cat > /etc/nginx/sites-available/default <<'EOF' | |
server { | |
listen 80; | |
location /torrent { | |
proxy_pass http://127.0.0.1:9091/torrent; | |
proxy_pass_header X-Transmission-Session-Id; | |
} | |
location /plex { | |
proxy_pass http://127.0.0.1:32400/web; | |
} | |
rewrite ^/sync /gui$1 last; | |
location /gui { | |
proxy_pass http://127.0.0.1:8888/gui; | |
proxy_buffering off; | |
proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; | |
} | |
root /var/www/owncloud; | |
client_max_body_size 10G; # set max upload size | |
index index.php; | |
error_page 403 /core/templates/403.php; | |
error_page 404 /core/templates/404.php; | |
location = /robots.txt { | |
allow all; | |
log_not_found off; | |
access_log off; | |
} | |
location ~ ^/(data|config|\.ht|db_structure\.xml|README) { | |
deny all; | |
} | |
location / { | |
rewrite ^/caldav(.*)$ /remote.php/caldav$1 redirect; | |
rewrite ^/carddav(.*)$ /remote.php/carddav$1 redirect; | |
rewrite ^/webdav(.*)$ /remote.php/webdav$1 redirect; | |
rewrite ^/.well-known/host-meta /public.php?service=host-meta last; | |
rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last; | |
rewrite ^/.well-known/carddav /remote.php/carddav/ redirect; | |
rewrite ^/.well-known/caldav /remote.php/caldav/ redirect; | |
rewrite ^(/core/doc/[^\/]+/)$ $1/index.html; | |
try_files $uri $uri/ index.php; | |
} | |
location ~ ^(.+?\.php)(/.*)?$ { | |
try_files $1 = 404; | |
include fastcgi_params; | |
fastcgi_buffers 64 4K; | |
fastcgi_param SCRIPT_FILENAME $document_root$1; | |
fastcgi_param PATH_INFO $2; | |
fastcgi_pass unix:/var/run/php5-fpm.sock; | |
} | |
} | |
EOF | |
service btsync start | |
service plexmediaserver start | |
service transmission-daemon start | |
service nginx start | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Install
curl https://gist.github.com/tonybolzan/7576056/raw/MediaServer.sh | bash