导航

一键脚本: 部署 Transmission 和 h5ai 实现离线下载及在线播放

• May 9, 2017 • Read: 1056 • 每日必看

文章获取自:Leonn 的博客:一键脚本: 部署 Transmission 和 h5ai 实现离线下载及在线播放 转载自:萌咖,Shell script for Linux written by Vicer.

说明

此 Linux Shell 会自动安装 PHP,Transmission,Nginx 等相关程序,并根据用户输入的数据进行配置程序.
Transmission: 用于下载. torrent 文件,实现离线下载;
h5ai: 用于显示目录的 PHP 程序,可在线播放。
仅适用于 Debian 系统, 已在 Debian 7 和 Debian 8 上顺利通过测试. 其他系统请自行测试。

特别注意

为了能顺利安装, 请使用纯净系统安装.
h5ai 默认密码: MoeClub.org,使用时请自行更改 h5ai 默认密码.
Transmission 默认用户名: MoeClub.org, 默认密码: Vicer
安装时请勿 https 地址, 如需要请在安装完成后自行配置.
如果需要下载磁力链接或其他协议的链接, 请安装 aria2. 可以参照: 修改 Debain 软件源中软件的源码并重新打包 进行安装.
改进

优化了 WebUI 界面 html 源码, 提高加载速度.
修改 h5ai 源码, 提供 Transmission 的入口.
修复 Transmission 不能使用 SSL 的 Tracker 的问题.

演示

H5ai

请输入图片描述

电脑界面

请输入图片描述

手机界面

请输入图片描述

脚本安装

  • 下载:

    wget --no-check-certificate -qO '/tmp/OneKeyForPT.sh'

    https://moeclub.org/attachment/LinuxShell/OneKeyForPT.sh'
    
  • 使用方法:

    Usage:

           bash OneKeyForPT.sh     -L/--url 'http://moeclub.org'
                                   -U/--UserName 'MoeClub.org'
                                   -P/--PassWord 'Vicer'
    

运行安装

-L 后的参数请自行改为自己的网址,如果想直接 IP 访问就写 http://IP 地址;
-U 后的参数请自行填写你自己默认的用户名
-P 后的桉树请自行填写你自己默认的密码

bash /tmp/OneKeyForPT.sh -L 'http://domain.ltd' -U 'User' -P 'Passwd'
  • h5ai 二维码功能 (默认为关闭状态)
  • 打开二维码功能
sed -i 's|"qrcode":.*|"qrcode": true,|g' '/data/www/_h5ai/private/conf/options.json'
  • 关闭二维码功能
sed -i 's|"qrcode":.*|"qrcode": false,|g' '/data/www/_h5ai/private/conf/options.json'
  • 完整代码:

!/bin/bash

while [[ $# -ge 1 ]]; do
case $1 in

-L|-l|--url)
  shift
  tmpMyLink="$1"
  shift
  ;;
-U|-u|--UserName)
  shift
  tmpMyUserName="$1"
  shift
  ;;
-P|-p|--PassWord)
  shift
  tmpMyPassWord="$1"
  shift
  ;;
*|--help)
  echo -ne " Usage:\n\tbash $0\t-L/--url \033[33m'\033[04mhttp://moeclub.org\033[0m\033[33m'\033[0m\n\t\t\t\t-U/--UserName \033[33m'\033[04mMoeClub.org\033[0m\033[33m'\033[0m\n\t\t\t\t-P/--PassWord \033[33m'\033[04mVicer\033[0m\033[33m'\033[0m\n"
  exit 1;
  ;;
esac

done

function CHECK()
{
MyLink=$tmpMyLink
MyUserName=$tmpMyUserName
MyPassWord=$tmpMyPassWord
[ -z $MyLink ] && echo "Please input your URL! " && exit 1;
MyDomian="$(echo -n "$MyLink" |awk -F '//' '{print $2}')"
[ -z $MyDomian ] && echo -e "URL Error! ( exp:033[33m'033[04mhttp://moeclub.org033[0m033[33m'033[0m )" && exit 1;
}

