forked from Cclleemm/FriendlyTorrent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·131 lines (106 loc) · 3.3 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/bash
checkInstall()
{
echo "------------ Check for $1 depedency ------------"
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' $1|grep "install ok installed")
echo Checking for $1: $PKG_OK
if [ "" == "$PKG_OK" ]; then
echo "No $1. Setting up $1."
sudo apt-get --force-yes --yes install $1
fi
}
checkInstall apache2
a2enmod rewrite
checkInstall php5
checkInstall mysql-server
checkInstall libapache2-mod-php5
checkInstall php5-curl
checkInstall php5-mysql
checkInstall memcached
checkInstall php5-memcache
checkInstall php5-memcached
checkInstall transmission
checkInstall transmission-daemon
checkInstall zip
echo "----------------------------------------------------"
echo "Welcome in the Friendly Torrent installation wizard"
echo "----------------------------------------------------"
#Ask for Website dir
echo -n "Website directory [default : /var/www/] "
read websiteFolder
if [[ $websiteFolder == "" ]]
then
websiteFolder=/var/www/
fi
cd src
cp -R ./ $websiteFolder 1> /dev/null
cd ..
echo "Files copied"
echo -n "Admin login : "
read login
echo -n "Admin password : "
read -s pass
echo ""
#Ask for download storage folder
echo -n "Downloads storage folder [default : /var/downloads/] "
read dossierBoxes
if [[ $dossierBoxes == "" ]]
then
dossierBoxes=/var/downloads/
fi
if mkdir $dossierBoxes
then
echo "Folder created with success "
else
echo "Can't create this folder"
fi
mkdir "$dossierBoxes/$login/"
mkdir "$dossierBoxes/.transferts/"
sudo chown www-data $dossierBoxes -R
echo "------------ PHP/Apache2 Configuration ------------ "
echo 'extension=memcache.so' >> /etc/php5/apache2/php.ini
echo "PHP Memcache extension enabled"
echo '*/1 * * * * www-data wget "http://localhost/action/refreshTorrent/" -O /dev/null' >> /etc/cron.d/php5
if [ -f "$websiteFolder/index.html" ]; then
sudo mv "$websiteFolder/index.html" "$websiteFolder/index-old.html"
fi
echo "------------ MySQL configuration ------------ "
while true; do
echo -n "MySQL user : "
read userBDD
echo -n "MySQL password : "
read -s passBDD
echo ""
echo -n "MySQL database: "
read bdd
mysql -u $userBDD -p$passBDD -e "CREATE DATABASE IF NOT EXISTS $bdd;"
if mysql -u $userBDD -p$passBDD $bdd < board.sql
then
echo "Database importation succeed ! "
break
else
echo "Can't import the database !"
fi
done
md5=`echo -n $pass|md5sum|awk '{ print $1 }'`
mysql -u $userBDD -p$passBDD $bdd << EOF
insert into users(login,mail,password,boxe,couleur,lastScan,rss,admin,port) values('$login','-','$md5','$dossierBoxes/$login', '78ba00', 0, '', 1, 9091);
EOF
mkdir "$websiteFolder""core/config/"
echo "<?php
//CONFIG MYSQL
\$BDD_MYSQL_SERVER = 'localhost';
\$BDD_MYSQL_LOGIN = '$userBDD';
\$BDD_MYSQL_PASS = '$passBDD';
\$BDD_MYSQL_BDD = '$bdd';
?>" > "$websiteFolder""core/config/bdd.php"
echo "<?php
define('ROOT_DOWNLOADS','$dossierBoxes');
define('TRANSMISSION','/usr/bin/transmission-daemon');
?>" > "$websiteFolder""core/config/global.php"
sudo service apache2 reload
sudo service transmission-daemon stop
sudo /etc/init.d/cron restart
echo "----------------------------------------------------"
echo "----- Thank you for installing Friendly Torrent ----"
echo "----------------------------------------------------"