OCSAutoJanda.sh 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. #!/bin/bash
  2. if [ $USER != 'root' ]; then
  3. echo "You must run this as root"
  4. exit
  5. fi
  6. # initialisasi var
  7. export DEBIAN_FRONTEND=noninteractive
  8. OS=`uname -m`;
  9. if [[ -e /etc/debian_version ]]; then
  10. #OS=debian
  11. RCLOCAL='/etc/rc.local'
  12. else
  13. echo "You are not running this script on Debian OS"
  14. exit
  15. fi
  16. vps="vps";
  17. if [[ $vps = "vps" ]]; then
  18. source="https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master"
  19. else
  20. source="https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master"
  21. fi
  22. # go to root
  23. cd
  24. MYIP=$(wget -qO- ipv4.icanhazip.com);
  25. : '
  26. #https://github.com/adenvt/OcsPanels/wiki/tutor-debian
  27. clear
  28. echo ""
  29. echo "I need to ask some questions before starting setup"
  30. echo "You can leave the default option and just hit enter if you agree with the option"
  31. echo ""
  32. echo "First I need to know the new password of MySQL root user:"
  33. read -p "Password baru: " -e -i janda DatabasePass
  34. echo ""
  35. echo "Finally, name the Database Name for OCS Panels"
  36. echo " Please, use one word only, no special characters other than Underscore (_)"
  37. read -p " Database Name: " -e -i OCS_PANEL DatabaseName
  38. echo ""
  39. echo "Okay, that's all I need. We are ready to setup your OCS Panels now"
  40. read -n1 -r -p "Press any key to continue..."
  41. #apt-get update
  42. apt-get update -y
  43. apt-get install build-essential expect -y
  44. echo "clear" >> .bashrc
  45. echo 'echo -e ""' >> .bashrc
  46. echo 'echo -e "'####:'########:::::'###::::'##::: ##::'######:::"' >> .bashrc
  47. echo 'echo -e ". ##:: ##.... ##:::'## ##::: ###:: ##:'##... ##::"' >> .bashrc
  48. echo 'echo -e ": ##:: ##:::: ##::'##:. ##:: ####: ##: ##:::..:::"' >> .bashrc
  49. echo 'echo -e ": ##:: ########::'##:::. ##: ## ## ##: ##::'####:"' >> .bashrc
  50. echo 'echo -e ": ##:: ##.....::: #########: ##. ####: ##::: ##::"' >> .bashrc
  51. echo 'echo -e ": ##:: ##:::::::: ##.... ##: ##:. ###: ##::: ##::"' >> .bashrc
  52. echo 'echo -e "'####: ##:::::::: ##:::: ##: ##::. ##:. ######:::"' >> .bashrc
  53. echo 'echo -e "....::..:::::::::..:::::..::..::::..:::......::::"' >> .bashrc
  54. echo 'echo -e " Ipang Nett Nott "' >> .bashrc
  55. echo 'echo -e "welcome to the server $HOSTNAME" | lolcat' >> .bashrc
  56. echo 'echo -e "Script mod by Janda Baper Group" | lolcat' >> .bashrc
  57. echo 'echo -e "Type menu to display a list of commands" | lolcat' >> .bashrc
  58. echo 'echo -e ""' >> .bashrc
  59. apt-get install -y mysql-server
  60. #mysql_secure_installation
  61. so1=$(expect -c "
  62. spawn mysql_secure_installation; sleep 3
  63. expect \"\"; sleep 3; send \"\r\"
  64. expect \"\"; sleep 3; send \"Y\r\"
  65. expect \"\"; sleep 3; send \"$DatabasePass\r\"
  66. expect \"\"; sleep 3; send \"$DatabasePass\r\"
  67. expect \"\"; sleep 3; send \"Y\r\"
  68. expect \"\"; sleep 3; send \"Y\r\"
  69. expect \"\"; sleep 3; send \"Y\r\"
  70. expect \"\"; sleep 3; send \"Y\r\"
  71. expect eof; ")
  72. echo "$so1"
  73. #\r
  74. #Y
  75. #pass
  76. #pass
  77. #Y
  78. #Y
  79. #Y
  80. #Y
  81. chown -R mysql:mysql /var/lib/mysql/
  82. chmod -R 755 /var/lib/mysql/
  83. apt-get -y install nginx php5 php5-fpm php5-cli php5-mysql php5-mcrypt
  84. rm /etc/nginx/sites-enabled/default
  85. rm /etc/nginx/sites-available/default
  86. mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.backup
  87. mv /etc/nginx/conf.d/vps.conf /etc/nginx/conf.d/vps.conf.backup
  88. wget -O /etc/nginx/nginx.conf "https://raw.githubusercontent.com/janda09/autoscripts/master/nginx.conf"
  89. wget -O /etc/nginx/conf.d/vps.conf "https://raw.githubusercontent.com/janda09/autoscripts/master/vps.conf"
  90. sed -i 's/cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /etc/php5/fpm/php.ini
  91. sed -i 's/listen = \/var\/run\/php5-fpm.sock/listen = 127.0.0.1:9000/g' /etc/php5/fpm/pool.d/www.conf
  92. useradd -m vps
  93. mkdir -p /home/vps/public_html
  94. rm /home/vps/public_html/index.html
  95. echo "<?php phpinfo() ?>" > /home/vps/public_html/info.php
  96. chown -R www-data:www-data /home/vps/public_html
  97. chmod -R g+rw /home/vps/public_html service php5-fpm restart
  98. service php5-fpm restart
  99. service nginx restart
  100. apt-get -y install zip unzip
  101. cd /home/vps/public_html
  102. wget $source/OCS.zip
  103. unzip OCS.zip
  104. rm -f OCS.zip
  105. chown -R www-data:www-data /home/vps/public_html
  106. chmod -R g+rw /home/vps/public_html
  107. #mysql -u root -p
  108. so2=$(expect -c "
  109. spawn mysql -u root -p; sleep 3
  110. expect \"\"; sleep 3; send \"$DatabasePass\r\"
  111. expect \"\"; sleep 3; send \"CREATE DATABASE IF NOT EXISTS $DatabaseName;EXIT;\r\"
  112. expect eof; ")
  113. echo "$so2"
  114. #pass
  115. #CREATE DATABASE IF NOT EXISTS OCS_PANEL;EXIT;
  116. chmod 777 /home/vps/public_html/config
  117. chmod 777 /home/vps/public_html/config/inc.php
  118. chmod 777 /home/vps/public_html/config/route.php
  119. apt-get -y --force-yes -f install libxml-parser-perl
  120. clear
  121. echo "Open Browser, access http://$MYIP:85/ and complete the data as below!"
  122. echo "Database:"
  123. echo "- Database Host: localhost"
  124. echo "- Database Name: $DatabaseName"
  125. echo "- Database User: root"
  126. echo "- Database Pass: $DatabasePass"
  127. echo ""
  128. echo "Admin Login:"
  129. echo "- Username: anything you want"
  130. echo "- Password Baru: anything you want"
  131. echo "- Re-enter New Password: as desired"
  132. echo ""
  133. echo "Click Install and wait for the process to finish, go back to terminal and then press [ENTER key]!"
  134. sleep 3
  135. echo ""
  136. read -p "If the above step has been done, please Press [Enter] key to continue...."
  137. echo ""
  138. read -p "If you really believe the above step has been done, please Press [Enter] key to continue..."
  139. echo ""
  140. cd /root
  141. #wget http://www.webmin.com/jcameron-key.asc
  142. #apt-key add jcameron-key.asc
  143. #sed -i 's/ssl=1/ssl=0/g' /etc/webmin/miniserv.conf
  144. #service webmin restart
  145. #rm -f /root/jcameron-key.asc
  146. #rm -R /home/vps/public_html/installation
  147. cd
  148. rm -f /root/.bash_history && history -c
  149. echo "unset HISTFILE" >> /etc/profile
  150. chmod 755 /home/vps/public_html/config
  151. chmod 644 /home/vps/public_html/config/inc.php
  152. chmod 644 /home/vps/public_html/config/route.php
  153. # info
  154. clear
  155. echo "=======================================================" | tee -a log-install.txt
  156. echo "Please login Reseller Panel at http://$MYIP:85" | tee -a log-install.txt
  157. echo "" | tee -a log-install.txt
  158. echo "Auto Script Installer OCS Panels Mod by Janda Baper Group" | tee -a log-install.txt
  159. echo "" | tee -a log-install.txt
  160. echo "Thanks " | tee -a log-install.txt
  161. echo "" | tee -a log-install.txt
  162. echo "Installation Log --> /root/log-install.txt" | tee -a log-install.txt
  163. echo "=======================================================" | tee -a log-install.txt
  164. cd ~/
  165. #rm -f /root/ocspanel.sh