一键脚本: 部署 Transmission 和 h5ai 实现离线下载及在线播放 不死鸟 • May 9, 2017 • 每日必看 文章获取自: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/bashwhile [[ $# -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; ;; esacdonefunction CHECK(){MyLink=$tmpMyLinkMyUserName=$tmpMyUserNameMyPassWord=$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.org\033[0m\033[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.listsed -i '/debian wheezy-backports main/'d /etc/apt/sources.listsed -i '/debian wheezy-updates main/'d /etc/apt/sources.listsed -i '/debian jessie main/'d /etc/apt/sources.listsed -i '/debian jessie-backports main/'d /etc/apt/sources.listsed -i '/debian jessie-updates main/'d /etc/apt/sources.listsed -i '/multimedia/'d /etc/apt/sources.listecho "deb http://httpredir.debian.org/debian wheezy main" >>/etc/apt/sources.listecho "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.listecho "deb http://httpredir.debian.org/debian jessie main" >>/etc/apt/sources.listecho "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.listecho "deb http://www.deb-multimedia.org wheezy main non-free" >>/etc/apt/sources.listsed -i '/deb cdrom/'d /etc/apt/sources.listsed -i '/^$/'d /etc/apt/sources.list[ "$DEB_VER" == '7' ] && {[ -f /etc/apt/preferences ] && mv -f /etc/apt/preferences /etc/apt/preferences.bakcat >/etc/apt/preferences<<EOFSRCPackage: *Pin: release wheezy-backportsPin-Priority: 70Package: *Pin: release jessiePin-Priority: 60Package: *Pin: release jessie-backportsPin-Priority: 50EOFSRC}[ "$DEB_VER" == '8' ] && {[ -f /etc/apt/preferences ] && mv -f /etc/apt/preferences /etc/apt/preferences.bakcat >/etc/apt/preferences<<EOFSRCPackage: *Pin: release jessie-backportsPin-Priority: 70Package: *Pin: release wheezyPin-Priority: 60EOFSRC}}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-daemonapt-get -qq update;DEBIAN_FRONTEND=noninteractive apt-get install -y -q -t jessie libcurl3-gnutlsDEBIAN_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>&1apt-get -y -qq autoremove >/dev/null 2>&1}function TRANSMISSION_CONFIG(){bash /etc/init.d/transmission-daemon stopmkdir -p /tmpmkdir -p /etc/transmission-daemonmkdir -p /usr/share/transmissionrm -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/transmissionrm -rf /etc/transmission-daemon/settings.jsonwget --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-daemonmkdir -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.htmlsed -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.jsonbash /etc/init.d/transmission-daemon restart}function H5AI_CONFIG(){mkdir -p /data/wwwrm -rf /data/www/*mkdir -p /data/www/downloadmkdir -p /tmpwget --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.jschown -R www-data:www-data /data/www;chmod -R a+x /data/www;}function NGINX_CONFIG(){mkdir -p /etc/nginxrm -rf /etc/nginx/*rm -rf /usr/share/nginx/wwwmkdir -p /etc/nginx/sites-availablewget --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/h5aised -i 's|stie.moeclub.org|'$MyDomian'|' /etc/nginx/sites-available/h5aichmod -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 removeupdate-rc.d fcgiwrap defaultsupdate-rc.d -f fcgiwrap-php removeupdate-rc.d fcgiwrap-php defaultsbash /etc/init.d/fcgiwrap-php restartbash /etc/init.d/nginx restart}CHECK;REMOVE_SRC;UPDATE_SRC;INSTALL_SRC;TRANSMISSION_CONFIG;H5AI_CONFIG;NGINX_CONFIG; Archives QR Code Tip