function UPDATE_SRC()
{
[ ! -f /etc/os-release ] && echo "Not Found Version! " && exit 1;
[ -f /etc/os-release ] && DEB_VER="$(awk -F'[= "]' '/VERSION_ID/{print $3}' /etc/os-release)"
[ -z $DEB_VER ] && echo "Error, Found Version! " && exit 1;
sed -i '/debian wheezy main/'d /etc/apt/sources.list
sed -i '/debian wheezy-backports main/'d /etc/apt/sources.list
sed -i '/debian wheezy-updates main/'d /etc/apt/sources.list
sed -i '/debian jessie main/'d /etc/apt/sources.list
sed -i '/debian jessie-backports main/'d /etc/apt/sources.list
sed -i '/debian jessie-updates main/'d /etc/apt/sources.list
sed -i '/multimedia/'d /etc/apt/sources.list
echo "deb http://httpredir.debian.org/debian wheezy main" >>/etc/apt/sources.list
echo "deb-src http://httpredir.debian.org/debian wheezy main" >>/etc/apt/sources.list
[ "$DEB_VER" == '7' ] && echo "deb http://httpredir.debian.org/debian wheezy-backports main" >> /etc/apt/sources.list
[ "$DEB_VER" == '7' ] && echo "deb-src http://httpredir.debian.org/debian wheezy-backports main" >> /etc/apt/sources.list
[ "$DEB_VER" == '7' ] && echo "deb http://httpredir.debian.org/debian wheezy-updates main" >> /etc/apt/sources.list
[ "$DEB_VER" == '7' ] && echo "deb-src http://httpredir.debian.org/debian wheezy-updates main" >> /etc/apt/sources.list
echo "deb http://httpredir.debian.org/debian jessie main" >>/etc/apt/sources.list
echo "deb-src http://httpredir.debian.org/debian jessie main" >>/etc/apt/sources.list
[ "$DEB_VER" == '8' ] && echo "deb http://httpredir.debian.org/debian jessie-backports main" >> /etc/apt/sources.list
[ "$DEB_VER" == '8' ] && echo "deb-src http://httpredir.debian.org/debian jessie-backports main" >> /etc/apt/sources.list
[ "$DEB_VER" == '8' ] && echo "deb http://httpredir.debian.org/debian jessie-updates main" >> /etc/apt/sources.list
[ "$DEB_VER" == '8' ] && echo "deb-src http://httpredir.debian.org/debian jessie-updates main" >> /etc/apt/sources.list
echo "deb http://www.deb-multimedia.org wheezy main non-free" >>/etc/apt/sources.list
sed -i '/deb cdrom/'d /etc/apt/sources.list
sed -i '/^$/'d /etc/apt/sources.list
[ "$DEB_VER" == '7' ] && {
[ -f /etc/apt/preferences ] && mv -f /etc/apt/preferences /etc/apt/preferences.bak
cat >/etc/apt/preferences<<EOFSRC
Package: *
Pin: release wheezy-backports
Pin-Priority: 70

Package: *
Pin: release jessie
Pin-Priority: 60

Package: *
Pin: release jessie-backports
Pin-Priority: 50
EOFSRC
}
[ "$DEB_VER" == '8' ] && {
[ -f /etc/apt/preferences ] && mv -f /etc/apt/preferences /etc/apt/preferences.bak
cat >/etc/apt/preferences<<EOFSRC
Package: *
Pin: release jessie-backports
Pin-Priority: 70

Package: *
Pin: release wheezy
Pin-Priority: 60
EOFSRC
}
}

function INSTALL_SRC()
{
apt-get update;
DEBIAN_FRONTEND=noninteractive apt-get install -y --force-yes deb-multimedia-keyring;
apt-get -qq update;
DEBIAN_FRONTEND=noninteractive apt-get install -y lsb-release curl sed gawk openssl autogen autoconf automake gettext pkg-config make gcc m4 libtool zlib1g-dev libpcre3 libpcre3-dev insserv e2fslibs;
DEBIAN_FRONTEND=noninteractive apt-get install -y nginx nginx-common spawn-fcgi libfcgi0ldbl fcgiwrap p7zip-full unzip vnstat ffmpeg;
apt-get -qq update;
DEBIAN_FRONTEND=noninteractive apt-get install -y -q -t wheezy transmission transmission-common transmission-daemon
apt-get -qq update;
DEBIAN_FRONTEND=noninteractive apt-get install -y -q -t jessie libcurl3-gnutls
DEBIAN_FRONTEND=noninteractive apt-get install -y -q -t jessie php5 php5-cgi php5-gd php-apc;
}

function REMOVE_SRC()
{
apt-get -y -qq --force-yes remove --purge apache bind9 >/dev/null 2>&1
apt-get -y -qq autoremove >/dev/null 2>&1
}

