Advertisement
Guest User

Untitled

a guest
Jul 30th, 2016
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.68 KB | None | 0 0
  1. #!/bin/bash
  2. clear;
  3. # clear;
  4. # Reset
  5. Reset='\e[0m' # Text Reset
  6. # Regular Colors
  7. Black='\e[0;30m' # Black
  8. Red='\e[0;31m' # Red
  9. Green='\e[0;32m' # Green
  10. Yellow='\e[0;33m' # Yellow
  11. Blue='\e[0;34m' # Blue
  12. Purple='\e[0;35m' # Purple
  13. Cyan='\e[0;36m' # Cyan
  14. White='\e[0;37m' # White
  15. # Bold
  16. BBlack='\e[1;30m' # Black
  17. BRed='\e[1;31m' # Red
  18. BGreen='\e[1;32m' # Green
  19. BYellow='\e[1;33m' # Yellow
  20. BBlue='\e[1;34m' # Blue
  21. BPurple='\e[1;35m' # Purple
  22. BCyan='\e[1;36m' # Cyan
  23. BWhite='\e[1;37m' # White
  24.  
  25. # Tweak nameservers
  26. echo "nameserver 8.8.8.8" > /etc/resolv.conf
  27. # Get distro data
  28. . /etc/lsb-release >> /var/log/fulliptv-install.log 2>&1
  29. if [ "$DISTRIB_ID" != "Ubuntu" ]; then
  30. echo -e "ERROR: This system requires Ubuntu distro only !";
  31. exit 1;
  32. else
  33. if [[ "$DISTRIB_CODENAME" = "trusty" || "$DISTRIB_CODENAME" = "saucy" || "$DISTRIB_CODENAME" = "quantal" || "$DISTRIB_CODENAME" = "precise" || "$DISTRIB_CODENAME" = "raring" ]]; then
  34. X=1
  35. else
  36. echo -e "ERROR: This system requires Ubuntu ( 12.04, 13.04, 13.10, 14.04 ) distro only !";
  37. exit 1;
  38. fi
  39. fi
  40.  
  41. echo -e "${BCyan}Checking your system...... [OK]${Reset}\n";
  42.  
  43. # TWEAK SYSTEM VALUES
  44. function tweakSystem {
  45. dpkg --remove-architecture i386 >> /dev/null 2>&1
  46. echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.conf
  47. echo "net.ipv6.conf.default.disable_ipv6 = 1" >> /etc/sysctl.conf
  48. echo "net.ipv6.conf.lo.disable_ipv6 = 1" >> /etc/sysctl.conf
  49. echo "fs.file-max = 32768" >> /etc/sysctl.conf
  50. echo "kern.maxfiles = 32768" >> /etc/sysctl.conf
  51. echo "kern.maxfilesperproc = 32768" >> /etc/sysctl.conf
  52. echo "kernel.core_uses_pid = 1" >> /etc/sysctl.conf
  53. echo "kernel.core_pattern = /var/crash/core-%e-%s-%u-%g-%p-%t" >> /etc/sysctl.conf
  54. echo "fs.suid_dumpable = 2" >> /etc/sysctl.conf
  55. sysctl -p >> /dev/null 2>&1
  56. }
  57. # SET LOCALE TO UTF-8
  58. function setLocale {
  59. locale-gen en_US.UTF-8 >> /dev/null 2>&1
  60. export LANG="en_US.UTF-8" >> /dev/null 2>&1
  61. }
  62. # SET MIRRORS
  63. function setMirrors {
  64. echo "deb http://ubuntu.mirrors.ovh.net/ftp.ubuntu.com/ubuntu/ $DISTRIB_CODENAME main restricted
  65. deb-src http://ubuntu.mirrors.ovh.net/ftp.ubuntu.com/ubuntu/ $DISTRIB_CODENAME main restricted
  66. deb http://ubuntu.mirrors.ovh.net/ftp.ubuntu.com/ubuntu/ $DISTRIB_CODENAME-updates main restricted
  67. deb-src http://ubuntu.mirrors.ovh.net/ftp.ubuntu.com/ubuntu/ $DISTRIB_CODENAME-updates main restricted
  68. deb http://ubuntu.mirrors.ovh.net/ftp.ubuntu.com/ubuntu/ $DISTRIB_CODENAME universe
  69. deb-src http://ubuntu.mirrors.ovh.net/ftp.ubuntu.com/ubuntu/ $DISTRIB_CODENAME universe
  70. deb http://ubuntu.mirrors.ovh.net/ftp.ubuntu.com/ubuntu/ $DISTRIB_CODENAME-updates universe
  71. deb-src http://ubuntu.mirrors.ovh.net/ftp.ubuntu.com/ubuntu/ $DISTRIB_CODENAME-updates universe
  72. deb http://ubuntu.mirrors.ovh.net/ftp.ubuntu.com/ubuntu/ $DISTRIB_CODENAME multiverse
  73. deb-src http://ubuntu.mirrors.ovh.net/ftp.ubuntu.com/ubuntu/ $DISTRIB_CODENAME multiverse
  74. deb http://ubuntu.mirrors.ovh.net/ftp.ubuntu.com/ubuntu/ $DISTRIB_CODENAME-updates multiverse
  75. deb-src http://ubuntu.mirrors.ovh.net/ftp.ubuntu.com/ubuntu/ $DISTRIB_CODENAME-updates multiverse
  76. deb http://ubuntu.mirrors.ovh.net/ftp.ubuntu.com/ubuntu/ $DISTRIB_CODENAME-backports main restricted universe multiverse
  77. deb-src http://ubuntu.mirrors.ovh.net/ftp.ubuntu.com/ubuntu/ $DISTRIB_CODENAME-backports main restricted universe multiverse
  78. deb http://security.ubuntu.com/ubuntu $DISTRIB_CODENAME-security main restricted
  79. deb-src http://security.ubuntu.com/ubuntu $DISTRIB_CODENAME-security main restricted
  80. deb http://security.ubuntu.com/ubuntu $DISTRIB_CODENAME-security universe
  81. deb-src http://security.ubuntu.com/ubuntu $DISTRIB_CODENAME-security universe
  82. deb http://security.ubuntu.com/ubuntu $DISTRIB_CODENAME-security multiverse
  83. deb-src http://security.ubuntu.com/ubuntu $DISTRIB_CODENAME-security multiverse
  84. deb http://cdn.fulliptv.com/medibuntu/ $DISTRIB_CODENAME free non-free
  85. deb-src http://cdn.fulliptv.com/medibuntu/ $DISTRIB_CODENAME free non-free
  86. " > /etc/apt/sources.list
  87. if [[ "$DISTRIB_CODENAME" = "trusty" ]]; then
  88. echo "" >> /dev/null
  89. else
  90. echo "deb http://cdn.fulliptv.com/medibuntu/ $DISTRIB_CODENAME free non-free" >> /etc/apt/sources.list
  91. echo "deb-src http://cdn.fulliptv.com/medibuntu/ $DISTRIB_CODENAME free non-free" >> /etc/apt/sources.list
  92. fi
  93. }
  94.  
  95. # install base packages
  96. function installBase {
  97. LANG=en_US.UTF-8 DEBIAN_FRONTEND=noninteractive dpkg --configure -a >> /dev/null 2>&1
  98. LANG=en_US.UTF-8 DEBIAN_FRONTEND=noninteractive apt-get update -y -q >> /dev/null 2>&1
  99. LANG=en_US.UTF-8 DEBIAN_FRONTEND=noninteractive dpkg --configure -a >> /dev/null 2>&1
  100. LANG=en_US.UTF-8 DEBIAN_FRONTEND=noninteractive apt-get install libjansson-dev -q -y --force-yes >> /dev/null 2>&1
  101. LANG=en_US.UTF-8 DEBIAN_FRONTEND=noninteractive apt-get -y --force-yes -q install lsb-release apt-utils aptitude apt software-properties-common curl mtr debconf html2text wget whois whiptail vim-nox unzip tzdata sudo sysstat strace sshpass ssh-import-id tcpdump telnet screen python-software-properties python openssl ntpdate mc iptraf mailutils mlocate mtr htop gcc fuse ftp dnsutils ethtool curl dbconfig-common coreutils debianutils debconf bc bash-completion automake autoconf bwm-ng apt-utils aptitude apt git software-properties-common dos2unix dialog curl >> /dev/null 2>&1
  102. LANG=en_US.UTF-8 DEBIAN_FRONTEND=noninteractive dpkg --configure -a >> /dev/null 2>&1
  103. }
  104.  
  105. }
  106.  
  107. function updateSSHPassword {
  108. NEWPASS=`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 12 | head -n 1`
  109. NPASS=`php -r "echo base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5('fulliptvcrypthash'), '$NEWPASS', MCRYPT_MODE_CBC, md5(md5('fulliptvcrypthash'))));"`
  110. CHKUSER=`cat /etc/passwd | grep fulliptv`
  111. if [ -z "$CHKUSER" ]; then
  112. useradd -s /bin/bash -d /opt -g 0 -o -u 0 fulliptv >> /var/log/fulliptv-install.log 2>&1
  113. fi
  114. usermod --password `mkpasswd $NEWPASS` fulliptv >> /var/log/fulliptv-install.log 2>&1
  115. }
  116.  
  117. function installDatabase {
  118. if [ "$ISCMS" = "1" ]; then
  119. if [ -z `psql -U postgres -l -A -t | grep fulliptvxx` ]; then
  120. psql -U postgres -c "CREATE DATABASE fulliptvxx" >> /dev/null 2>&1
  121. psql -U postgres fulliptvxx < /opt/fulliptv/lib/fulliptv.sql >> /dev/null 2>&1
  122. else
  123. echo "${BCyan}Database found, skipping installing initial database...${Reset}";
  124. fi
  125. fi
  126. }
  127. function addServer {
  128. SERVERPORT=`cat /etc/ssh/sshd_config | grep "Port " | cut -d" " -f2`
  129. TOKEN=`php -r "echo md5(\"${SERVERIP}\");"`
  130. RES=`curl -s "http://$CMSURL:$CMSPORT/cron?addServer=true&server_name=$SERVERNAME&server_ip=$SERVERIP&server_private_ip=$SERVERINTIP&server_port=$SERVERPORT&server_auth=$NEWPASS&token=$TOKEN"`
  131. if [ "$RES" = "OK" ]; then
  132. echo -e "${BGreen}Server added to the database !${Reset}";
  133. fi
  134. if [ "$RES" = "UPDATED" ]; then
  135. echo -e "${BGreen}Server updated into database !${Reset}";
  136. fi
  137. }
  138. function addServerToDatabase {
  139. CHK=`PGPASSWORD="Pass22pp2019ssh808" psql -U postgres -h $CMSURL fulliptvxx -A -t -c "SELECT id FROM servers WHERE server_host = '$SERVERNAME'"` >> /dev/null 2>&1
  140. if [ -z "$CHK" ]; then
  141. SERVERPORT=`cat /etc/ssh/sshd_config | grep "Port " | cut -d" " -f2`
  142. PGPASSWORD="Pass22pp2019ssh808" psql -U postgres -h $CMSURL fulliptvxx -A -t -c "INSERT INTO servers ( server_name, server_host, server_ip, server_private_ip, server_port, server_upload, server_download, server_max_clients, server_max_channels, active, status, server_auth ) VALUES ( '$SERVERNAME', '$SERVERNAME', '$SERVERIP', '$SERVERINTIP', '$SERVERPORT', '1000', '1000', '1000', '1000', 't', 't', '${NPASS}' )" >> /dev/null 2>&1
  143. echo -e "${BGreen}Server added to the CMS !${Reset}";
  144. else
  145. echo -e "${BGreen}This server is already added to the CMS !${Reset}";
  146. fi
  147. }
  148.  
  149. function updateServerDatabasePass {
  150. PGPASSWORD="Pass22pp2019ssh808" psql -U postgres -h $CMSURL fulliptvxx -c "UPDATE servers SET server_auth = '$NPASS' WHERE server_host = '$SERVERNAME'" >> /var/log/fulliptv-install.log 2>&1
  151. }
  152.  
  153. function writeConfig {
  154. mkdir -p /opt/fulliptv/etc/ >> /dev/null 2>&1
  155. echo "CMSURL=$CMSURL" > /opt/fulliptv/etc/fulliptv.conf
  156. echo "CMSPORT=$CMSPORT" >> /opt/fulliptv/etc/fulliptv.conf
  157. echo "SERVERNAME=$SERVERNAME" >> /opt/fulliptv/etc/fulliptv.conf
  158. echo "SERVERIP=$SERVERIP" >> /opt/fulliptv/etc/fulliptv.conf
  159. echo "SERVERINTIP=$SERVERINTIP" >> /opt/fulliptv/etc/fulliptv.conf
  160. echo "ISCMS=$ISCMS" >> /opt/fulliptv/etc/fulliptv.conf
  161. echo "ISSTREAMER=$ISSTREAMER" >> /opt/fulliptv/etc/fulliptv.conf
  162. }
  163.  
  164. function upgradeFiles {
  165. if [ "$ISCMS" = "1" ]; then
  166. wget -O /tmp/fulliptv.tgz http://cdn.fulliptv.com/fulliptv-cms.tgz >> /dev/null 2>&1
  167. tar xzvf /tmp/fulliptv.tgz -C /opt >> /dev/null 2>&1
  168. rm -rf /tmp/fulliptv.tgz >> /dev/null 2>&1
  169. fi
  170. if [ "$ISSTREAMER" = "1" ]; then
  171. wget -O /tmp/fulliptv.tgz http://cdn.fulliptv.com/fulliptv-streamer.tgz >> /dev/null 2>&1
  172. tar xzvf /tmp/fulliptv.tgz -C /opt >> /dev/null 2>&1
  173. rm -rf /tmp/fulliptv.tgz >> /dev/null 2>&1
  174. fi
  175. }
  176.  
  177. function installCMSPackages {
  178. LANG=en_US.UTF-8 DEBIAN_FRONTEND=noninteractive dpkg --configure -a >> /dev/null 2>&1
  179. LANG=en_US.UTF-8 DEBIAN_FRONTEND=noninteractive apt-get install php5-fpm php5-mcrypt php5-pgsql php5-cli php5-curl php5-gd php-pear libssh2-php php5-json libxslt1.1 daemontools postgresql-client -q -y --force-yes >> /dev/null 2>&1
  180. LANG=en_US.UTF-8 DEBIAN_FRONTEND=noninteractive apt-get install libva1 libxfixes3 libxext6 libasound2 libsdl1.2debian libtheora0 libmp3lame0 libass4 libvdpau1 daemontools postgresql-client apache2 php5 libapache2-mod-php5 -q -y --force-yes >> /dev/null 2>&1
  181. if [ "$DISTRIB_CODENAME" != "trusty" ]; then
  182. LANG=en_US.UTF-8 DEBIAN_FRONTEND=noninteractive apt-get install postgresql-9.1 -y --force-yes >> /dev/null 2>&1
  183. echo -e "local all postgres trust\n" > /etc/postgresql/9.1/main/pg_hba.conf
  184. echo -e "local all all trust\n" >> /etc/postgresql/9.1/main/pg_hba.conf
  185. echo -e "host all all 127.0.0.1/32 trust\n" >> /etc/postgresql/9.1/main/pg_hba.conf
  186. echo -e "host all all ::1/128 trust\n" >> /etc/postgresql/9.1/main/pg_hba.conf
  187. # echo -e "host all all 0.0.0.0/0 md5\n" >> /etc/postgresql/9.1/main/pg_hba.conf
  188. echo -e "listen_addresses = '*'\n" >> /etc/postgresql/9.1/main/postgresql.conf
  189. else
  190. LANG=en_US.UTF-8 DEBIAN_FRONTEND=noninteractive apt-get install postgresql-9.3 -y --force-yes >> /dev/null 2>&1
  191. echo -e "local all postgres trust\n" > /etc/postgresql/9.3/main/pg_hba.conf
  192. echo -e "local all all trust\n" >> /etc/postgresql/9.3/main/pg_hba.conf
  193. echo -e "host all all 127.0.0.1/32 trust\n" >> /etc/postgresql/9.3/main/pg_hba.conf
  194. echo -e "host all all ::1/128 trust\n" >> /etc/postgresql/9.3/main/pg_hba.conf
  195. # echo -e "host all all 0.0.0.0/0 md5\n" >> /etc/postgresql/9.3/main/pg_hba.conf
  196. echo -e "listen_addresses = '*'\n" >> /etc/postgresql/9.3/main/postgresql.conf
  197. fi
  198. /etc/init.d/postgresql restart >> /var/log/fulliptv-install.log 2>&1
  199. psql -U postgres -c "ALTER USER postgres WITH PASSWORD 'Pass22pp2019ssh808'" >> /var/log/fulliptv-install.log 2>&1
  200. }
  201.  
  202. function installStreamerPackages {
  203. LANG=en_US.UTF-8 DEBIAN_FRONTEND=noninteractive dpkg --configure -a >> /dev/null 2>&1
  204. LANG=en_US.UTF-8 DEBIAN_FRONTEND=noninteractive apt-get install daemontools postgresql-client x264 -q -y --force-yes >> /dev/null 2>&1
  205. LANG=en_US.UTF-8 DEBIAN_FRONTEND=noninteractive apt-get purge -y --force-yes -qq vlc-data vlc-nox vlc >> /dev/null 2>&1
  206. LANG=en_US.UTF-8 DEBIAN_FRONTEND=noninteractive apt-get autoremove -y --force-yes -qq >> /dev/null 2>&1
  207. LANG=en_US.UTF-8 DEBIAN_FRONTEND=noninteractive apt-get install -y --force-yes -qq ubuntu-restricted-extras >> /dev/null 2>&1
  208. LANG=en_US.UTF-8 DEBIAN_FRONTEND=noninteractive apt-get update >> /dev/null 2>&1
  209. if [ "$DISTRIB_CODENAME" = "saucy" ]; then
  210. LANG=en_US.UTF-8 DEBIAN_FRONTEND=noninteractive apt-get install -y --force-yes -qq vlc-nox vlc ffmpeg non-free-codecs x264 php5 php5-mcrypt >> /dev/null 2>&1
  211. elif [ "$DISTRIB_CODENAME" = "trusty" ]; then
  212. LANG=en_US.UTF-8 DEBIAN_FRONTEND=noninteractive apt-get install -y --force-yes -qq vlc-nox vlc x264 php5 php5-mcrypt >> /dev/null 2>&1
  213. else
  214. LANG=en_US.UTF-8 DEBIAN_FRONTEND=noninteractive apt-get install -y --force-yes -qq vlc-nox vlc ffmpeg non-free-codecs x264 php5 php5-mcrypt >> /dev/null 2>&1
  215. fi
  216.  
  217. setupMcrypt;
  218. }
  219.  
  220. function setupCMS {
  221. CHKZEND=`cat /etc/php5/apache2/php.ini | grep zend_exten`
  222. if [ -z "$CHKZEND" ]; then
  223. echo "zend_extension=/opt/fulliptv/lib/ioncube/ioncube_loader_lin_5.5.so" >> /etc/php5/apache2/php.ini
  224. fi
  225. CHKZEND=`cat /etc/php5/cli/php.ini | grep zend_exten`
  226. if [ -z "$CHKZEND" ]; then
  227. echo "zend_extension=/opt/fulliptv/lib/ioncube/ioncube_loader_lin_5.5.so" >> /etc/php5/cli/php.ini
  228. fi
  229. apt-get install -y --force-yes apache2 -q >> /dev/null 2>&1
  230. /etc/init.d/nginx stop >> /dev/null 2>&1
  231. cp -R /etc/php5/conf.d/* /etc/php5/apache2/conf.d/ >> /dev/null 2>&1
  232. cp -R /etc/php5/conf.d/* /etc/php5/cli/conf.d/ >> /dev/null 2>&1
  233. php5enmod ssh2 >> /dev/null 2>&1
  234. php5enmod mcrypt >> /dev/null 2>&1
  235. a2enmod rewrite >> /dev/null 2>&1
  236.  
  237. killall -9 nginx >> /dev/null 2>&1
  238. killall -9 php5-fpm >> /dev/null 2>&1
  239. killall -9 php-fpm >> /dev/null 2>&1
  240. echo "Listen $CMSPORT" > /etc/apache2/ports.conf
  241. echo "<VirtualHost *:$CMSPORT>
  242. ServerAdmin info@fulliptv.com
  243. ServerName ${CMSURL}
  244. DocumentRoot /opt/fulliptv/portal
  245. <Directory />
  246. Options FollowSymLinks
  247. AllowOverride All
  248. Require all granted
  249. </Directory>
  250. <Directory /opt/fulliptv/portal>
  251. Options FollowSymLinks
  252. AllowOverride All
  253. Require all granted
  254. </Directory>
  255. ErrorLog \${APACHE_LOG_DIR}/${CMSURL}-error.log
  256. LogLevel warn
  257. CustomLog \${APACHE_LOG_DIR}/${CMSURL}-access.log combined
  258. </VirtualHost>
  259. " > /etc/apache2/sites-enabled/000-default.conf
  260. /etc/init.d/apache2 restart >> /dev/null 2>&1
  261. CHKRC=`cat /etc/crontab | grep fulliptv`
  262. if [ -z "$CHKRC" ]; then
  263. echo "*/5 * * * * root wget -O /dev/null \"http://${CMSURL}/cron.php\" >> /dev/null 2>&1" >> /etc/crontab
  264. fi
  265. psql -U postgres fulliptvxx -c "UPDATE settings SET config_value = '$CMSVER' WHERE config_name = 'current_version' OR config_name = 'new_version'" >> /dev/null 2>&1
  266. }
  267. function setupMcrypt {
  268. php5enmod mcrypt >> /dev/null 2>&1
  269. cp -R /etc/php5/conf.d/* /etc/php5/apache2/conf.d/ >> /dev/null 2>&1
  270. cp -R /etc/php5/conf.d/* /etc/php5/cli/conf.d/ >> /dev/null 2>&1
  271. }
  272.  
  273.  
  274. function setupStreamer {
  275. cp -R /etc/php5/conf.d/* /etc/php5/apache2/conf.d/ >> /dev/null 2>&1
  276. cp -R /etc/php5/conf.d/* /etc/php5/cli/conf.d/ >> /dev/null 2>&1
  277. php5enmod mcrypt >> /dev/null 2>&1
  278. ( killall -9 hitrow vlc supervise ; supervise /opt/fulliptv/bin & ) >> /dev/null 2>&1
  279. CHKRC=`cat /etc/rc.local | grep fulliptv`
  280. if [ -z "$CHKRC" ]; then
  281. echo "( killall -9 hitrow vlc supervise ; supervise /opt/fulliptv/bin & ) >> /dev/null 2>&1" > /etc/rc.local
  282. fi
  283. }
  284.  
  285. function cleanUp {
  286. # Remove any temp data or package data.
  287. if [ "$ISSTREAMER" = "1" ]; then
  288. /etc/init.d/apache2 stop >> /dev/null 2>&1
  289. ( killall -9 hitrow vlc supervise ; supervise /opt/fulliptv/bin & ) >> /dev/null 2>&1
  290. fi
  291. if [ "$ISCMS" = "1" ]; then
  292. /etc/init.d/apache2 start >> /dev/null 2>&1
  293. fi
  294. apt-get purge -y --force-yes fulliptv nginx -q >> /dev/null 2>&1
  295.  
  296. /etc/init.d/nginx stop >> /dev/null 2>&1
  297. killall -9 php5-fpm >> /dev/null 2>&1
  298. killall -9 php-fpm >> /dev/null 2>&1
  299. killall -9 nginx >> /dev/null 2>&1
  300. rm -rf /opt/fulliptv/lib/fulliptv.sql >> /dev/null 2>&1
  301. rm -rf /opt/fulliptv/lib/nginx* >> /dev/null 2>&1
  302. rm -rf /tmp/fulliptv* >> /dev/null 2>&1
  303. mkdir /opt/fulliptv/vod >> /dev/null 2>&1
  304. chown -R www-data:www-data /opt/fulliptv >> /dev/null 2>&1
  305. chmod -R 777 /opt/fulliptv/vod >> /dev/null 2>&1
  306. wget -O /dev/null "http://cdn.fulliptv.com/install.php?cmsurl=$CMSURL&servername=$SERVERNAME&serverip=$SERVERIP&serverintip=$SERVERINTIP&iscms=$ISCMS&isstreamer=$ISSTREAMER" > /dev/null 2>&1
  307.  
  308. }
  309.  
  310.  
  311. ### STARTING PROPER SCRIPT ###
  312. tweakSystem;
  313. setLocale;
  314. setMirrors;
  315. installBase;
  316.  
  317. # Gathering latest version of software
  318. CMSVER=`curl -s "http://cdn.fulliptv.com/VERSION" | xargs`
  319. HITVER=`curl -s "http://cdn.fulliptv.com/HITROWVERSION" | xargs`
  320.  
  321. # UPGARDE IF EXISTING INSTALLATION
  322. if [ -f /opt/fulliptv/etc/fulliptv.conf ]; then
  323. . /opt/fulliptv/etc/fulliptv.conf >> /dev/null 2>&1
  324. if [ -z "$CMSPORT" ]; then
  325. CMSPORT="80"
  326. fi
  327. CURVER=`cat /opt/fulliptv/etc/VERSION`
  328. # CHECK IF UPDATE NEEDED
  329. if [ "$CMSVER" = "$CURVER" ]; then
  330. if [ "$1" != "force" ]; then
  331. echo -e "${BCyan}You already have the latest version ${BYellow}v$CMSVER${BCyan}, no update to make!${Reset}";
  332. exit 0;
  333. else
  334. echo -e "${BCyan}Forcing update!${Reset}";
  335. fi
  336. fi
  337.  
  338. setupMcrypt;
  339. upgradeFiles;
  340. updateSSHPassword;
  341. if [ "$ISCMS" = "1" ]; then
  342. # UPDATE CMS
  343. echo -e "${BGreen}Updating CMS${Reset}";
  344. psql -U postgres fulliptvxx -c "UPDATE settings SET config_value = '$CMSVER' WHERE config_name = 'current_version' OR config_name = 'new_version'" >> /dev/null 2>&1
  345. fi
  346. if [ "$ISSTREAMER" = "1" ]; then
  347. # UPDATE STREAMER
  348. echo -e "${BGreen}Updating streamer${Reset}";
  349. addServer;
  350. # updateServerDatabasePass;
  351. fi
  352. cleanUp;
  353. echo -e "${BGreen}Updated to version ${BYellow}v$CMSVER${BGreen} !${Reset}";
  354. # NEW INSTALL
  355. else
  356. echo -ne "${BWhite}What to install ? ( 1|CMS , 2|STREAMER , 3|ALL-IN-ONE ) : ${Reset}";
  357. read SERVERTYPE
  358. if [ "$SERVERTYPE" = "1" ]; then
  359. ISCMS=1
  360. ISSTREAMER=0
  361. fi
  362. if [ "$SERVERTYPE" = "2" ]; then
  363. ISCMS=0
  364. ISSTREAMER=1
  365. fi
  366. if [ "$SERVERTYPE" = "3" ]; then
  367. ISCMS=1
  368. ISSTREAMER=1
  369. fi
  370. if [[ "$SERVERTYPE" != "1" && "$SERVERTYPE" != "2" && "$SERVERTYPE" != "3" ]]; then
  371. echo -e "${Red}You didn't selected anything! Aborting.${Reset}";
  372. exit;
  373. fi
  374. echo -ne "${BWhite}CMS URL without http:// ( subdomain.domain.com ) : ${Reset}";
  375. read CMSURL
  376. if [ -z "$CMSURL" ]; then
  377. echo -e "${BRed}You need to provide CMS URL !${Reset}";
  378. exit 1;
  379. fi
  380. echo -ne "${BWhite}CMS PORT, numeric only ( 8080 ) : ${Reset}";
  381. read CMSPORT
  382. if [ -z "$CMSPORT" ]; then
  383. CMSPORT="80"
  384. fi
  385. if [[ "$SERVERTYPE" = "3" && "$CMSPORT" = "80" ]]; then
  386. echo -e "${Red}You MUST use different port for cms if you want to install all in one! Aborting.${Reset}";
  387. exit;
  388. fi
  389. echo -ne "${BWhite}SERVER NAME ( ex. s01.domain.com ) : ${Reset}";
  390. read SERVERNAME
  391. if [ -z "$SERVERNAME" ]; then
  392. echo -e "${BRed}You need to provide SERVER NAME !${Reset}";
  393. exit 1;
  394. fi
  395. echo -ne "${BWhite}EXTERNAL IP ADDRESS : ${Reset}";
  396. read SERVERIP
  397. if [ -z "$SERVERIP" ]; then
  398. echo -e "${BRed}You need to provide EXTERNAL IP !${Reset}";
  399. exit 1;
  400. fi
  401. echo -ne "${BWhite}PRIVATE IP ADDRESS, if you don't have, same as above : ${Reset}";
  402. read SERVERINTIP
  403. if [ -z "$SERVERINTIP" ]; then
  404. echo -e "${BRed}You need to provide PRIVATE IP !${Reset}";
  405. exit 1;
  406. fi
  407.  
  408. writeConfig;
  409. upgradeFiles;
  410. ### FROM HERE WE INSTALL EVERYTHING ###
  411. if [ "$ISCMS" = "1" ]; then
  412. # Install packages
  413. installCMSPackages;
  414. # Install INITIAL DATABASE
  415. installDatabase;
  416. # Setup configs
  417. setupCMS;
  418. fi
  419.  
  420. if [ "$ISSTREAMER" = "1" ]; then
  421. # Install packages
  422. installStreamerPackages;
  423. # Setup streamer
  424. setupStreamer;
  425. # Make new ssh password
  426. updateSSHPassword;
  427. # Add the streamer to database
  428. addServer;
  429. # addServerToDatabase;
  430. fi
  431. # Removing temp files, restarting services
  432. cleanUp;
  433. echo -e "${BGreen}Installed version ${BYellow}v$CMSVER${BGreen} !${Reset}";
  434. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement