-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathinstall.sh
261 lines (259 loc) · 15.6 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
#!/bin/bash
if [ -f /etc/centos-release ]; then
OS="CentOs"
VERFULL=$(sed 's/^.*release //;s/ (Fin.*$//' /etc/centos-release)
VER=${VERFULL:0:1} # return 6, 7 or 8
elif [ -f /etc/fedora-release ]; then
OS="Fedora"
VERFULL=$(sed 's/^.*release //;s/ (Fin.*$//' /etc/fedora-release)
VER=${VERFULL:0:2} # return 6 or 7
elif [ -f /etc/lsb-release ]; then
OS=$(grep DISTRIB_ID /etc/lsb-release | sed 's/^.*=//')
VER=$(grep DISTRIB_RELEASE /etc/lsb-release | sed 's/^.*=//')
elif [ -f /etc/os-release ]; then
OS=$(grep -w ID /etc/os-release | sed 's/^.*=//')
VER=$(grep VERSION_ID /etc/os-release | sed 's/^.*"\(.*\)"/\1/' | head -n 1 | tail -n 1)
else
OS=$(uname -s)
VER=$(uname -r)
fi
ARCH=$(uname -m)
echo "Detected : $OS $VER $ARCH"
if [[ "$OS" = "Ubuntu" && "$VER" = "18.04" || "$OS" = "Ubuntu" && "$VER" = "20.04" ]] ; then
echo "Ok."
else
echo "Sorry, this OS is not supported by xtream-ui."
exit 1
fi
read -e -p "Enter your root mysql password: " -i "$ROOT_PASSWORD" ROOT_PASSWORD
if [[ "$ROOT_PASSWORD" = "" ]]; then
echo "mysql password required."
exit 2
fi
DEBIAN_FRONTEND=noninteractive apt-get -y purge mariadb-client-*
DEBIAN_FRONTEND=noninteractive apt-get -y purge mariadb-client-core-*
DEBIAN_FRONTEND=noninteractive apt-get -y purge mariadb-common
DEBIAN_FRONTEND=noninteractive apt-get -y purge mariadb-server
DEBIAN_FRONTEND=noninteractive apt-get -y purge mariadb-server-*
DEBIAN_FRONTEND=noninteractive apt-get -y purge mariadb-server-core-*
DEBIAN_FRONTEND=noninteractive apt-get -y purge mysql-client-*
DEBIAN_FRONTEND=noninteractive apt-get -y purge mysql-client-core-*
DEBIAN_FRONTEND=noninteractive apt-get -y purge mysql-server-*
DEBIAN_FRONTEND=noninteractive apt-get -y purge mysql-server-core-*
DEBIAN_FRONTEND=noninteractive apt-get -y purge mysql-apt-config
DEBIAN_FRONTEND=noninteractive apt-get -y purge mysql-client
DEBIAN_FRONTEND=noninteractive apt-get -y purge mysql-community-client
DEBIAN_FRONTEND=noninteractive apt-get -y purge mysql-community-server
rm -rf /var/lib/mysql/
rm -rf /var/lib/mysql-*
chattr -ia /etc/mysql/my.cnf
rm -rf /etc/mysql
apt-get -y autoremove
cat > /etc/apt/sources.list <<EOF
deb mirror://mirrors.ubuntu.com/mirrors.txt $(lsb_release -sc) main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu $(lsb_release -sc)-security main restricted universe multiverse
deb mirror://mirrors.ubuntu.com/mirrors.txt $(lsb_release -sc)-updates main restricted universe multiverse
deb-src mirror://mirrors.ubuntu.com/mirrors.txt $(lsb_release -sc) main restricted universe multiverse
deb-src mirror://mirrors.ubuntu.com/mirrors.txt $(lsb_release -sc)-updates main restricted universe multiverse
deb-src http://security.ubuntu.com/ubuntu $(lsb_release -sc)-security main restricted universe multiverse
deb http://archive.canonical.com/ubuntu $(lsb_release -sc) partner
deb-src http://archive.canonical.com/ubuntu $(lsb_release -sc) partner
EOF
apt-get update
#apt-get -y install python-software-properties
DEBIAN_FRONTEND=noninteractive apt-get -y install software-properties-common wget gnupg gnupg2
wget -O- "https://download.opensuse.org/repositories/home:/andykimpe:/ubuntu-$(lsb_release -sc)/xUbuntu_$(lsb_release -sr)/Release.key" | sudo apt-key add -
echo 'deb http://download.opensuse.org/repositories/home:/andykimpe:/ubuntu-'$(lsb_release -sc)'/xUbuntu_'$(lsb_release -sr)'/ /' > /etc/apt/sources.list.d/andykimpe.list
echo 'deb-src http://download.opensuse.org/repositories/home:/andykimpe:/ubuntu-'$(lsb_release -sc)'/xUbuntu_'$(lsb_release -sr)'/ /' >> /etc/apt/sources.list.d/andykimpe.list
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get -y dist-upgrade
echo "mariadb-server mysql-server/root_password password $ROOT_PASSWORD" | /usr/bin/debconf-set-selections
echo "mariadb-server mysql-server/root_password_again password $ROOT_PASSWORD" | /usr/bin/debconf-set-selections
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get -y install mariadb-server libxslt1-dev e2fsprogs wget mcrypt nscd htop python libcurl3 nano unzip
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get -y dist-upgrade
DEBIAN_FRONTEND=noninteractive apt-get -y install libcurl4
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get -y install libapache2-mod-php5.6 php5.6-common php5.6-cli php5.6-mysql php5.6-gd php5.6-mcrypt php5.6-curl php-pear php5.6-imap php5.6-xmlrpc php5.6-xsl php5.6-intl php php-dev php5.6-dev
echo "phpmyadmin phpmyadmin/dbconfig-install boolean true" | debconf-set-selections
echo "phpmyadmin phpmyadmin/app-password-confirm password $ROOT_PASSWORD" | debconf-set-selections
echo "phpmyadmin phpmyadmin/mysql/admin-pass password $ROOT_PASSWORD" | debconf-set-selections
echo "phpmyadmin phpmyadmin/mysql/app-pass password $ROOT_PASSWORD" | debconf-set-selections
echo "phpmyadmin phpmyadmin/reconfigure-webserver multiselect apache2" | debconf-set-selections
DEBIAN_FRONTEND=noninteractive apt-get -y install phpmyadmin php5.6-mbstring
update-alternatives --set php /usr/bin/php5.6
update-alternatives --set phar /usr/bin/phar5.6
update-alternatives --set phar.phar /usr/bin/phar.phar5.6
update-alternatives --set phpize /usr/bin/phpize5.6
update-alternatives --set php-config /usr/bin/php-config5.6
a2dismod php7.0
a2dismod php7.1
a2dismod php7.2
a2dismod php7.3
a2dismod php7.4
a2enmod php5.6
phpenmod -v 5.6 mcrypt
phpenmod -v 5.6 mbstring
service apache2 restart
cd /usr/share/
rm -rf /usr/share/phpmyadmin
wget https://files.phpmyadmin.net/phpMyAdmin/4.9.5/phpMyAdmin-4.9.5-all-languages.tar.xz
tar -xvf phpMyAdmin-4.9.5-all-languages.tar.xz
rm -f phpMyAdmin-4.9.5-all-languages.tar.xz
mv phpMyAdmin-4.9.5-all-languages phpmyadmin
chmod 777 -R phpmyadmin
chmod 777 -R phpmyadmin/*
ln -s /etc/phpmyadmin/config.inc.php /usr/share/phpmyadmin/config.inc.php
chmod 644 /etc/phpmyadmin/config.inc.php
systemctl stop mariadb
wget "https://github.com/amidevous/xtream-ui-beta-install/raw/master/etc/mysql/my.cnf" -O /etc/mysql/my.cnf
chmod 644 /etc/mysql/my.cnf
systemctl start mariadb
wget -q -O /tmp/libpng12.deb https://github.com/amidevous/xtream-ui-beta-install/raw/master/install/libpng12-0_1.2.54-1ubuntu1_amd64.deb
dpkg -i /tmp/libpng12.deb
apt-get install -yf
apt-get -y install sshpass
rm -f /tmp/libpng12.deb
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get -y dist-upgrade
getent passwd xtreamcodes
adduser --system --shell /bin/false --group --disabled-login xtreamcodes
mkdir -p /home/xtreamcodes
wget -O "/tmp/xtreamcodes.tar.gz" "https://github.com/amidevous/xtream-ui-beta-install/releases/download/1.0/mainnews.tar.gz"
#wget -O "/tmp/xtreamcodes.tar.gz" "https://github.com/amidevous/xtream-ui-beta-install/releases/download/1.0/main.tar.gz"
tar -zxvf "/tmp/xtreamcodes.tar.gz" -C "/home/xtreamcodes/"
rm -f /tmp/xtreamcodes.tar.gz
mysql -u root -p$ROOT_PASSWORD -e "DROP DATABASE IF EXISTS xtream_iptvpro; CREATE DATABASE IF NOT EXISTS xtream_iptvpro;"
mysql -u root -p$ROOT_PASSWORD xtream_iptvpro < /home/xtreamcodes/iptv_xtream_codes/database.sql
gen1=$(tr -cd '[:alnum:]' < /dev/urandom | fold -w20 | head -n1)
gen2=$(tr -cd '[:alnum:]' < /dev/urandom | fold -w10 | head -n1)
gen3=$(tr -cd '[:alnum:]' < /dev/urandom | fold -w20 | head -n1)
mysql -u root -p$ROOT_PASSWORD -e "USE xtream_iptvpro; UPDATE settings SET live_streaming_pass = '$gen1', unique_id = '$gen2', crypt_load_balancing = '$gen3';"
ip=$(wget -qO- http://andy.kimpe.free.fr/ip.php)
net=$(route | grep default | awk '{print $8}')
version=$(lsb_release -ds)
mysql -u root -p$ROOT_PASSWORD -e "USE xtream_iptvpro; REPLACE INTO streaming_servers (id, server_name, domain_name, server_ip, vpn_ip, ssh_password, ssh_port, diff_time_main, http_broadcast_port, total_clients, system_os, network_interface, latency, status, enable_geoip, geoip_countries, last_check_ago, can_delete, server_hardware, total_services, persistent_connections, rtmp_port, geoip_type, isp_names, isp_type, enable_isp, boost_fpm, http_ports_add, network_guaranteed_speed, https_broadcast_port, https_ports_add, whitelist_ips, watchdog_data, timeshift_only) VALUES (1, 'Main Server', '$ip', '$ip', '', NULL, NULL, 0, 80, 1000, '$version', '$net', 0, 1, 0, '', 0, 0, '{}', 3, 0, 25462, 'low_priority', '', 'low_priority', 0, 1, '', 1000, 25463, '', '[\"127.0.0.1\",\"\"]', '{}', 0);"
timetamp=$(date +"%s")
mysql -u root -p$ROOT_PASSWORD -e "USE xtream_iptvpro; INSERT INTO reg_users (id, username, password, email, ip, date_registered, verify_key, last_login, member_group_id, verified, credits, notes, status, default_lang, reseller_dns, owner_id, override_packages, google_2fa_sec) VALUES ('1', 'admin', '\$6\$rounds=20000\$xtreamcodes\$XThC5OwfuS0YwS4ahiifzF14vkGbGsFF1w7ETL4sRRC5sOrAWCjWvQJDromZUQoQuwbAXAFdX3h3Cp3vqulpS0', '[email protected]', NULL, '$timetamp', NULL, NULL, '1', '1', '0', NULL, '1', '', '', '0', NULL, '');"
sqlpass=$(tr -cd '[:alnum:]' < /dev/urandom | fold -w20 | head -n1)
mysql -u root -p$ROOT_PASSWORD -e "GRANT ALL PRIVILEGES ON xtream_iptvpro.* TO 'user_iptvpro'@'%' IDENTIFIED BY '$sqlpass' WITH GRANT OPTION; FLUSH PRIVILEGES;"
#wget https://github.com/amidevous/xtream-ui-beta-install/raw/master/install/update-21.sql -O /home/xtreamcodes/iptv_xtream_codes/update-21.sql
#mysql -u root -p$ROOT_PASSWORD xtream_iptvpro < /home/xtreamcodes/iptv_xtream_codes/update-21.sql
cd
wget https://github.com/amidevous/xtream-ui-beta-install/raw/master/install/encrypt.py -O encrypt.py
apt-get -y install dos2unix
dos2unix encrypt.py
sed -i 's|idedit|1|' encrypt.py
sed -i 's|mysqlpassword|'$sqlpass'|' encrypt.py
rm -f /home/xtreamcodes/iptv_xtream_codes/config
python encrypt.py ENCRYPT
if ! grep -q "/home/xtreamcodes/iptv_xtream_codes/" /etc/fstab; then
cat >> /etc/fstab <<EOF
tmpfs /home/xtreamcodes/iptv_xtream_codes/streams tmpfs defaults,noatime,nosuid,nodev,noexec,mode=1777,size=90% 0 0
tmpfs /home/xtreamcodes/iptv_xtream_codes/tmp tmpfs defaults,noatime,nosuid,nodev,noexec,mode=1777,size=2G 0 0"
EOF
fi
if ! grep -q "xtreamcodes ALL = (root) NOPASSWD: /sbin/iptables" /etc/sudoers; then
echo "xtreamcodes ALL = (root) NOPASSWD: /sbin/iptables" >> /etc/sudoers;
fi
if ! grep -q "xtreamcodes ALL = (root) NOPASSWD: /usr/bin/chattr" /etc/sudoers; then
echo "xtreamcodes ALL = (root) NOPASSWD: /usr/bin/chattr" >> /etc/sudoers;
fi
if ! grep -q "xtreamcodes ALL = (root) NOPASSWD: /bin/chmod" /etc/sudoers; then
echo "xtreamcodes ALL = (root) NOPASSWD: /bin/chmod" >> /etc/sudoers;
fi
fibash <(wget -qO- https://github.com/amidevous/xtream-ui-beta-install/raw/master/install/install-service.sh)
systemctl disable xtreamcodes
rm -f /etc/init.d/xtreamcodes
rm -f /usr/bin/ffmpeg
mkdir -p /home/xtreamcodes/iptv_xtream_codes/tv_archive
mkdir -p /home/xtreamcodes/iptv_xtream_codes/adtools/backups
ln -s /home/xtreamcodes/iptv_xtream_codes/bin/ffmpeg /usr/bin/
chown xtreamcodes:xtreamcodes -R /home/xtreamcodes
chmod -R 0777 /home/xtreamcodes
chmod +x /home/xtreamcodes/iptv_xtream_codes/start_services.sh
chattr +i /home/xtreamcodes/iptv_xtream_codes/GeoLite2.mmdb
mount -a
chattr -i /etc/hosts
chmod 777 /etc/hosts
if ! grep -q "127.0.0.1 api.xtream-codes.com" /etc/hosts; then
echo "127.0.0.1 api.xtream-codes.com" >> /etc/hosts;
fi
if ! grep -q "127.0.0.1 downloads.xtream-codes.com" /etc/hosts; then
echo "127.0.0.1 downloads.xtream-codes.com" >> /etc/hosts;
fi
if ! grep -q "127.0.0.1 xtream-codes.com" /etc/hosts; then
echo "127.0.0.1 xtream-codes.com" >> /etc/hosts;
fi
chattr +i /etc/hosts
wget -O /home/xtreamcodes/iptv_xtream_codes/nginx/conf/nginx.conf https://github.com/amidevous/xtream-ui-beta-install/raw/master/install/nginx_main.conf
wget -O /etc/apache2/ports.conf https://github.com/amidevous/xtream-ui-beta-install/raw/master/install/ports.conf
wget -O /etc/apache2/apache2.conf https://github.com/amidevous/xtream-ui-beta-install/raw/master/install/apache2.conf
wget -O /etc/apache2/sites-available/000-default.conf https://github.com/amidevous/xtream-ui-beta-install/raw/master/install/000-default.conf
service apache2 restart
#bash <(wget -qO- https://github.com/amidevous/xtream-ui-beta-install/raw/master/install/update.sh)
#bash <(wget -qO- https://github.com/amidevous/xtream-ui-beta-install/raw/master/install/updatebeta.sh)
bash <(wget -qO- https://github.com/amidevous/xtream-ui-beta-install/raw/master/install/updatev3.sh)
chown xtreamcodes:xtreamcodes -R /home/xtreamcodes
chmod -R 0777 /home/xtreamcodes
mysql -u root -p$ROOT_PASSWORD -e "GRANT ALL PRIVILEGES ON xtream_iptvpro.* TO 'user_iptvpro'@'%' IDENTIFIED BY '$sqlpass' WITH GRANT OPTION; FLUSH PRIVILEGES;"
#wget -O /home/xtreamcodes/iptv_xtream_codes/admin/settings.php https://github.com/amidevous/xtream-ui-beta-install/raw/master/install/settings.php.txt
#wget -O /home/xtreamcodes/iptv_xtream_codes/pytools/balancer.py https://github.com/amidevous/xtream-ui-beta-install/raw/master/install/pytools/balancer.py
proc=$(cat /proc/cpuinfo | grep -i "^processor" | wc -l)
apt-get -y install build-essential libzip4
apt-get -y build-dep php5.6
apt-get -y build-dep php7.3
wget https://www.php.net/distributions/php-7.3.26.tar.xz
tar -xvf php-7.3.26.tar.xz
cd php-7.3.26
if [[ "$OS" = "Ubuntu" && "$VER" = "20.04" ]] ; then
wget -O /usr/bin/freetype-config https://github.com/amidevous/xtream-ui-beta-install/raw/master/install/freetype-config
chmod +x /usr/bin/freetype-config
fi
./configure --prefix=/home/xtreamcodes/iptv_xtream_codes/php --with-zlib-dir --with-freetype-dir --enable-mbstring --enable-calendar --with-curl --with-mcrypt --with-gd --disable-rpath --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --enable-exif --enable-bcmath --with-mhash --enable-zip --with-pcre-regex --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --enable-gd-native-ttf --with-openssl --with-fpm-user=xtreamcodes --with-fpm-group=xtreamcodes --with-libdir=/lib/x86_64-linux-gnu --with-gettext --with-xmlrpc --with-xsl --enable-opcache --enable-fpm --enable-libxml --enable-static --disable-shared
make -j$proc
make install
cd ..
rm -rf php-7.3.26 php-7.3.26.tar.xz
rm -f /home/xtreamcodes/iptv_xtream_codes/php/lib/php/extensions/no-debug-non-zts-20180731/geoip.so
wget https://pecl.php.net/get/geoip-1.1.1.tgz
tar -xvf geoip-1.1.1.tgz
cd geoip-1.1.1
/home/xtreamcodes/iptv_xtream_codes/php/bin/phpize
apt-get -y install libgeoip-dev
./configure --with-php-config=/home/xtreamcodes/iptv_xtream_codes/php/bin/php-config
make -j$proc
make install
cd ..
rm -rf geoip-1.1.1 geoip-1.1.1.tgz
rm -f /home/xtreamcodes/iptv_xtream_codes/php/lib/php/extensions/no-debug-non-zts-20180731/mcrypt.so
apt-get -y install libmcrypt-dev
wget https://pecl.php.net/get/mcrypt-1.0.4.tgz
tar -xvf mcrypt-1.0.4.tgz
cd mcrypt-1.0.4
/home/xtreamcodes/iptv_xtream_codes/php/bin/phpize
./configure --with-php-config=/home/xtreamcodes/iptv_xtream_codes/php/bin/php-config
make -j$proc
make install
cd ..
rm -rf mcrypt-1.0.4.tgz mcrypt-1.0.4
rm -f /home/xtreamcodes/iptv_xtream_codes/php/lib/php/extensions/no-debug-non-zts-20180731/igbinary.so
wget https://pecl.php.net/get/igbinary-3.2.1.tgz
tar -xvf igbinary-3.2.1.tgz
cd igbinary-3.2.1
/home/xtreamcodes/iptv_xtream_codes/php/bin/phpize
./configure --with-php-config=/home/xtreamcodes/iptv_xtream_codes/php/bin/php-config
make -j$proc
make install
cd ..
rm -rf igbinary-3.2.1.tgz igbinary-3.2.1
bash <(wget -qO- https://github.com/amidevous/xtream-ui-beta-install/raw/master/install/updatev3.sh)
chown xtreamcodes:xtreamcodes -R /home/xtreamcodes
chmod -R 0777 /home/xtreamcodes
chattr +i /home/xtreamcodes/iptv_xtream_codes/GeoLite2.mmdb
/home/xtreamcodes/iptv_xtream_codes/start_services.sh
rm -f cookies.txt encrypt.py /home/xtreamcodes/iptv_xtream_codes/admin/.update
bash <(wget -qO- https://github.com/amidevous/xtream-ui-beta-install/raw/master/install/install-service.sh)
echo "panel installed"
echo "go to login http://$ip:25500/login.php"