This repository was archived by the owner on Feb 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinstall.sh
62 lines (55 loc) · 1.81 KB
/
install.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
#! /bin/bash
#====================================================================
# install.sh
#
# rTorrent + ruTorrent Auto Install Script
#
# Copyright (c) 2012, WangYan <[email protected]>
# All rights reserved.
# Distributed under the GNU General Public License, version 3.0.
#
# Intro: https://wangyan.org/blog/rtorrent-shell-script.html
#
#====================================================================
if [ $(id -u) != "0" ]; then
clear && echo "Error: You must be root to run this script!"
exit 1
fi
RTRUT_PATH=`pwd`
if [ `echo $RTRUT_PATH | awk -F/ '{print $NF}'` != "rtrut" ]; then
clear && echo "Please enter rtrut script path:"
read -p "(Default path: ${RTRUT_PATH}/rtrut):" RTRUT_PATH
[ -z "$RTRUT_PATH" ] && RTRUT_PATH=$(pwd)/rtrut
cd $RTRUT_PATH/
fi
DISTRIBUTION=`awk 'NR==1{print $1}' /etc/issue`
if echo $DISTRIBUTION | grep -Eqi '(Red Hat|CentOS|Fedora|Amazon)';then
PACKAGE="rpm"
elif echo $DISTRIBUTION | grep -Eqi '(Debian|Ubuntu)';then
PACKAGE="deb"
else
if cat /proc/version | grep -Eqi '(redhat|centos)';then
PACKAGE="rpm"
elif cat /proc/version | grep -Eqi '(debian|ubuntu)';then
PACKAGE="deb"
else
echo "Please select the package management! (rpm/deb)"
read -p "(Default: rpm):" PACKAGE
if [ -z "$PACKAGE" ]; then
PACKAGE="rpm"
fi
if [[ "$PACKAGE" != "rpm" && "$PACKAGE" != "deb" ]];then
echo -e "\nNot supported linux distribution!"
echo "Please contact me! WangYan <[email protected]>"
exit 0
fi
fi
fi
[ -r "$RTRUT_PATH/fifo" ] && rm -rf $RTRUT_PATH/fifo
mkfifo $RTRUT_PATH/fifo
cat $RTRUT_PATH/fifo | tee $RTRUT_PATH/log.txt &
exec 1>$RTRUT_PATH/fifo
exec 2>&1
/bin/bash ${RTRUT_PATH}/${PACKAGE}.sh
sed -i '/password/d' $RTRUT_PATH/log.txt
rm -rf $RTRUT_PATH/fifo