SHARE
TWEET

Untitled

a guest Feb 23rd, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env bash
  2. red=$'\e[1;31m'
  3. grn=$'\e[1;32m'
  4. yel=$'\e[1;33m'
  5. blu=$'\e[1;34m'
  6. mag=$'\e[1;35m'
  7. cyn=$'\e[1;36m'
  8. end=$'\e[0m'
  9. tambah_domain() {
  10.     clear
  11.     echo -e "##### Skrip add domain by Hardinal #####"
  12.     echo -e "Web: \e[32mhttps://jasa.hardinal.com/${end}"
  13.     echo -e "Email: \e[33mjasa@hardinal.com${end}"
  14.     echo "_________________"
  15.     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
  16.     echo
  17.     echo "Mau tambah domain? Ga usah bingung lagi"
  18.     echo "Yang perlu Anda masukkan hanya nama domain"
  19.     echo
  20.     echo "Skrip ini juga bisa digunakan untuk menginstall sub domain."
  21.     echo "Yang perlu diinput nanti bukan nama domain, melainkan sub domainnya"
  22.     echo "Misal domainnya bernama example.com, maka kalo mau install subdomain,"
  23.     echo "input full URL sub domainnya, misalnya ${yel}sub.example.com${end}"
  24.     echo
  25.     echo "Silahkan ketik nama domain, misal ${blu}example.com${end}, tanpa www dan tanpa http"
  26.     echo "(Kalo salah input hapus dengan CTRL + Backspace)"
  27.     echo
  28.     while true
  29.     do
  30.             read -p $'\e[34m'"Domain${end}: " domain
  31.             read -p $'\e[34m'"Masukan nama domain (sekali lagi)${end}: " domain2
  32.             echo
  33.             [ "$domain" = "$domain2" ] && break
  34.             echo "Nama domain ga cocok, ulang lagi ya!"
  35.     done
  36.     periksa="/etc/nginx/sites-available/$domain"
  37.     if [ -f "$periksa" ]
  38.     then
  39.         echo -e "\e[33mDomain tidak bisa diinstall karena sudah terpasang di server ini${end}"
  40.         echo -e "\e[33mSilahkan jalankan kembali skrip ini, masukkan domain lain.${end}"
  41.         echo ""
  42.     else
  43.         echo $domain >> domain.txt
  44.         clean_domain_1=`sed 's/[^a-zA-Z0-9]//g'  domain.txt > domain-tanpa-titik.txt`
  45.         untuk_db=`cat domain-tanpa-titik.txt`
  46.         echo $untuk_db >> db_name1.txt
  47.         echo $untuk_db >> u_name1.txt
  48.         sed 's/^/db_/' db_name1.txt > db_name.txt
  49.         sed 's/^/u_/' u_name1.txt > u_name.txt
  50.         db_name=`cat db_name.txt`
  51.         u_name=`cat u_name.txt`
  52.         rm -f domain.txt domain-tanpa-titik.txt db_name.txt db_name1.txt u_name.txt u_name1.txt
  53.         file="/root/.pwdmysql"
  54.         if [ -f "$file" ]
  55.         then
  56.                 echo
  57.         else
  58.                 echo "Sorry, skrip ini hanya bekerja di server yang di setting Hardinal"
  59.             echo "Info lanjut silahkan email ke jasa@hardinal.com"
  60.                 exit 1
  61.         fi
  62.         echo "Sip, udah semua.."
  63.         echo "Tekan '${yel}y${end}' lalu Enter untuk melanjutkan (tunggu maks. 1 menit)"
  64.         read -p "Atau '${yel}t${end}' lalu Enter untuk membatalkan ... <y/t> ?" tanya
  65.         echo
  66.         if [[ $tanya == "y" || $tanya == "Y" || $tanya == "yes" || $tanya == "Yes" || $tanya == "Ya" || $tanya == "ya" ]]
  67.         then
  68.             echo "${blu}Mohon tunggu...${end}"
  69.                 echo
  70.                 password_root_mysql=`cat /root/.pwdmysql`
  71.                 password_wp_config=`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 12 | head -n 1`
  72.                 mysql -uroot -p$password_root_mysql -e "CREATE DATABASE $db_name /*\!40100 DEFAULT CHARACTER SET utf8 */;"
  73.                 mysql -uroot -p$password_root_mysql -e "CREATE USER $u_name@localhost IDENTIFIED BY '$password_wp_config';"
  74.                 mysql -uroot -p$password_root_mysql -e "GRANT ALL PRIVILEGES ON $db_name.* TO '$u_name'@'localhost';"
  75.                 mysql -uroot -p$password_root_mysql -e "FLUSH PRIVILEGES;"
  76.             php -r \@phpinfo\(\)\; | grep 'PHP Version' -m 1 > versi-php.txt
  77.             awk '{ print $4 }' versi-php.txt > versi-php1.txt
  78.             cut -c -1 versi-php1.txt > jessie_php.txt
  79.             jessie_php=`cat jessie_php.txt`
  80.             cut -c -3 versi-php1.txt > stretch_php.txt
  81.             stretch_php=`cat stretch_php.txt`
  82.             rm -f versi-php.txt versi-php1.txt jessie_php.txt stretch_php.txt
  83.             wget -q --no-check-certificate https://www.dropbox.com/s/42umjfjsyr6esmn/master.vhost?dl=0 -O master.vhost
  84.             debversion=`lsb_release -sc`
  85.             if [ "$debversion" = "jessie" ]; then
  86.                     if [ $jessie_php = 5 ]
  87.                     then
  88.                             sed -i 's/xGANTIx/unix:\/var\/run\/php5-'$domain'-fpm.sock/g' master.vhost
  89.                     echo "" >>  master.vhost
  90.                     wget -q https://pastebin.com/raw/jVBQNtar -O /etc/php5/fpm/pool.d/$domain.conf
  91.                     sed -i "s/xDOMAINx/$domain/g" /etc/php5/fpm/pool.d/$domain.conf
  92.                     echo "" >> /etc/php5/fpm/pool.d/$domain.conf
  93.                     service php5-fpm reload
  94.                     else
  95.                             sed -i 's/xGANTIx/unix:\/run\/php\/php7.0-'$domain'-fpm.sock/g' master.vhost
  96.                     echo "" >>  master.vhost
  97.                     wget -q https://pastebin.com/raw/LWGptHGd -O /etc/php/7.0/fpm/pool.d/$domain.conf
  98.                     sed -i "s/xDOMAINx/$domain/g" /etc/php/7.0/fpm/pool.d/$domain.conf
  99.                     echo "" >> /etc/php/7.0/fpm/pool.d/$domain.conf
  100.                     service php7.0-fpm reload
  101.                     fi
  102.             elif [ "$debversion" = "stretch" ]; then
  103.                 sed -i 's/xGANTIx/unix:\/run\/php\/php'$stretch_php'-'$domain'-fpm.sock/g' master.vhost
  104.                 echo "" >>  master.vhost
  105.                 wget -q https://pastebin.com/raw/PisgrN5F -O /etc/php/$stretch_php/fpm/pool.d/$domain.conf
  106.                 sed -i "s/xDOMAINx/$domain/g" /etc/php/$stretch_php/fpm/pool.d/$domain.conf
  107.                 sed -i 's/xGANTIx/'$stretch_php'/g' /etc/php/$stretch_php/fpm/pool.d/$domain.conf
  108.                 echo "" >> /etc/php/$stretch_php/fpm/pool.d/$domain.conf
  109.                 service php$stretch_php-fpm reload
  110.             else
  111.                         sed -i 's/xGANTIx/unix:\/var\/run\/php5-'$domain'-fpm.sock/g' master.vhost
  112.                 echo "" >>  master.vhost
  113.                 wget -q https://pastebin.com/raw/jVBQNtar -O /etc/php5/fpm/pool.d/$domain.conf
  114.                 sed -i "s/xDOMAINx/$domain/g" /etc/php5/fpm/pool.d/$domain.conf
  115.                 echo "" >> /etc/php5/fpm/pool.d/$domain.conf
  116.                 service php5-fpm reload
  117.             fi
  118.                 sed -i "s/xDOMAINx/$domain/g" master.vhost
  119.                 mv master.vhost /etc/nginx/sites-available/$domain
  120.             sed -i '/robots.txt {/a \\t        try_files $uri $uri/ /index.php?$args;' /etc/nginx/sites-available/$domain
  121.                 ln -sf /etc/nginx/sites-available/$domain /etc/nginx/sites-enabled/
  122.                 curl -L -# -k --connect-timeout 5 --retry 1 'https://www.dropbox.com/s/fd3fqf6keena2r2/wordpress-5.1.zip?dl=0' -o latest.zip
  123.                 unzip -qq latest.zip
  124.                 rm -f latest.zip
  125.                 mv wordpress /var/www/html/$domain
  126.                 mv /var/www/html/$domain/wp-config-sample.php /var/www/html/$domain/wp-config.php
  127.                 sed -i "s/database_name_here/$db_name/g" /var/www/html/$domain/wp-config.php
  128.                 sed -i "s/username_here/$u_name/g" /var/www/html/$domain/wp-config.php
  129.                 sed -i "s/password_here/$password_wp_config/g" /var/www/html/$domain/wp-config.php
  130.             salts=$(curl -s https://api.wordpress.org/secret-key/1.1/salt/)
  131.             while read -r salt; do
  132.             cari="define( '$(echo "$salt" | cut -d "'" -f 2)"
  133.             ganti=$(echo "$salt" | cut -d "'" -f 4)
  134.             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
  135.             done <<< "$salts"
  136.                 chown -R www-data:www-data /var/www/html/$domain
  137.                 rm -f latest.zip
  138.             mkdir -p /etc/ssl/$domain/
  139.             touch /root/.rnd
  140.             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
  141.             sed -i '$ilisten 443 ssl http2;' /etc/nginx/sites-available/$domain
  142.             sed -i '$issl_certificate /etc/ssl/'$domain'/'$domain'.crt;' /etc/nginx/sites-available/$domain
  143.             sed -i '$issl_certificate_key /etc/ssl/'$domain'/'$domain'.key;' /etc/nginx/sites-available/$domain
  144.                 service nginx reload
  145.             clear
  146.                 echo "_________________"
  147.             echo
  148.                 echo "Selamat, domain ${blu}$domain${end} baru saja ditambahkan ke server ini"
  149.             echo "Silahkan daftarkan dan ganti NS ke NS Cloudflare, lalu tunggu +/- 30 menit supaya domain bisa diakses."
  150.                 echo "Video Cloudflare bisa Anda liat di ${blu}http://vid.hardinal.com/2/${end}"
  151.                 echo "_________________"
  152.             echo
  153.                 echo "Setelah menunggu 30 menit-an, silahkan kunjungi:"
  154.             echo
  155.                 echo "http://$domain"
  156.             echo
  157.                 echo "Atau kalo domainnya ingin pake ${red}www${end} kunjungi"
  158.             echo
  159.             echo "http://www.$domain"
  160.             echo
  161.                 echo "Anda nanti akan dibawa ke proses instalasi Wordpress"
  162.                 echo "_________________"
  163.             echo
  164.                 echo "Oia, Jika Anda perlu rincian database, silahkan gunakan rincian di bawah ini"
  165.             echo
  166.                 echo "${yel}DATABASE${end}: $db_name"
  167.                 echo "${yel}USERNAME${end}: $u_name"
  168.                 echo "${yel}PASSWORD${end}: $password_wp_config"
  169.             echo
  170.         else
  171.                 rm -f db_name1.txt  db_name.txt  domain-tanpa-titik.txt  domain.txt  u_name1.txt  u_name.txt info.php
  172.                 exit 0
  173.         fi
  174.     fi
  175. }
  176. clear
  177. dh_version="/.dhversion"
  178. if [ -f "$dh_version" ]
  179. then
  180.     tambah_domain
  181. else
  182.     echo -e "\e[33m##### PERHATIAN: Ada Update #####${end}"
  183.         echo "Konfigurasi Nginx pada server Anda masih pake settingan lama"
  184.     echo "Mau diperbaharui ngga?"
  185.     echo
  186.     echo "Kalo mau, tekan '${yel}y${end}' lalu Enter untuk melanjutkan (tunggu beberapa menit)"
  187.     echo "Atau '${yel}t${end}' lalu Enter untuk tetap menggunakan settingan jadul."
  188.     echo
  189.     echo "${blu}WARNING:${end} ${red}Kalo salah satu web Anda ada yang pake HTTPS / SSL${end}"
  190.     echo "${red}Konsultasikan dulu ke saya, karena akan merusak settingan${end}"
  191.     echo
  192.     read -p "Jawab <y/t> ?" tanya
  193.     echo
  194.     if [[ $tanya == "y" || $tanya == "Y" || $tanya == "yes" || $tanya == "Yes" || $tanya == "Ya" || $tanya == "ya" ]]
  195.     then
  196.         echo "${blu}Siaap, sebentar ya...${end}"
  197.         echo
  198.             sleep 2
  199.         echo -e "##### TAHAP 1 (dari 2) #####"
  200.         echo
  201.         ls -I default -I phpmyadmin -I filemanager -1 /etc/nginx/sites-enabled/ > list.txt
  202.         for domain in $(ls -I default -I phpmyadmin -I filemanager -1 /etc/nginx/sites-enabled/); do   
  203.             rm -fr /etc/nginx/untuk_cache/$domain
  204.             unlink /etc/nginx/sites-enabled/$domain
  205.             rm -f /etc/nginx/sites-available/$domain
  206.             rm -f /var/log/nginx/$domain.error.log
  207.             rm -f /etc/php5/fpm/pool.d/$domain.conf
  208.             rm -f /etc/php/5.6/fpm/pool.d/$domain.conf
  209.             rm -f /etc/php/7.0/fpm/pool.d/$domain.conf
  210.             rm -f /etc/php/7.2/fpm/pool.d/$domain.conf
  211.             rm -f /etc/php/7.3/fpm/pool.d/$domain.conf
  212.             echo "Konfigurasi ulang domain ${blu}$domain${end} tahap 1 (dari 2)"
  213.         done
  214.         echo
  215.         echo -e "##### TAHAP 2 (dari 2) #####"
  216.         echo
  217.         sleep 3
  218.         for domain in $(cat list.txt); do  
  219.             php -r \@phpinfo\(\)\; | grep 'PHP Version' -m 1 > versi-php.txt
  220.             awk '{ print $4 }' versi-php.txt > versi-php1.txt
  221.             cut -c -1 versi-php1.txt > jessie_php.txt
  222.             jessie_php=`cat jessie_php.txt`
  223.             cut -c -3 versi-php1.txt > stretch_php.txt
  224.             stretch_php=`cat stretch_php.txt`
  225.             rm -f versi-php.txt versi-php1.txt jessie_php.txt stretch_php.txt
  226.             wget -q --no-check-certificate https://www.dropbox.com/s/42umjfjsyr6esmn/master.vhost?dl=0 -O master.vhost
  227.             debversion=`lsb_release -sc`
  228.             if [ "$debversion" = "jessie" ]; then
  229.                     if [ $jessie_php = 5 ]
  230.                     then
  231.                             sed -i 's/xGANTIx/unix:\/var\/run\/php5-'$domain'-fpm.sock/g' master.vhost
  232.                     echo "" >>  master.vhost
  233.                     wget -q https://pastebin.com/raw/jVBQNtar -O /etc/php5/fpm/pool.d/$domain.conf
  234.                     sed -i "s/xDOMAINx/$domain/g" /etc/php5/fpm/pool.d/$domain.conf
  235.                     echo "" >> /etc/php5/fpm/pool.d/$domain.conf
  236.                     else
  237.                             sed -i 's/xGANTIx/unix:\/run\/php\/php7.0-'$domain'-fpm.sock/g' master.vhost
  238.                     echo "" >>  master.vhost
  239.                     wget -q https://pastebin.com/raw/LWGptHGd -O /etc/php/7.0/fpm/pool.d/$domain.conf
  240.                     sed -i "s/xDOMAINx/$domain/g" /etc/php/7.0/fpm/pool.d/$domain.conf
  241.                     echo "" >> /etc/php/7.0/fpm/pool.d/$domain.conf
  242.                     fi
  243.             elif [ "$debversion" = "stretch" ]; then
  244.                 sed -i 's/xGANTIx/unix:\/run\/php\/php'$stretch_php'-'$domain'-fpm.sock/g' master.vhost
  245.                 echo "" >>  master.vhost
  246.                 wget -q https://pastebin.com/raw/PisgrN5F -O /etc/php/$stretch_php/fpm/pool.d/$domain.conf
  247.                 sed -i "s/xDOMAINx/$domain/g" /etc/php/$stretch_php/fpm/pool.d/$domain.conf
  248.                 sed -i 's/xGANTIx/'$stretch_php'/g' /etc/php/$stretch_php/fpm/pool.d/$domain.conf
  249.                 echo "" >> /etc/php/$stretch_php/fpm/pool.d/$domain.conf
  250.             else
  251.                         sed -i 's/xGANTIx/unix:\/var\/run\/php5-'$domain'-fpm.sock/g' master.vhost
  252.                 echo "" >>  master.vhost
  253.                 wget -q https://pastebin.com/raw/jVBQNtar -O /etc/php5/fpm/pool.d/$domain.conf
  254.                 sed -i "s/xDOMAINx/$domain/g" /etc/php5/fpm/pool.d/$domain.conf
  255.                 echo "" >> /etc/php5/fpm/pool.d/$domain.conf
  256.             fi
  257.                 sed -i "s/xDOMAINx/$domain/g" master.vhost
  258.                 mv master.vhost /etc/nginx/sites-available/$domain
  259.             sed -i '/robots.txt {/a \\t        try_files $uri $uri/ /index.php?$args;' /etc/nginx/sites-available/$domain
  260.                 ln -sf /etc/nginx/sites-available/$domain /etc/nginx/sites-enabled/
  261.             echo "Konfigurasi ulang domain ${blu}$domain${end} tahap 2 (dari 2)"
  262.         done
  263.         echo
  264.         debversion=`lsb_release -sc`
  265.         php -r \@phpinfo\(\)\; | grep 'PHP Version' -m 1 > versi-php.txt
  266.         awk '{ print $4 }' versi-php.txt > versi-php1.txt
  267.         cut -c -1 versi-php1.txt > jessie_php.txt
  268.         jessie_php=`cat jessie_php.txt`
  269.         cut -c -3 versi-php1.txt > stretch_php.txt
  270.         stretch_php=`cat stretch_php.txt`
  271.         rm -f versi-php.txt versi-php1.txt jessie_php.txt stretch_php.txt
  272.         if [ "$debversion" = "jessie" ]; then
  273.                 if [ $jessie_php = 5 ]
  274.                 then
  275.                 service php5-fpm reload
  276.                 else
  277.                 service php7.0-fpm reload
  278.                 fi
  279.         elif [ "$debversion" = "stretch" ]; then
  280.             service php$stretch_php-fpm reload
  281.         else
  282.             service php5-fpm reload
  283.         fi
  284.         service nginx reload
  285.         echo "dh20180617" >> /.dhversion
  286.         rm -f list.txt
  287.         echo "Mantaap, dalam ${red}5${end} detik, Anda akan dilanjutkan ke proses add domain seperti biasa"
  288.         sleep 5
  289.     else
  290.         echo "Ya sudah kalo ga mau,"
  291.         echo "Dalam ${red}5${end} detik Anda akan dilanjutkan ke proses add domain seperti biasa"
  292.         sleep 5
  293.         echo
  294.     fi
  295.     clear
  296.     tambah_domain
  297. 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
 
Top