simpleocs.sh 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #!/bin/bash
  2. #
  3. # Mod by SL
  4. # ==================================================
  5. export DEBIAN_FRONTEND=noninteractive
  6. OS=`uname -m`;
  7. MYIP=$(wget -qO- icanhazip.com);
  8. MYIP2="s/xxxxxxxxx/$MYIP/g";
  9. ANU=$(ip -o $ANU -4 route show to default | awk '{print $5}');
  10. apt-get -y install apt-transport-https lsb-release ca-certificates curl
  11. curl -sSL -o /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
  12. sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
  13. apt update
  14. # install webserver
  15. cd
  16. rm /etc/nginx/sites-enabled/default
  17. rm /etc/nginx/sites-available/default
  18. wget -O /etc/nginx/nginx.conf "https://raw.githubusercontent.com/irwanmohi/test/master/simpleocs/nginx.conf"
  19. wget -O /etc/nginx/conf.d/vps.conf "https://raw.githubusercontent.com/irwanmohi/test/master/simpleocs/vps.conf"
  20. wget -O /etc/nginx/conf.d/monitoring.conf "https://raw.githubusercontent.com/irwanmohi/test/master/simpleocs/monitoring.conf"
  21. mkdir -p /home/vps/public_html
  22. wget -O /home/vps/public_html/index.php "https://raw.githubusercontent.com/irwanmohi/test/master/simpleocs/index.php"
  23. sed -i 's/listen = \/run\/php\/php7.4-fpm.sock/listen = 127.0.0.1:9000/g' /etc/php/7.4/fpm/pool.d/www.conf
  24. sed -i $MYIP2 /home/vps/public_html/index.php;
  25. service php7.4-fpm restart
  26. service nginx restart
  27. # OpenVPN monitoring
  28. apt-get install -y gcc libgeoip-dev python-virtualenv python-dev geoip-database-extra uwsgi uwsgi-plugin-python
  29. wget -O /srv/openvpn-monitor.tar "https://raw.githubusercontent.com/irwanmohi/test/master/simpleocs/openvpn-monitor.tar"
  30. cd /srv
  31. tar xf openvpn-monitor.tar
  32. cd openvpn-monitor
  33. virtualenv .
  34. . bin/activate
  35. pip install -r requirements.txt
  36. wget -O /etc/uwsgi/apps-available/openvpn-monitor.ini "https://raw.githubusercontent.com/irwanmohi/test/master/simpleocs/openvpn-monitor.ini"
  37. ln -s /etc/uwsgi/apps-available/openvpn-monitor.ini /etc/uwsgi/apps-enabled/
  38. # GeoIP For OpenVPN Monitor
  39. mkdir -p /var/lib/GeoIP
  40. wget -O /var/lib/GeoIP/GeoLite2-City.mmdb.gz "https://raw.githubusercontent.com/irwanmohi/test/master/simpleocs/GeoLite2-City.mmdb.gz"
  41. gzip -d /var/lib/GeoIP/GeoLite2-City.mmdb.gz
  42. # install vnstat gui
  43. cd /home/vps/public_html/
  44. wget https://raw.githubusercontent.com/daybreakersx/premscript/master/vnstat_php_frontend-1.5.1.tar.gz
  45. tar xf vnstat_php_frontend-1.5.1.tar.gz
  46. rm vnstat_php_frontend-1.5.1.tar.gz
  47. mv vnstat_php_frontend-1.5.1 vnstat
  48. cd vnstat
  49. sed -i "s/\$iface_list = array('eth0', 'sixxs');/\$iface_list = array('eth0');/g" config.php
  50. sed -i "s/\$language = 'nl';/\$language = 'en';/g" config.php
  51. sed -i 's/Internal/Internet/g' config.php
  52. sed -i '/SixXS IPv6/d' config.php
  53. cd
  54. # install mrtg
  55. wget -O /etc/snmp/snmpd.conf "https://raw.githubusercontent.com/daybreakersx/premscript/master/snmpd.conf"
  56. wget -O /root/mrtg-mem.sh "https://raw.githubusercontent.com/daybreakersx/premscript/master/mrtg-mem.sh"
  57. chmod +x /root/mrtg-mem.sh
  58. cd /etc/snmp/
  59. sed -i 's/TRAPDRUN=no/TRAPDRUN=yes/g' /etc/default/snmpd
  60. service snmpd restart
  61. snmpwalk -v 1 -c public localhost 1.3.6.1.4.1.2021.10.1.3.1
  62. mkdir -p /home/vps/public_html/mrtg
  63. cfgmaker --zero-speed 100000000 --global 'WorkDir: /home/vps/public_html/mrtg' --output /etc/mrtg.cfg public@localhost
  64. curl "https://raw.githubusercontent.com/daybreakersx/premscript/master/mrtg.conf" >> /etc/mrtg.cfg
  65. sed -i 's/WorkDir: \/var\/www\/mrtg/# WorkDir: \/var\/www\/mrtg/g' /etc/mrtg.cfg
  66. sed -i 's/# Options\[_\]: growright, bits/Options\[_\]: growright/g' /etc/mrtg.cfg
  67. indexmaker --output=/home/vps/public_html/mrtg/index.html /etc/mrtg.cfg
  68. if [ -x /usr/bin/mrtg ] && [ -r /etc/mrtg.cfg ]; then mkdir -p /var/log/mrtg ; env LANG=C /usr/bin/mrtg /etc/mrtg.cfg 2>&1 | tee -a /var/log/mrtg/mrtg.log ; fi
  69. if [ -x /usr/bin/mrtg ] && [ -r /etc/mrtg.cfg ]; then mkdir -p /var/log/mrtg ; env LANG=C /usr/bin/mrtg /etc/mrtg.cfg 2>&1 | tee -a /var/log/mrtg/mrtg.log ; fi
  70. if [ -x /usr/bin/mrtg ] && [ -r /etc/mrtg.cfg ]; then mkdir -p /var/log/mrtg ; env LANG=C /usr/bin/mrtg /etc/mrtg.cfg 2>&1 | tee -a /var/log/mrtg/mrtg.log ; fi
  71. cd
  72. # finishing
  73. cd
  74. chown -R www-data:www-data /home/vps/public_html
  75. /etc/init.d/nginx restart
  76. /etc/init.d/openvpn restart
  77. /etc/init.d/cron restart
  78. /etc/init.d/ssh restart
  79. /etc/init.d/dropbear restart
  80. /etc/init.d/fail2ban restart
  81. /etc/init.d/stunnel4 restart
  82. service php7.4-fpm restart
  83. service uwsgi restart
  84. systemctl daemon-reload
  85. service squid restart
  86. service pptpd restart
  87. /etc/init.d/webmin restart
  88. # clearing history
  89. rm -rf ~/.bash_history && history -c
  90. echo "unset HISTFILE" >> /etc/profile
  91. # remove unnecessary files
  92. apt -y autoremove
  93. apt -y autoclean
  94. apt -y clean