function TRANSMISSION_CONFIG()
{
bash /etc/init.d/transmission-daemon stop
mkdir -p /tmp
mkdir -p /etc/transmission-daemon
mkdir -p /usr/share/transmission
rm -rf /usr/share/transmission/*
wget --no-check-certificate -q -O '/tmp/Transmission.zip' 'https://moeclub.org/attachment/LinuxSoftware/transmission/Transmission.zip.deb'
7z x /tmp/Transmission.zip -o/usr/share/transmission
rm -rf /etc/transmission-daemon/settings.json
wget --no-check-certificate -q -O '/etc/transmission-daemon/settings.json' 'https://moeclub.org/attachment/LinuxSoftware/transmission/settings.json'
[ -f '/etc/init.d/transmission-daemon' ] && sed -i s'/^USER=.*/USER=root/g' /etc/init.d/transmission-daemon
mkdir -p /data/www;
mkdir -p /etc/transmission-daemon;
mkdir -p /usr/share/transmission;
mkdir -p /var/lib/transmission-daemon;
sed -i 's|http://moeclub.org|'$MyLink'|g' /usr/share/transmission/web/index.html
sed -i 's|http://moeclub.org|'$MyLink'|g' /usr/share/transmission/web/index.mobile.html
[ -n $MyUserName ] && sed -i 's|MoeClub.org|'$MyUserName'|g' /etc/transmission-daemon/settings.json
[ -n $MyPassWord ] && sed -i 's|Vicer|'$MyPassWord'|g' /etc/transmission-daemon/settings.json
bash /etc/init.d/transmission-daemon restart
}

function H5AI_CONFIG()
{
mkdir -p /data/www
rm -rf /data/www/*
mkdir -p /data/www/download
mkdir -p /tmp
wget --no-check-certificate -qO /tmp/h5ai.zip 'https://moeclub.org/attachment/LinuxSoftware/directory/h5ai.zip.deb'
[ -f /tmp/h5ai.zip ] && 7z x /tmp/h5ai.zip -o/data/www;
[ -f /data/www/_h5ai/public/js/scripts.js ] && sed -i 's|http://moeclub.org|'$MyLink'/dl|' /data/www/_h5ai/public/js/scripts.js
chown -R www-data:www-data /data/www;
chmod -R a+x /data/www;
}

function NGINX_CONFIG()
{
mkdir -p /etc/nginx
rm -rf /etc/nginx/*
rm -rf /usr/share/nginx/www
mkdir -p /etc/nginx/sites-available
wget --no-check-certificate -qO '/etc/nginx/example' 'https://moeclub.org/attachment/LinuxSoftware/nginx/config/example'
wget --no-check-certificate -qO '/etc/nginx/fcgiwrap' 'https://moeclub.org/attachment/LinuxSoftware/nginx/config/fcgiwrap'
wget --no-check-certificate -qO '/etc/nginx/fcgiwrap-php' 'https://moeclub.org/attachment/LinuxSoftware/nginx/config/fcgiwrap-php'
wget --no-check-certificate -qO '/etc/nginx/fastcgi_params' 'https://moeclub.org/attachment/LinuxSoftware/nginx/config/fastcgi_params'
wget --no-check-certificate -qO '/etc/nginx/fcgiwrap.conf' 'https://moeclub.org/attachment/LinuxSoftware/nginx/config/fcgiwrap.conf'
wget --no-check-certificate -qO '/etc/nginx/nginx.conf' 'https://moeclub.org/attachment/LinuxSoftware/nginx/config/nginx.conf'
cp -f /etc/nginx/example /etc/nginx/sites-available/h5ai
sed -i 's|stie.moeclub.org|'$MyDomian'|' /etc/nginx/sites-available/h5ai
chmod -R a+x /etc/nginx;
ln -sf /etc/nginx/fcgiwrap /etc/init.d/fcgiwrap;
ln -sf /etc/nginx/fcgiwrap-php /etc/init.d/fcgiwrap-php;
update-rc.d -f fcgiwrap remove
update-rc.d fcgiwrap defaults
update-rc.d -f fcgiwrap-php remove
update-rc.d fcgiwrap-php defaults
bash /etc/init.d/fcgiwrap-php restart
bash /etc/init.d/nginx restart
}

CHECK;
REMOVE_SRC;
UPDATE_SRC;
INSTALL_SRC;
TRANSMISSION_CONFIG;
H5AI_CONFIG;
NGINX_CONFIG;

Tags: 分享
查看所有文章 QR Code Tip
QR Code for this page
Tipping QR Code
0:00