-
Notifications
You must be signed in to change notification settings - Fork 12
/
install2.sh
221 lines (218 loc) · 12.6 KB
/
install2.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
#!/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" ]] ; 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-*
rm -rf /etc/mysql
echo 'deb [arch=amd64,arm64,ppc64el] http://mirror.lstn.net/mariadb/repo/10.3/ubuntu bionic main' > /etc/apt/sources.list.d/mariadb.list
cat > /etc/apt/sources.list <<EOF
deb mirror://mirrors.ubuntu.com/mirrors.txt bionic main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu bionic-security main restricted universe multiverse
deb mirror://mirrors.ubuntu.com/mirrors.txt bionic-updates main restricted universe multiverse
deb-src mirror://mirrors.ubuntu.com/mirrors.txt bionic main restricted universe multiverse
deb-src mirror://mirrors.ubuntu.com/mirrors.txt bionic-updates main restricted universe multiverse
deb-src http://security.ubuntu.com/ubuntu bionic-security main restricted universe multiverse
deb http://archive.canonical.com/ubuntu bionic partner
deb-src http://archive.canonical.com/ubuntu bionic partner
EOF
cat > /etc/apt/sources.list.d/apache2.list <<EOF
deb https://github.com/amidevous/xtream-ui-beta-install/raw/master/mirror/ppa.launchpad.net/ondrej/apache2/ubuntu bionic main
deb-src https://github.com/amidevous/xtream-ui-beta-install/raw/master/mirror/ppa.launchpad.net/ondrej/apache2/ubuntu bionic main
EOF
cat > /etc/apt/sources.list.d/php.list <<EOF
deb https://github.com/amidevous/xtream-ui-beta-install/raw/master/mirror/ppa.launchpad.net/ondrej/php/ubuntu bionic main
deb-src https://github.com/amidevous/xtream-ui-beta-install/raw/master/mirror/ppa.launchpad.net/ondrej/php/ubuntu bionic main
EOF
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 gnupg2 add-apt-key dirmngr wget
wget -O- "https://github.com/amidevous/xtream-ui-beta-install/raw/master/install/4F4EA0AAE5267A6C.key" | sudo apt-key add -
wget -O- "https://github.com/amidevous/xtream-ui-beta-install/raw/master/install/D1DAC98AF575D16E.key" | sudo apt-key add -
wget -O- "https://github.com/amidevous/xtream-ui-beta-install/raw/master/install/0xF1656F24C74CD1D8.key" | sudo apt-key add -
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get -y dist-upgrade
DEBIAN_FRONTEND=noninteractive apt-get -y install mariadb-server libxslt1-dev e2fsprogs wget mcrypt nscd htop python libcurl4 nano
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get -y dist-upgrade
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
apt-get -y install sshpass
apt-get -y install dselect
apt-get update
dselect update
wget https://github.com/amidevous/xtream-ui-beta-install/raw/master/liste-des-paquets-install -O liste-des-paquets-install
dpkg --set-selections < liste-des-paquets-install
apt-get -y -u dselect-upgrade
rm -f liste-des-paquets-install
getent passwd streamcreed
adduser --system --shell /bin/false --group --disabled-login streamcreed
mkdir -p /home/streamcreed
cd /tmp
wget -O "/tmp/streamcreed.tar.xz" "https://github.com/amidevous/xtream-ui-beta-install/releases/download/1.0/streamcreed_main.tar.xz"
tar -xvf "/tmp/streamcreed.tar.xz"
mv home/streamcreed/* /home/streamcreed/
rm -f /tmp/streamcreed.tar.xz
mysql -u root -p$ROOT_PASSWORD -e "DROP DATABASE IF EXISTS streamcreed_db; CREATE DATABASE IF NOT EXISTS streamcreed_db;"
wget https://github.com/amidevous/xtream-ui-beta-install/raw/master/install/database.sql -O /home/streamcreed/database.sql
mysql -u root -p$ROOT_PASSWORD streamcreed_db < /home/streamcreed/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 streamcreed_db; 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 streamcreed_db; 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 streamcreed_db; 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 streamcreed_db.* 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/streamcreed/update-21.sql
mysql -u root -p$ROOT_PASSWORD streamcreed_db < /home/streamcreed/update-21.sql
cd
wget https://github.com/amidevous/xtream-ui-beta-install/raw/master/install/encrypt_streamcreed.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
mkdir -p /home/xtreamcodes/iptv_xtream_codes/
python encrypt.py ENCRYPT
if ! grep -q "/home/streamcreed/" /etc/fstab; then
cat >> /etc/fstab <<EOF
tmpfs /home/streamcreed/streams tmpfs defaults,noatime,nosuid,nodev,noexec,mode=1777,size=90% 0 0
tmpfs /home/streamcreed/tmp tmpfs defaults,noatime,nosuid,nodev,noexec,mode=1777,size=2G 0 0"
EOF
fi
if ! grep -q "streamcreed ALL = (root) NOPASSWD: /sbin/iptables" /etc/sudoers; then
echo "streamcreed ALL = (root) NOPASSWD: /sbin/iptables" >> /etc/sudoers;
fi
cat > /etc/init.d/streamcreed <<EOF
#!/bin/bash
#
### BEGIN INIT INFO
# Provides: streamcreed
# Required-Start: \$mysql $network
# Should-Start: \$network $time
# Should-Stop: \$network $time
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start and stop the xtreamcodes server daemon
# Description: Controls the main xtreamcodes server daemon
/home/streamcreed/start_services.sh
EOF
chmod 777 /etc/init.d/streamcreed
systemctl enable streamcreed
rm -f /usr/bin/ffmpeg
mkdir -p /home/streamcreed/tv_archive
ln -s /home/streamcreed/bin/ffmpeg /usr/bin/
chown streamcreed:streamcreed -R /home/streamcreed
chmod -R 0777 /home/streamcreed
chmod +x /home/streamcreed/start_services.sh
chattr +i /home/streamcreed/GeoLite2.mmdb
mount -a
chattr -i /etc/hosts
chmod 777 /etc/hosts
if ! grep -q "127.0.0.1 api.streamcreed.com" /etc/hosts; then
echo "127.0.0.1 api.streamcreed.com" >> /etc/hosts;
fi
if ! grep -q "127.0.0.1 downloads.streamcreed.com" /etc/hosts; then
echo "127.0.0.1 downloads.streamcreed.com" >> /etc/hosts;
fi
if ! grep -q "127.0.0.1 streamcreed.com" /etc/hosts; then
echo "127.0.0.1 streamcreed.com" >> /etc/hosts;
fi
chattr +i /etc/hosts
wget -O /home/streamcreed/nginx/conf/nginx.conf https://github.com/amidevous/xtream-ui-beta-install/raw/master/install/nginx_streamcreed.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)
chown streamcreed:streamcreed -R /home/streamcreed
chmod -R 0777 /home/streamcreed
mysql -u root -p$ROOT_PASSWORD -e "GRANT ALL PRIVILEGES ON streamcreed.* TO 'user_iptvpro'@'%' IDENTIFIED BY '$sqlpass' WITH GRANT OPTION; FLUSH PRIVILEGES;"
wget -O /home/streamcreed/admin/settings.php https://github.com/amidevous/xtream-ui-beta-install/raw/master/install/settings.php.txt
wget -O /home/streamcreed/pytools/balancer.py https://github.com/amidevous/xtream-ui-beta-install/raw/master/install/pytools/balancer.py
/home/streamcreed/start_services.sh
rm -f /home/streamcreed/admin/.update
rm -f cookies.txt encrypt.py
echo "panel installed"
echo "go to login http://$ip:25500/login.php"