batchdebian12.sh 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. #!/bin/sh
  2. DISTRO_URL="https://codeload.github.com/nightflyza/OphanimFlow/zip/refs/heads/main"
  3. DISTRO_NAME="main.zip"
  4. DISTRO_DIR="OphanimFlow-main"
  5. DIALOG="dialog"
  6. FETCH="/usr/bin/wget"
  7. APACHE_VERSION="apache24"
  8. PRESETS_PATH="dist/presets/debian12/"
  9. APACHE_DATA_PATH="/var/www/html/"
  10. APACHE_CONFIG_DIR="/etc/apache2/"
  11. APACHE_INIT_SCRIPT="/usr/sbin/service apache2"
  12. APACHE_CONFIG_PRESET_NAME="debi12_apache2.conf"
  13. APACHE_CONFIG_NAME="apache2.conf"
  14. PHP_CONFIG_PRESET="php82.ini"
  15. PHP_CONFIG_PATH="/etc/php/8.2/apache2/php.ini"
  16. MYSQL_INIT_SCRIPT="/usr/sbin/service mariadb"
  17. WEB_DIR="of"
  18. DUMP_PATH="dist/dumps/ophanimflow.sql"
  19. LANDING_PATH="dist/landing/"
  20. CRONTAB_PRESET="dist/presets/debian12/crontab.debian"
  21. #initial repos update
  22. echo "Preparing to installation.."
  23. apt update
  24. apt -y upgrade
  25. #installation of basic software required for installer
  26. echo "Installing basic software required for Debianstaller.."
  27. apt install -y dialog
  28. apt install -y net-tools
  29. apt install -y gnupg2
  30. #MariaDB setup
  31. apt install -y software-properties-common dirmngr
  32. apt install -y mariadb-server
  33. apt install -y mariadb-client
  34. apt install -y libmariadb-dev
  35. apt install -y default-libmysqlclient-dev
  36. mariadb --version
  37. systemctl start mariadb
  38. systemctl enable mariadb
  39. #required software setup
  40. apt install -y expat
  41. apt install -y libexpat1-dev
  42. apt install -y sudo
  43. apt install -y curl
  44. apt install -y apache2
  45. apt install -y libapache2-mod-php8.2
  46. apt install -y build-essential
  47. apt install -y libxmlrpc-c++8-dev
  48. #apt install -y ipset
  49. apt install -y memcached
  50. apt install -y redis
  51. apt install -y php8.2-cli
  52. apt install -y php8.2-mysql
  53. apt install -y php8.2-mysqli
  54. apt install -y php8.2-mbstring
  55. apt install -y php8.2-bcmath
  56. apt install -y php8.2-curl
  57. apt install -y php8.2-gd
  58. apt install -y php8.2-snmp
  59. apt install -y php8.2-soap
  60. apt install -y php8.2-zip
  61. apt install -y php8.2-imap
  62. #apt install -y php8.2-json
  63. apt install -y php8.2-tokenizer
  64. apt install -y php8.2-xml
  65. apt install -y php8.2-xmlreader
  66. apt install -y php8.2-xmlwriter
  67. apt install -y php8.2-simplexml
  68. apt install -y php8.2-sqlite3
  69. apt install -y php8.2-sockets
  70. apt install -y php8.2-opcache
  71. apt install -y php8.2-json
  72. apt install -y php8.2-pdo
  73. apt install -y php8.2-pdo-sqlite
  74. apt install -y php8.2-phar
  75. apt install -y php8.2-posix
  76. #apt install -y php8.2-memcached
  77. #apt install -y php8.2-redis
  78. #apt install -y ffmpeg
  79. #apt install -y graphviz
  80. apt install -y vim-tiny
  81. #apt install -y arping
  82. apt install -y elinks
  83. apt install -y mc
  84. apt install -y nano
  85. #apt install -y nmap
  86. apt install -y mtr
  87. apt install -y expect
  88. #apt install -y bwm-ng
  89. apt install -y git
  90. apt install -y netdiag
  91. apt install -y htop
  92. apt install -y rsyslog
  93. #installing pmacct
  94. apt install -y pmacct
  95. #generating mysql password
  96. GEN_MYS_PASS=`dd if=/dev/urandom count=128 bs=1 2>&1 | md5sum | cut -b-8`
  97. MYSQL_PASSWD="mys"${GEN_MYS_PASS}
  98. #
  99. # Preconfiguring software
  100. #
  101. #downloading and unpacking app distro
  102. $FETCH -O ${DISTRO_NAME} ${DISTRO_URL}
  103. unzip ${DISTRO_NAME}
  104. mkdir ${APACHE_DATA_PATH}${WEB_DIR}
  105. mv ${DISTRO_DIR}/* ${APACHE_DATA_PATH}${WEB_DIR}/
  106. rm -fr ${DISTRO_DIR} ${DISTRO_NAME}
  107. cd ${APACHE_DATA_PATH}${WEB_DIR}/
  108. #deploying database, webserver and php presets
  109. cp -R ${PRESETS_PATH}${APACHE_CONFIG_PRESET_NAME} ${APACHE_CONFIG_DIR}${APACHE_CONFIG_NAME}
  110. cp -R ${PRESETS_PATH}${PHP_CONFIG_PRESET} ${PHP_CONFIG_PATH}
  111. cp -R ${PRESETS_PATH}000-default.conf ${APACHE_CONFIG_DIR}sites-enabled/000-default.conf
  112. #preconfiguring app
  113. chmod -R 777 config content exports gdata
  114. #creating collector config and data storage placeholders
  115. mkdir /ofstorage
  116. touch /etc/of.conf
  117. touch /etc/pretag.map
  118. chmod -R 777 /etc/of.conf /etc/pretag.map /ofstorage
  119. #setting landing page
  120. cp -R ${LANDING_PATH}* ${APACHE_DATA_PATH}
  121. #loading default crontab preset
  122. crontab ${CRONTAB_PRESET}
  123. # start services
  124. ${APACHE_INIT_SCRIPT} start
  125. ${MYSQL_INIT_SCRIPT} start
  126. # updating sudoers
  127. echo "User_Alias OPHANIM = www-data" >> /etc/sudoers.d/ophanim
  128. echo "OPHANIM ALL = NOPASSWD: ALL" >> /etc/sudoers.d/ophanim
  129. echo "New MySQL password is ${MYSQL_PASSWD}"
  130. #Setting MySQL root password
  131. mysqladmin -u root password ${MYSQL_PASSWD}
  132. # configuring database
  133. cat ${DUMP_PATH} | /usr/bin/mysql -u root --password=${MYSQL_PASSWD}
  134. # updating passwords and login in mysql.ini
  135. perl -e "s/mylogin/root/g" -pi ./config/mysql.ini
  136. perl -e "s/newpassword/${MYSQL_PASSWD}/g" -pi ./config/mysql.ini
  137. #overriding binary paths in alter.config
  138. cat ${PRESETS_PATH}alter_append >> ./config/alter.ini
  139. #setting up updater
  140. cp -R ${PRESETS_PATH}autoofupdate.sh /bin/
  141. chmod a+x /bin/autoofupdate.sh
  142. #enabling required apache modules
  143. /usr/sbin/a2enmod headers
  144. /usr/sbin/a2enmod expires
  145. #restarting database and web server
  146. ${MYSQL_INIT_SCRIPT} restart
  147. ${APACHE_INIT_SCRIPT} restart
  148. #here we go?
  149. echo "========== Installation finished! ============="
  150. echo "Please, reboot your server to check correct"
  151. echo "startup of all services. You cah access web"
  152. echo "interface by URL http://thishost/${WEB_DIR}/"
  153. echo "with login admin and password demo"
  154. echo "================================================"