SHARE
TWEET

Untitled

a guest Jun 18th, 2019 293 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env bash
  2.  
  3. red=$'\e[1;31m'
  4. grn=$'\e[1;32m'
  5. yel=$'\e[1;33m'
  6. blu=$'\e[1;34m'
  7. mag=$'\e[1;35m'
  8. cyn=$'\e[1;36m'
  9. end=$'\e[0m'
  10.  
  11. wordpress_dl="https://www.dropbox.com/s/mxhj0urerc7g6p9/wordpress-5.2.2.zip?dl=0"
  12. apache2_conf="https://www.dropbox.com/s/fj41jfcsg8o6v95/apache2.conf?dl=0"
  13. salt_url="https://api.wordpress.org/secret-key/1.1/salt/"
  14. nginx_conf="https://www.dropbox.com/s/42umjfjsyr6esmn/master.vhost?dl=0"
  15. php5_dotdeb="https://pastebin.com/raw/jVBQNtar"
  16. php7_dotdeb="https://pastebin.com/raw/LWGptHGd"
  17. php_sury="https://pastebin.com/raw/PisgrN5F"
  18.  
  19. tambah_domain_apache() {
  20.     clear
  21.     echo -e "##### Skrip add domain by Hardinal #####"
  22.     echo -e "Web: \e[32mhttps://jasa.hardinal.com/${end}"
  23.     echo -e "Email: \e[33mjasa@hardinal.com${end}"
  24.     echo "_________________"
  25.     rm -fr wordpress latest.zip domain.txt domain-tanpa-titik.txt db_name.txt db_name1.txt u_name.txt u_name1.txt versi{1..4}.txt versi.txt /var/www/html/info.php
  26.     echo
  27.     echo "Mau tambah domain? Ga usah bingung lagi"
  28.     echo "Yang perlu Anda masukkan hanya nama domain"
  29.     echo
  30.     echo "Skrip ini juga bisa digunakan untuk menginstall sub domain."
  31.     echo "Yang perlu diinput nanti bukan nama domain, melainkan sub domainnya"
  32.     echo "Misal domainnya bernama example.com, maka kalo mau install subdomain,"
  33.     echo "input full URL sub domainnya, misalnya ${yel}sub.example.com${end}"
  34.     echo
  35.     echo "Silahkan ketik nama domain, misal ${blu}example.com${end}, tanpa www dan tanpa http"
  36.     echo "(Kalo salah input hapus dengan CTRL + Backspace)"
  37.     echo
  38.     while true
  39.     do
  40.             read -p $'\e[34m'"Domain${end}: " domain
  41.             read -p $'\e[34m'"Masukan nama domain (sekali lagi)${end}: " domain2
  42.             echo
  43.             [ "$domain" = "$domain2" ] && break
  44.             echo "Nama domain ga cocok, ulang lagi ya!"
  45.     done
  46.     periksa="/etc/apache2/sites-available/$domain.conf"
  47.     if [ -f "$periksa" ]
  48.     then
  49.         echo -e "\e[33mDomain tidak bisa diinstall karena sudah terpasang di server ini${end}"
  50.         echo -e "\e[33mSilahkan jalankan kembali skrip ini, masukkan domain lain.${end}"
  51.         echo ""
  52.     else
  53.         echo $domain >> domain.txt
  54.         clean_domain_1=`sed 's/[^a-zA-Z0-9]//g'  domain.txt > domain-tanpa-titik.txt`
  55.         untuk_db=`cat domain-tanpa-titik.txt`
  56.         echo $untuk_db >> db_name1.txt
  57.         echo $untuk_db >> u_name1.txt
  58.         sed 's/^/db_/' db_name1.txt > db_name.txt
  59.         sed 's/^/u_/' u_name1.txt > u_name.txt
  60.         db_name=`cat db_name.txt`
  61.         u_name=`cat u_name.txt`
  62.         rm -f domain.txt domain-tanpa-titik.txt db_name.txt db_name1.txt u_name.txt u_name1.txt
  63.         file="/root/.pwdmysql"
  64.         if [ -f "$file" ]
  65.         then
  66.                 echo
  67.         else
  68.                 echo "Sorry, skrip ini hanya bekerja di server yang di setting Hardinal"
  69.             echo "Info lanjut silahkan email ke jasa@hardinal.com"
  70.                 exit 1
  71.         fi
  72.         echo "Sip, udah semua.."
  73.         echo "Tekan '${yel}y${end}' lalu Enter untuk melanjutkan (tunggu maks. 1 menit)"
  74.         read -p "Atau '${yel}t${end}' lalu Enter untuk membatalkan ... <y/t> ?" tanya
  75.         echo
  76.         if [[ $tanya == "y" || $tanya == "Y" || $tanya == "yes" || $tanya == "Yes" || $tanya == "Ya" || $tanya == "ya" ]]
  77.         then
  78.             echo "${blu}Mohon tunggu...${end}"
  79.                 echo
  80.                 password_root_mysql=`cat /root/.pwdmysql`
  81.                 password_wp_config=`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 12 | head -n 1`
  82.                 mysql -uroot -p$password_root_mysql -e "CREATE DATABASE $db_name /*\!40100 DEFAULT CHARACTER SET utf8 */;"
  83.                 mysql -uroot -p$password_root_mysql -e "CREATE USER $u_name@localhost IDENTIFIED BY '$password_wp_config';"
  84.                 mysql -uroot -p$password_root_mysql -e "GRANT ALL PRIVILEGES ON $db_name.* TO '$u_name'@'localhost';"
  85.                 mysql -uroot -p$password_root_mysql -e "FLUSH PRIVILEGES;"
  86.             wget -q --no-check-certificate $apache2_conf -O master2.vhost
  87.             sed -i "s/xDOMAINx/$domain/g" master2.vhost
  88.             mv master2.vhost /etc/apache2/sites-available/$domain.conf
  89.             touch /root/.rnd
  90.             mkdir -p /etc/ssl/$domain
  91.             openssl req -new -newkey rsa:2048 -days 3650 -nodes -x509 -subj "/C=ID/ST=DKI/L=Jakarta/O=Tech/CN=$domain" -keyout /etc/ssl/$domain/$domain.key -out /etc/ssl/$domain/$domain.crt > /dev/null 2>&1
  92.                 curl -L -# -k --connect-timeout 5 --retry 1 $wordpress_dl -o latest.zip
  93.                 unzip -qq latest.zip
  94.                 rm -f latest.zip
  95.                 mv wordpress /var/www/html/$domain
  96.                 mv /var/www/html/$domain/wp-config-sample.php /var/www/html/$domain/wp-config.php
  97.                 sed -i "s/database_name_here/$db_name/g" /var/www/html/$domain/wp-config.php
  98.                 sed -i "s/username_here/$u_name/g" /var/www/html/$domain/wp-config.php
  99.                 sed -i "s/password_here/$password_wp_config/g" /var/www/html/$domain/wp-config.php
  100.             sed -i "s/( '/('/g" /var/www/html/$domain/wp-config.php
  101.             sed -i "s/' )/')/g" /var/www/html/$domain/wp-config.php
  102.             sed -i "s/table_prefix =/table_prefix  =/g" /var/www/html/$domain/wp-config.php
  103.             salts=$(curl -s $salt_url)
  104.             while read -r salt; do
  105.             cari="define('$(echo "$salt" | cut -d "'" -f 2)"
  106.             ganti=$(echo "$salt" | cut -d "'" -f 4)
  107.             sed -i "/^$cari/s/put your unique phrase here/$(echo $ganti | sed -e 's/\\/\\\\/g' -e 's/\//\\\//g' -e 's/&/\\\&/g')/" /var/www/html/$domain/wp-config.php
  108.             done <<< "$salts"
  109.             dos2unix /var/www/html/$domain/wp-config.php > /dev/null 2>&1
  110.                 chown -R www-data:www-data /var/www/html/$domain
  111.             a2ensite $domain > /dev/null 2>&1
  112.             service apache2 reload
  113.             clear
  114.                 echo "_________________"
  115.             echo
  116.                 echo "Selamat, domain ${blu}$domain${end} baru saja ditambahkan ke server ini"
  117.             echo "Silahkan daftarkan dan ganti NS ke NS Cloudflare, lalu tunggu +/- 30 menit supaya domain bisa diakses."
  118.                 echo "Video Cloudflare bisa Anda liat di ${blu}http://vid.hardinal.com/2/${end}"
  119.                 echo "_________________"
  120.             echo
  121.                 echo "Setelah menunggu 30 menit-an, silahkan kunjungi:"
  122.             echo
  123.                 echo "http://$domain"
  124.             echo
  125.                 echo "Atau kalo domainnya ingin pake ${red}www${end} kunjungi"
  126.             echo
  127.             echo "http://www.$domain"
  128.             echo
  129.                 echo "Anda nanti akan dibawa ke proses instalasi Wordpress"
  130.                 echo "_________________"
  131.             echo
  132.                 echo "Oia, Jika Anda perlu rincian database, silahkan gunakan rincian di bawah ini"
  133.             echo
  134.                 echo "${yel}DATABASE${end}: $db_name"
  135.                 echo "${yel}USERNAME${end}: $u_name"
  136.                 echo "${yel}PASSWORD${end}: $password_wp_config"
  137.             echo
  138.         else
  139.                 rm -f db_name1.txt  db_name.txt  domain-tanpa-titik.txt  domain.txt  u_name1.txt  u_name.txt info.php
  140.                 exit 0
  141.         fi
  142.     fi
  143. }
  144.  
  145. reconfig_apache() {
  146.     echo -e "\e[33m##### PERHATIAN: Ada Update #####${end}"
  147.         echo "Konfigurasi Apache pada server Anda masih pake settingan lama"
  148.     echo "Mau diperbaharui ngga?"
  149.     echo
  150.     echo "Kalo mau, tekan '${yel}y${end}' lalu Enter untuk melanjutkan (tunggu beberapa menit)"
  151.     echo "Atau '${yel}t${end}' lalu Enter untuk tetap menggunakan settingan jadul."
  152.     echo
  153.     echo "${blu}WARNING:${end}"
  154.     echo "${red}Kalo salah satu web Anda ada yang pake format HTTPS${end}"
  155.     echo "${red}yang SSL nya itu dapat beli, konsultasikan dulu ke saya${end}"
  156.     echo "${red}Karena akan merusak settingan${end}"
  157.     echo
  158.     read -p "Jawab <y/t> (Kalo ragu t aja, nanti kabari saya)?" tanya
  159.     echo
  160.     if [[ $tanya == "y" || $tanya == "Y" || $tanya == "yes" || $tanya == "Yes" || $tanya == "Ya" || $tanya == "ya" ]]
  161.     then
  162.         echo "${blu}Siaap, sebentar ya...${end}"
  163.         echo
  164.             sleep 2
  165.         echo -e "##### TAHAP 1 (dari 2) #####"
  166.         echo
  167.         ls -I 000-default.conf -I phpmyadmin.conf -I file-manager.conf -1 /etc/apache2/sites-enabled/ > list.txt
  168.         sed -i 's/.conf//g' list.txt
  169.         for domain in $(cat list.txt); do  
  170.             unlink /etc/apache2/sites-enabled/$domain.conf
  171.             rm -f /etc/apache2/sites-available/$domain.conf
  172.             echo "Konfigurasi ulang domain ${blu}$domain${end} tahap 1 (dari 2)"
  173.         done
  174.         echo
  175.         echo -e "##### TAHAP 2 (dari 2) #####"
  176.         echo
  177.         sleep 3
  178.         for domain in $(cat list.txt); do
  179.             wget -q --no-check-certificate $apache2_conf -O master2.vhost
  180.             sed -i "s/xDOMAINx/$domain/g" master2.vhost
  181.             mv master2.vhost /etc/apache2/sites-available/$domain.conf
  182.             touch /root/.rnd
  183.             echo "Konfigurasi ulang domain ${blu}$domain${end} tahap 2 (dari 2)"
  184.             mkdir -p /etc/ssl/$domain
  185.             openssl req -new -newkey rsa:2048 -days 3650 -nodes -x509 -subj "/C=ID/ST=DKI/L=Jakarta/O=Tech/CN=$domain" -keyout /etc/ssl/$domain/$domain.key -out /etc/ssl/$domain/$domain.crt > /dev/null 2>&1
  186.             a2ensite $domain > /dev/null 2>&1
  187.         done
  188.         service apache2 reload
  189.         echo "dh20180617" >> /.dhversion
  190.         rm -f list.txt
  191.         echo
  192.         echo "Mantaap, dalam ${red}5${end} detik, Anda akan dilanjutkan ke proses add domain seperti biasa"
  193.         sleep 5
  194.     else
  195.         echo "Ya sudah kalo ga mau,"
  196.         echo "Dalam ${red}5${end} detik Anda akan dilanjutkan ke proses add domain seperti biasa"
  197.         sleep 5
  198.         echo
  199.     fi
  200.     clear
  201.     tambah_domain_apache
  202. }
  203.  
  204. tambah_domain_nginx() {
  205.     clear
  206.     echo -e "##### Skrip add domain by Hardinal #####"
  207.     echo -e "Web: \e[32mhttps://jasa.hardinal.com/${end}"
  208.     echo -e "Email: \e[33mjasa@hardinal.com${end}"
  209.     echo "_________________"
  210.     rm -fr wordpress latest.zip domain.txt domain-tanpa-titik.txt db_name.txt db_name1.txt u_name.txt u_name1.txt versi{1..4}.txt versi.txt /var/www/html/info.php
  211.     echo
  212.     echo "Mau tambah domain? Ga usah bingung lagi"
  213.     echo "Yang perlu Anda masukkan hanya nama domain"
  214.     echo
  215.     echo "Skrip ini juga bisa digunakan untuk menginstall sub domain."
  216.     echo "Yang perlu diinput nanti bukan nama domain, melainkan sub domainnya"
  217.     echo "Misal domainnya bernama example.com, maka kalo mau install subdomain,"
  218.     echo "input full URL sub domainnya, misalnya ${yel}sub.example.com${end}"
  219.     echo
  220.     echo "Silahkan ketik nama domain, misal ${blu}example.com${end}, tanpa www dan tanpa http"
  221.     echo "(Kalo salah input hapus dengan CTRL + Backspace)"
  222.     echo
  223.     while true
  224.     do
  225.             read -p $'\e[34m'"Domain${end}: " domain
  226.             read -p $'\e[34m'"Masukan nama domain (sekali lagi)${end}: " domain2
  227.             echo
  228.             [ "$domain" = "$domain2" ] && break
  229.             echo "Nama domain ga cocok, ulang lagi ya!"
  230.     done
  231.     periksa="/etc/nginx/sites-available/$domain"
  232.     if [ -f "$periksa" ]
  233.     then
  234.         echo -e "\e[33mDomain tidak bisa diinstall karena sudah terpasang di server ini${end}"
  235.         echo -e "\e[33mSilahkan jalankan kembali skrip ini, masukkan domain lain.${end}"
  236.         echo ""
  237.     else
  238.         echo $domain >> domain.txt
  239.         clean_domain_1=`sed 's/[^a-zA-Z0-9]//g'  domain.txt > domain-tanpa-titik.txt`
  240.         untuk_db=`cat domain-tanpa-titik.txt`
  241.         echo $untuk_db >> db_name1.txt
  242.         echo $untuk_db >> u_name1.txt
  243.         sed 's/^/db_/' db_name1.txt > db_name.txt
  244.         sed 's/^/u_/' u_name1.txt > u_name.txt
  245.         db_name=`cat db_name.txt`
  246.         u_name=`cat u_name.txt`
  247.         rm -f domain.txt domain-tanpa-titik.txt db_name.txt db_name1.txt u_name.txt u_name1.txt
  248.         file="/root/.pwdmysql"
  249.         if [ -f "$file" ]
  250.         then
  251.                 echo
  252.         else
  253.                 echo "Sorry, skrip ini hanya bekerja di server yang di setting Hardinal"
  254.             echo "Info lanjut silahkan email ke jasa@hardinal.com"
  255.                 exit 1
  256.         fi
  257.         echo "Sip, udah semua.."
  258.         echo "Tekan '${yel}y${end}' lalu Enter untuk melanjutkan (tunggu maks. 1 menit)"
  259.         read -p "Atau '${yel}t${end}' lalu Enter untuk membatalkan ... <y/t> ?" tanya
  260.         echo
  261.         if [[ $tanya == "y" || $tanya == "Y" || $tanya == "yes" || $tanya == "Yes" || $tanya == "Ya" || $tanya == "ya" ]]
  262.         then
  263.             echo "${blu}Mohon tunggu...${end}"
  264.                 echo
  265.                 password_root_mysql=`cat /root/.pwdmysql`
  266.                 password_wp_config=`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 12 | head -n 1`
  267.                 mysql -uroot -p$password_root_mysql -e "CREATE DATABASE $db_name /*\!40100 DEFAULT CHARACTER SET utf8 */;"
  268.                 mysql -uroot -p$password_root_mysql -e "CREATE USER $u_name@localhost IDENTIFIED BY '$password_wp_config';"
  269.                 mysql -uroot -p$password_root_mysql -e "GRANT ALL PRIVILEGES ON $db_name.* TO '$u_name'@'localhost';"
  270.                 mysql -uroot -p$password_root_mysql -e "FLUSH PRIVILEGES;"
  271.             php -r \@phpinfo\(\)\; | grep 'PHP Version' -m 1 > versi-php.txt
  272.             awk '{ print $4 }' versi-php.txt > versi-php1.txt
  273.             cut -c -1 versi-php1.txt > jessie_php.txt
  274.             jessie_php=`cat jessie_php.txt`
  275.             cut -c -3 versi-php1.txt > stretch_php.txt
  276.             stretch_php=`cat stretch_php.txt`
  277.             rm -f versi-php.txt versi-php1.txt jessie_php.txt stretch_php.txt
  278.             wget -q --no-check-certificate $nginx_conf -O master.vhost
  279.             debversion=`lsb_release -sc`
  280.             if [ "$debversion" = "jessie" ]; then
  281.                     if [ $jessie_php = 5 ]
  282.                     then
  283.                             sed -i 's/xGANTIx/unix:\/var\/run\/php5-'$domain'-fpm.sock/g' master.vhost
  284.                     echo "" >>  master.vhost
  285.                     wget -q $php5_dotdeb -O /etc/php5/fpm/pool.d/$domain.conf
  286.                     sed -i "s/xDOMAINx/$domain/g" /etc/php5/fpm/pool.d/$domain.conf
  287.                     echo "" >> /etc/php5/fpm/pool.d/$domain.conf
  288.                     dos2unix /etc/php5/fpm/pool.d/$domain.conf > /dev/null 2>&1
  289.                     service php5-fpm reload
  290.                     else
  291.                             sed -i 's/xGANTIx/unix:\/run\/php\/php7.0-'$domain'-fpm.sock/g' master.vhost
  292.                     echo "" >>  master.vhost
  293.                     wget -q $php7_dotdeb -O /etc/php/7.0/fpm/pool.d/$domain.conf
  294.                     sed -i "s/xDOMAINx/$domain/g" /etc/php/7.0/fpm/pool.d/$domain.conf
  295.                     echo "" >> /etc/php/7.0/fpm/pool.d/$domain.conf
  296.                     dos2unix /etc/php/7.0/fpm/pool.d/$domain.conf > /dev/null 2>&1
  297.                     service php7.0-fpm reload
  298.                     fi
  299.             elif [ "$debversion" = "stretch" ]; then
  300.                 sed -i 's/xGANTIx/unix:\/run\/php\/php'$stretch_php'-'$domain'-fpm.sock/g' master.vhost
  301.                 echo "" >>  master.vhost
  302.                 wget -q $php_sury -O /etc/php/$stretch_php/fpm/pool.d/$domain.conf
  303.                 sed -i "s/xDOMAINx/$domain/g" /etc/php/$stretch_php/fpm/pool.d/$domain.conf
  304.                 sed -i 's/xGANTIx/'$stretch_php'/g' /etc/php/$stretch_php/fpm/pool.d/$domain.conf
  305.                 echo "" >> /etc/php/$stretch_php/fpm/pool.d/$domain.conf
  306.                 dos2unix /etc/php/$stretch_php/fpm/pool.d/$domain.conf > /dev/null 2>&1
  307.                 service php$stretch_php-fpm reload
  308.             else
  309.                         sed -i 's/xGANTIx/unix:\/var\/run\/php5-'$domain'-fpm.sock/g' master.vhost
  310.                 echo "" >>  master.vhost
  311.                 wget -q $php5_dotdeb -O /etc/php5/fpm/pool.d/$domain.conf
  312.                 sed -i "s/xDOMAINx/$domain/g" /etc/php5/fpm/pool.d/$domain.conf
  313.                 echo "" >> /etc/php5/fpm/pool.d/$domain.conf
  314.                 dos2unix /etc/php5/fpm/pool.d/$domain.conf > /dev/null 2>&1
  315.                 service php5-fpm reload
  316.             fi
  317.                 sed -i "s/xDOMAINx/$domain/g" master.vhost
  318.                 mv master.vhost /etc/nginx/sites-available/$domain
  319.             sed -i '/robots.txt {/a \\t        try_files $uri $uri/ /index.php?$args;' /etc/nginx/sites-available/$domain
  320.                 ln -sf /etc/nginx/sites-available/$domain /etc/nginx/sites-enabled/
  321.                 curl -L -# -k --connect-timeout 5 --retry 1 $wordpress_dl -o latest.zip
  322.                 unzip -qq latest.zip
  323.                 rm -f latest.zip
  324.                 mv wordpress /var/www/html/$domain
  325.                 mv /var/www/html/$domain/wp-config-sample.php /var/www/html/$domain/wp-config.php
  326.                 sed -i "s/database_name_here/$db_name/g" /var/www/html/$domain/wp-config.php
  327.                 sed -i "s/username_here/$u_name/g" /var/www/html/$domain/wp-config.php
  328.                 sed -i "s/password_here/$password_wp_config/g" /var/www/html/$domain/wp-config.php
  329.             sed -i "s/( '/('/g" /var/www/html/$domain/wp-config.php
  330.             sed -i "s/' )/')/g" /var/www/html/$domain/wp-config.php
  331.             sed -i "s/table_prefix =/table_prefix  =/g" /var/www/html/$domain/wp-config.php
  332.             salts=$(curl -s $salt_url)
  333.             while read -r salt; do
  334.             cari="define('$(echo "$salt" | cut -d "'" -f 2)"
  335.             ganti=$(echo "$salt" | cut -d "'" -f 4)
  336.             sed -i "/^$cari/s/put your unique phrase here/$(echo $ganti | sed -e 's/\\/\\\\/g' -e 's/\//\\\//g' -e 's/&/\\\&/g')/" /var/www/html/$domain/wp-config.php
  337.             done <<< "$salts"
  338.             dos2unix /var/www/html/$domain/wp-config.php > /dev/null 2>&1
  339.                 chown -R www-data:www-data /var/www/html/$domain
  340.                 rm -f latest.zip
  341.             mkdir -p /etc/ssl/$domain/
  342.             touch /root/.rnd
  343.             openssl req -new -newkey rsa:2048 -days 3650 -nodes -x509 -subj "/C=ID/ST=DKI/L=Jakarta/O=Tech/CN=$domain" -keyout /etc/ssl/$domain/$domain.key -out /etc/ssl/$domain/$domain.crt > /dev/null 2>&1
  344.             sed -i '$ilisten 443 ssl http2;' /etc/nginx/sites-available/$domain
  345.             sed -i '$issl_certificate /etc/ssl/'$domain'/'$domain'.crt;' /etc/nginx/sites-available/$domain
  346.             sed -i '$issl_certificate_key /etc/ssl/'$domain'/'$domain'.key;' /etc/nginx/sites-available/$domain
  347.                 service nginx reload
  348.             clear
  349.                 echo "_________________"
  350.             echo
  351.                 echo "Selamat, domain ${blu}$domain${end} baru saja ditambahkan ke server ini"
  352.             echo "Silahkan daftarkan dan ganti NS ke NS Cloudflare, lalu tunggu +/- 30 menit supaya domain bisa diakses."
  353.                 echo "Video Cloudflare bisa Anda liat di ${blu}http://vid.hardinal.com/2/${end}"
  354.                 echo "_________________"
  355.             echo
  356.                 echo "Setelah menunggu 30 menit-an, silahkan kunjungi:"
  357.             echo
  358.                 echo "http://$domain"
  359.             echo
  360.                 echo "Atau kalo domainnya ingin pake ${red}www${end} kunjungi"
  361.             echo
  362.             echo "http://www.$domain"
  363.             echo
  364.                 echo "Anda nanti akan dibawa ke proses instalasi Wordpress"
  365.                 echo "_________________"
  366.             echo
  367.                 echo "Oia, Jika Anda perlu rincian database, silahkan gunakan rincian di bawah ini"
  368.             echo
  369.                 echo "${yel}DATABASE${end}: $db_name"
  370.                 echo "${yel}USERNAME${end}: $u_name"
  371.                 echo "${yel}PASSWORD${end}: $password_wp_config"
  372.             echo
  373.         else
  374.                 rm -f db_name1.txt  db_name.txt  domain-tanpa-titik.txt  domain.txt  u_name1.txt  u_name.txt info.php
  375.                 exit 0
  376.         fi
  377.     fi
  378. }
  379.  
  380.  
  381. reconfig_nginx() {
  382.     echo -e "\e[33m##### PERHATIAN: Ada Update #####${end}"
  383.         echo "Konfigurasi Nginx pada server Anda masih pake settingan lama"
  384.     echo "Mau diperbaharui ngga?"
  385.     echo
  386.     echo "Kalo mau, tekan '${yel}y${end}' lalu Enter untuk melanjutkan (tunggu beberapa menit)"
  387.     echo "Atau '${yel}t${end}' lalu Enter untuk tetap menggunakan settingan jadul."
  388.     echo
  389.     echo "${blu}WARNING:${end}"
  390.     echo "${red}Kalo salah satu web Anda ada yang pake format HTTPS${end}"
  391.     echo "${red}yang SSL nya itu dapat beli, konsultasikan dulu ke saya${end}"
  392.     echo "${red}Karena akan merusak settingan${end}"
  393.     echo
  394.     read -p "Jawab <y/t> (Kalo ragu t aja, nanti kabari saya)?" tanya
  395.     echo
  396.     if [[ $tanya == "y" || $tanya == "Y" || $tanya == "yes" || $tanya == "Yes" || $tanya == "Ya" || $tanya == "ya" ]]
  397.     then
  398.         echo "${blu}Siaap, sebentar ya...${end}"
  399.         echo
  400.             sleep 2
  401.         echo -e "##### TAHAP 1 (dari 2) #####"
  402.         echo
  403.         ls -I default -I phpmyadmin -I filemanager -1 /etc/nginx/sites-enabled/ > list.txt
  404.         for domain in $(ls -I default -I phpmyadmin -I filemanager -1 /etc/nginx/sites-enabled/); do   
  405.             rm -fr /etc/nginx/untuk_cache/$domain
  406.             unlink /etc/nginx/sites-enabled/$domain
  407.             rm -f /etc/nginx/sites-available/$domain
  408.             rm -f /var/log/nginx/$domain.error.log
  409.             rm -f /etc/php5/fpm/pool.d/$domain.conf
  410.             rm -f /etc/php/5.6/fpm/pool.d/$domain.conf
  411.             rm -f /etc/php/7.0/fpm/pool.d/$domain.conf
  412.             rm -f /etc/php/7.2/fpm/pool.d/$domain.conf
  413.             rm -f /etc/php/7.3/fpm/pool.d/$domain.conf
  414.             echo "Konfigurasi ulang domain ${blu}$domain${end} tahap 1 (dari 2)"
  415.         done
  416.         echo
  417.         echo -e "##### TAHAP 2 (dari 2) #####"
  418.         echo
  419.         sleep 3
  420.         for domain in $(cat list.txt); do  
  421.             php -r \@phpinfo\(\)\; | grep 'PHP Version' -m 1 > versi-php.txt
  422.             awk '{ print $4 }' versi-php.txt > versi-php1.txt
  423.             cut -c -1 versi-php1.txt > jessie_php.txt
  424.             jessie_php=`cat jessie_php.txt`
  425.             cut -c -3 versi-php1.txt > stretch_php.txt
  426.             stretch_php=`cat stretch_php.txt`
  427.             rm -f versi-php.txt versi-php1.txt jessie_php.txt stretch_php.txt
  428.             wget -q --no-check-certificate $nginx_conf -O master.vhost
  429.             debversion=`lsb_release -sc`
  430.             if [ "$debversion" = "jessie" ]; then
  431.                     if [ $jessie_php = 5 ]
  432.                     then
  433.                             sed -i 's/xGANTIx/unix:\/var\/run\/php5-'$domain'-fpm.sock/g' master.vhost
  434.                     echo "" >>  master.vhost
  435.                     wget -q $php5_dotdeb -O /etc/php5/fpm/pool.d/$domain.conf
  436.                     sed -i "s/xDOMAINx/$domain/g" /etc/php5/fpm/pool.d/$domain.conf
  437.                     echo "" >> /etc/php5/fpm/pool.d/$domain.conf
  438.                     dos2unix /etc/php5/fpm/pool.d/$domain.conf > /dev/null 2>&1
  439.                     else
  440.                             sed -i 's/xGANTIx/unix:\/run\/php\/php7.0-'$domain'-fpm.sock/g' master.vhost
  441.                     echo "" >>  master.vhost
  442.                     wget -q $php7_dotdeb -O /etc/php/7.0/fpm/pool.d/$domain.conf
  443.                     sed -i "s/xDOMAINx/$domain/g" /etc/php/7.0/fpm/pool.d/$domain.conf
  444.                     echo "" >> /etc/php/7.0/fpm/pool.d/$domain.conf
  445.                     dos2unix /etc/php/7.0/fpm/pool.d/$domain.conf > /dev/null 2>&1
  446.                     fi
  447.             elif [ "$debversion" = "stretch" ]; then
  448.                 sed -i 's/xGANTIx/unix:\/run\/php\/php'$stretch_php'-'$domain'-fpm.sock/g' master.vhost
  449.                 echo "" >>  master.vhost
  450.                 wget -q $php_sury -O /etc/php/$stretch_php/fpm/pool.d/$domain.conf
  451.                 sed -i "s/xDOMAINx/$domain/g" /etc/php/$stretch_php/fpm/pool.d/$domain.conf
  452.                 sed -i 's/xGANTIx/'$stretch_php'/g' /etc/php/$stretch_php/fpm/pool.d/$domain.conf
  453.                 echo "" >> /etc/php/$stretch_php/fpm/pool.d/$domain.conf
  454.                 dos2unix /etc/php/$stretch_php/fpm/pool.d/$domain.conf > /dev/null 2>&1
  455.             else
  456.                         sed -i 's/xGANTIx/unix:\/var\/run\/php5-'$domain'-fpm.sock/g' master.vhost
  457.                 echo "" >>  master.vhost
  458.                 wget -q $php5_dotdeb -O /etc/php5/fpm/pool.d/$domain.conf
  459.                 sed -i "s/xDOMAINx/$domain/g" /etc/php5/fpm/pool.d/$domain.conf
  460.                 echo "" >> /etc/php5/fpm/pool.d/$domain.conf
  461.                 dos2unix /etc/php5/fpm/pool.d/$domain.conf > /dev/null 2>&1
  462.             fi
  463.                 sed -i "s/xDOMAINx/$domain/g" master.vhost
  464.                 mv master.vhost /etc/nginx/sites-available/$domain
  465.             sed -i '/robots.txt {/a \\t        try_files $uri $uri/ /index.php?$args;' /etc/nginx/sites-available/$domain
  466.                 ln -sf /etc/nginx/sites-available/$domain /etc/nginx/sites-enabled/
  467.             echo "Konfigurasi ulang domain ${blu}$domain${end} tahap 2 (dari 2)"
  468.             mkdir -p /etc/ssl/$domain/
  469.             touch /root/.rnd
  470.             openssl req -new -newkey rsa:2048 -days 3650 -nodes -x509 -subj "/C=ID/ST=DKI/L=Jakarta/O=Tech/CN=$domain" -keyout /etc/ssl/$domain/$domain.key -out /etc/ssl/$domain/$domain.crt > /dev/null 2>&1
  471.             sed -i '$ilisten 443 ssl http2;' /etc/nginx/sites-available/$domain
  472.             sed -i '$issl_certificate /etc/ssl/'$domain'/'$domain'.crt;' /etc/nginx/sites-available/$domain
  473.             sed -i '$issl_certificate_key /etc/ssl/'$domain'/'$domain'.key;' /etc/nginx/sites-available/$domain
  474.         done
  475.         echo
  476.         debversion=`lsb_release -sc`
  477.         php -r \@phpinfo\(\)\; | grep 'PHP Version' -m 1 > versi-php.txt
  478.         awk '{ print $4 }' versi-php.txt > versi-php1.txt
  479.         cut -c -1 versi-php1.txt > jessie_php.txt
  480.         jessie_php=`cat jessie_php.txt`
  481.         cut -c -3 versi-php1.txt > stretch_php.txt
  482.         stretch_php=`cat stretch_php.txt`
  483.         rm -f versi-php.txt versi-php1.txt jessie_php.txt stretch_php.txt
  484.         if [ "$debversion" = "jessie" ]; then
  485.                 if [ $jessie_php = 5 ]
  486.                 then
  487.                 service php5-fpm reload
  488.                 else
  489.                 service php7.0-fpm reload
  490.                 fi
  491.         elif [ "$debversion" = "stretch" ]; then
  492.             service php$stretch_php-fpm reload
  493.         else
  494.             service php5-fpm reload
  495.         fi
  496.         service nginx reload
  497.         echo "dh20180617" >> /.dhversion
  498.         rm -f list.txt
  499.         echo "Mantaap, dalam ${red}5${end} detik, Anda akan dilanjutkan ke proses add domain seperti biasa"
  500.         sleep 5
  501.     else
  502.         echo "Ya sudah kalo ga mau,"
  503.         echo "Dalam ${red}5${end} detik Anda akan dilanjutkan ke proses add domain seperti biasa"
  504.         sleep 5
  505.         echo
  506.     fi
  507.     clear
  508.     tambah_domain_nginx
  509. }
  510.  
  511.  
  512. clear
  513.  
  514.  
  515. dh_version="/.dhversion"
  516. if [ -f "$dh_version" ]
  517. then
  518.     if [[ `ps -acx|grep apache|wc -l` > 0 ]]; then
  519.         tambah_domain_apache
  520.     fi
  521.     if [[ `ps -acx|grep nginx|wc -l` > 0 ]]; then
  522.         tambah_domain_nginx
  523.     fi
  524. else
  525.     if [[ `ps -acx|grep apache|wc -l` > 0 ]]; then
  526.         reconfig_apache
  527.     fi
  528.     if [[ `ps -acx|grep nginx|wc -l` > 0 ]]; then
  529.         reconfig_nginx
  530.     fi
  531. fi
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top