wrinstaller.sh 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. #!/bin/sh
  2. #
  3. # Acta, non verba
  4. #
  5. OS_NAME=`uname`
  6. case $OS_NAME in
  7. FreeBSD)
  8. DIALOG=${DIALOG=dialog}
  9. FETCH="/usr/bin/fetch"
  10. APACHE_VERSION="apache24"
  11. APACHE_DATA_PATH="/usr/local/www/apache24/data/"
  12. APACHE_CONFIG_DIR="/usr/local/etc/apache24/"
  13. APACHE_INIT_SCRIPT="/usr/local/etc/rc.d/apache24"
  14. APACHE_CONFIG_PRESET_NAME="httpd24f7.conf"
  15. APACHE_CONFIG_NAME="httpd.conf"
  16. PHP_CONFIG_PRESET="php.ini"
  17. MYSQL_INIT_SCRIPT="/usr/local/etc/rc.d/mysql-server"
  18. CACHE_INIT_SCRIPT="/usr/local/etc/rc.d/memcached"
  19. WR_WEB_DIR="wr/"
  20. INSTALLER_WORK_DIR="/usr/local/wrinstaller/"
  21. INSTALLER_LOG="/var/log/wrinstaller.log"
  22. #some remote paths here
  23. DL_PACKAGES_URL="http://wolfrecorder.com/packages/"
  24. DL_PACKAGES_EXT=".tar.gz"
  25. DL_WR_URL="http://wolfrecorder.com/"
  26. DL_WR_NAME="wr.tgz"
  27. set PATH=/usr/local/bin:/usr/local/sbin:$PATH
  28. # config interface section
  29. clear
  30. $DIALOG --title "WolfRecorder NVR installation" --msgbox "This wizard helps you to install WolfRecorder of the latest stable version to CLEAN (!) FreeBSD distribution" 10 50
  31. clear
  32. #new or migration installation
  33. clear
  34. $DIALOG --menu "Type of WolfRecorder installation" 10 75 8 \
  35. NEW "This is new WolfRecorder installation"\
  36. MIG "Migrating existing WolfRecorder setup from another host"\
  37. 2> /tmp/insttype
  38. clear
  39. $DIALOG --menu "Choose FreeBSD version and architecture" 16 50 8 \
  40. 132_6E "FreeBSD 13.2 amd64"\
  41. 131_6T "FreeBSD 13.1 amd64"\
  42. 131_3T "FreeBSD 13.1 i386"\
  43. 124_6T "FreeBSD 12.4 amd64"\
  44. 124_6E "FreeBSD 12.4 amd64"\
  45. 2> /tmp/wrarch
  46. clear
  47. #some passwords generation or manual input
  48. PASSW_MODE=`cat /tmp/insttype`
  49. case $PASSW_MODE in
  50. NEW)
  51. #generating mysql password
  52. GEN_MYS_PASS=`dd if=/dev/urandom count=128 bs=1 2>&1 | md5 | cut -b-8`
  53. echo "mys"${GEN_MYS_PASS} > /tmp/wrmypass
  54. ;;
  55. MIG)
  56. #request previous MySQL password
  57. clear
  58. $DIALOG --title "MySQL root password" --inputbox "Enter your previous installation MySQL root password" 8 60 2> /tmp/wrmypass
  59. clear
  60. $DIALOG --title "WolfRecorder serial" --inputbox "Enter your previous installation WolfRecorder serial number" 8 60 2> /tmp/wrsrl
  61. ;;
  62. esac
  63. #setting some opts for future
  64. MYSQL_PASSWD=`cat /tmp/wrmypass`
  65. ARCH=`cat /tmp/wrarch`
  66. case $PASSW_MODE in
  67. NEW)
  68. WRSERIAL="AUTO"
  69. ;;
  70. MIG)
  71. WRSERIAL=`cat /tmp/wrsrl`
  72. ;;
  73. esac
  74. # cleaning temp files
  75. rm -fr /tmp/wrarch
  76. rm -fr /tmp/wrmypass
  77. rm -fr /tmp/wrsrl
  78. rm -fr /tmp/insttype
  79. #last chance to exit
  80. $DIALOG --title "Check settings" --yesno "Are all of these settings correct? \n \n MySQL password: ${MYSQL_PASSWD} \n System: ${ARCH} \n WolfRecorder serial: ${WRSERIAL}\n" 10 60
  81. AGREE=$?
  82. clear
  83. # confirm installation
  84. case $AGREE in
  85. 0)
  86. echo "Everything is okay! Installation is starting."
  87. # preparing for installation
  88. mkdir ${INSTALLER_WORK_DIR}
  89. cd ${INSTALLER_WORK_DIR}
  90. #######################################
  91. # Platform specific issues handling #
  92. #######################################
  93. case $ARCH in
  94. 124_6E)
  95. #12.4E contains PHP 8.2 binaries
  96. APACHE_CONFIG_PRESET_NAME="httpd24f8.conf"
  97. ;;
  98. 132_6E)
  99. #13.2E contains PHP 8.2 binaries
  100. APACHE_CONFIG_PRESET_NAME="httpd24f8.conf"
  101. ;;
  102. esac
  103. #botstrapping pkg ng
  104. pkg info
  105. #check is FreeBSD installation clean
  106. PKG_COUNT=`/usr/sbin/pkg info | /usr/bin/wc -l`
  107. if [ $PKG_COUNT -ge 2 ]
  108. then
  109. echo "WRinstaller supports setup only for clean FreeBSD distribution. Installation is aborted."
  110. exit
  111. fi
  112. # install prebuilded binary packages
  113. $DIALOG --infobox "Downloading binary packages." 4 60
  114. $FETCH ${DL_PACKAGES_URL}${ARCH}${DL_PACKAGES_EXT}
  115. #check is binary packages download has beed completed
  116. if [ -f ${ARCH}${DL_PACKAGES_EXT} ];
  117. then
  118. $DIALOG --infobox "Binary packages download has been completed." 4 60
  119. else
  120. echo "=== Error: binary packages are not available. Installation is aborted. ==="
  121. exit
  122. fi
  123. # unpacking and installing packages
  124. $DIALOG --infobox "Unpacking binary packages." 4 60
  125. tar zxvf ${ARCH}${DL_PACKAGES_EXT} 2>> ${INSTALLER_LOG}
  126. cd ${ARCH}
  127. $DIALOG --infobox "Software installation is in progress. This takes a while." 4 70
  128. ls -1 | xargs -n 1 pkg add >> ${INSTALLER_LOG}
  129. $DIALOG --infobox "Binary packages installation has been completed." 4 60
  130. ################################################
  131. # Downloading and unpacking WolfRecorder distro
  132. ################################################
  133. $DIALOG --infobox "WolfRecorder download, unpacking and installation is in progress." 4 60
  134. #back to installation directory
  135. cd ${INSTALLER_WORK_DIR}
  136. # downloading distro
  137. $FETCH ${DL_WR_URL}${DL_WR_NAME}
  138. #check is wolfrecorder distro download complete
  139. if [ -f ${DL_WR_NAME} ];
  140. then
  141. $DIALOG --infobox "WolfRecorder download has been completed." 4 60
  142. else
  143. echo "=== Error: WolfRecorder release is not available. Installation is aborted. ==="
  144. exit
  145. fi
  146. mkdir ${APACHE_DATA_PATH}${WR_WEB_DIR}
  147. cp -R ${DL_WR_NAME} ${APACHE_DATA_PATH}${WR_WEB_DIR}
  148. cd ${APACHE_DATA_PATH}${WR_WEB_DIR}
  149. tar zxvf ${DL_WR_NAME} 2>> ${INSTALLER_LOG}
  150. chmod -R 777 content/ config/ exports/ howl/
  151. # setting up config presets
  152. cp -R dist/presets/freebsd/${APACHE_CONFIG_PRESET_NAME} ${APACHE_CONFIG_DIR}${APACHE_CONFIG_NAME}
  153. cp -R dist/presets/freebsd/${PHP_CONFIG_PRESET} /usr/local/etc/php.ini
  154. cat dist/presets/freebsd/rc.preconf >> /etc/rc.conf
  155. cat dist/presets/freebsd/sysctl.preconf >> /etc/sysctl.conf
  156. cat dist/presets/freebsd/loader.preconf >> /boot/loader.conf
  157. cp -R dist/presets/freebsd/firewall.conf /etc/firewall.conf
  158. chmod a+x /etc/firewall.conf
  159. # setting up default web awesomeness
  160. cp -R dist/landing/index.html ${APACHE_DATA_PATH}/index.html
  161. cp -R dist/landing/bg.gif ${APACHE_DATA_PATH}/
  162. # start reqired services
  163. $DIALOG --infobox "Starting web server.." 4 60
  164. ${APACHE_INIT_SCRIPT} start 2>> ${INSTALLER_LOG}
  165. $DIALOG --infobox "Starting database server.." 4 60
  166. ${MYSQL_INIT_SCRIPT} start 2>> ${INSTALLER_LOG}
  167. $DIALOG --infobox "Starting caching server.." 4 60
  168. ${CACHE_INIT_SCRIPT} start 2>> ${INSTALLER_LOG}
  169. #Setting MySQL root password
  170. mysqladmin -u root password ${MYSQL_PASSWD} 2>> ${INSTALLER_LOG}
  171. # updating passwords and login in mysql.ini
  172. perl -e "s/mylogin/root/g" -pi ./config/mysql.ini
  173. perl -e "s/newpassword/${MYSQL_PASSWD}/g" -pi ./config/mysql.ini
  174. # creating wr database
  175. $DIALOG --infobox "Creating initial WolfRecorder DB" 4 60
  176. cat dist/dumps/wolfrecorder.sql | /usr/local/bin/mysql -u root --password=${MYSQL_PASSWD} 2>> ${INSTALLER_LOG}
  177. # creation default storage
  178. $DIALOG --infobox "Creating default storage" 4 60
  179. cat dist/dumps/defaultstorage.sql | /usr/local/bin/mysql -u root -p wr --password=${MYSQL_PASSWD} 2>> ${INSTALLER_LOG}
  180. mkdir /wrstorage
  181. chmod 777 /wrstorage
  182. # first install flag setup for the future
  183. touch ./exports/FIRST_INSTALL
  184. chmod 777 ./exports/FIRST_INSTALL
  185. # unpacking wrapi preset
  186. cp -R dist/wrap/wrapi /bin/
  187. chmod a+x /bin/wrapi
  188. $DIALOG --infobox "remote API wrapper installed" 4 60
  189. # updating sudoers
  190. echo "User_Alias WOLFRECORDER = www" >> /usr/local/etc/sudoers
  191. echo "WOLFRECORDER ALL = NOPASSWD: ALL" >> /usr/local/etc/sudoers
  192. #disabling mysql>=5.6 strict trans tables in various config locations
  193. if [ -f /usr/local/my.cnf ];
  194. then
  195. perl -e "s/,STRICT_TRANS_TABLES//g" -pi /usr/local/my.cnf
  196. $DIALOG --infobox "Disabling MySQL STRICT_TRANS_TABLES in /usr/local/my.cnf done" 4 60
  197. else
  198. $DIALOG --infobox "Looks like no MySQL STRICT_TRANS_TABLES disable required in /usr/local/my.cnf" 4 60
  199. fi
  200. if [ -f /usr/local/etc/my.cnf ];
  201. then
  202. perl -e "s/,STRICT_TRANS_TABLES//g" -pi /usr/local/etc/my.cnf
  203. $DIALOG --infobox "Disabling MySQL STRICT_TRANS_TABLES in /usr/local/etc/my.cnf done" 4 60
  204. else
  205. $DIALOG --infobox "Looks like no MySQL STRICT_TRANS_TABLES disable required in /usr/local/etc/my.cnf" 4 60
  206. fi
  207. if [ -f /usr/local/etc/mysql/my.cnf ];
  208. then
  209. perl -e "s/,STRICT_TRANS_TABLES//g" -pi /usr/local/etc/mysql/my.cnf
  210. $DIALOG --infobox "Disabling MySQL STRICT_TRANS_TABLES in /usr/local/etc/mysql/my.cnf done" 4 60
  211. else
  212. $DIALOG --infobox "Looks like no MySQL STRICT_TRANS_TABLES disable required in /usr/local/etc/mysql/my.cnf" 4 60
  213. fi
  214. #initial crontab configuration
  215. cd ${APACHE_DATA_PATH}${WR_WEB_DIR}
  216. if [ -f ./dist/crontab/crontab.preconf ];
  217. then
  218. #generating new WolfRecorder serial or using predefined
  219. case $PASSW_MODE in
  220. NEW)
  221. /usr/local/bin/curl -o /dev/null "http://127.0.0.1/${WR_WEB_DIR}?module=remoteapi&action=identify&param=save" 2>> ${INSTALLER_LOG}
  222. NEW_WRSERIAL=`cat ./exports/wrserial`
  223. $DIALOG --infobox "New WolfRecorder serial generated: ${NEW_WRSERIAL}" 4 60
  224. ;;
  225. MIG)
  226. NEW_WRSERIAL=${WRSERIAL}
  227. $DIALOG --infobox "Using WolfRecorder serial: ${NEW_WRSERIAL}" 4 60
  228. ;;
  229. esac
  230. #loading default crontab preset
  231. crontab ./dist/crontab/crontab.preconf
  232. $DIALOG --infobox "Installing default crontab preset" 4 60
  233. # updating serial in wrapi wrapper
  234. perl -e "s/WR00000000000000000000000000000000/${NEW_WRSERIAL}/g" -pi /bin/wrapi
  235. $DIALOG --infobox "New serial installed into wrapi wrapper" 4 60
  236. else
  237. echo "Looks like this WolfRecorder release is not supporting automatic crontab configuration"
  238. fi
  239. # Setting up autoupdate sctipt
  240. cp -R ./dist/presets/freebsd/autowrupdate.sh /bin/
  241. chmod a+x /bin/autowrupdate.sh
  242. #cleaning up installer work directory
  243. cd /
  244. rm -fr ${INSTALLER_WORK_DIR}
  245. $DIALOG --title "WolfRecorder installation has been completed" --msgbox "Now you can access your web-interface by address http://server_ip/${WR_WEB_DIR} with login and password: admin/demo. Please reboot your server to check correct startup of all services" 15 50
  246. # Finishing installation
  247. ;;
  248. #cancel installstion
  249. 1)
  250. echo "Installation has been aborted"
  251. exit
  252. ;;
  253. esac
  254. #
  255. # End of FreeBSD setup
  256. #
  257. ;;
  258. Linux)
  259. # START of Linux installation scripts here
  260. DIALOG="dialog"
  261. INSTALLER_LOG="/var/log/wrinstaller.log"
  262. #initial repos update
  263. echo "Preparing to installation.."
  264. apt update >> ${INSTALLER_LOG} 2>&1
  265. apt -y upgrade >> ${INSTALLER_LOG} 2>&1
  266. #installation of basic software required for installer
  267. echo "Installing basic software required for Debianstaller.."
  268. apt install -y dialog >> ${INSTALLER_LOG} 2>&1
  269. apt install -y net-tools >> ${INSTALLER_LOG} 2>&1
  270. apt install -y gnupg2 >> ${INSTALLER_LOG} 2>&1
  271. $DIALOG --menu "Choose your Linux distribution" 16 50 8 \
  272. DEB121 "Debian 12.1 Bookworm"\
  273. 2> /tmp/wrarch
  274. clear
  275. ARCH=`cat /tmp/wrarch`
  276. case $ARCH in
  277. DEB121)
  278. #some remote paths here
  279. FETCH="/usr/bin/wget"
  280. APACHE_VERSION="apache24"
  281. APACHE_DATA_PATH="/var/www/html/"
  282. APACHE_CONFIG_DIR="/etc/apache2/"
  283. APACHE_INIT_SCRIPT="/usr/sbin/service apache2"
  284. APACHE_CONFIG_PRESET_NAME="debi12_apache2.conf"
  285. APACHE_CONFIG_NAME="apache2.conf"
  286. PHP_CONFIG_PRESET="php82.ini"
  287. MYSQL_INIT_SCRIPT="/usr/sbin/service mariadb"
  288. CACHE_INIT_SCRIPT="/usr/sbin/service memcached"
  289. WR_WEB_DIR="wr/"
  290. INSTALLER_WORK_DIR="/usr/local/wrinstaller/"
  291. DL_WR_URL="http://wolfrecorder.com/"
  292. DL_WR_NAME="wr.tgz"
  293. # config interface section
  294. clear
  295. $DIALOG --title "WolfRecorder NVR installation" --msgbox "This wizard helps you to install WolfRecorder of the latest stable version to CLEAN (!) Linux distribution" 10 50
  296. clear
  297. #new or migration installation
  298. clear
  299. $DIALOG --menu "Type of WolfRecorder installation" 10 75 8 \
  300. NEW "This is new WolfRecorder installation"\
  301. MIG "Migrating existing WolfRecorder setup from another host"\
  302. 2> /tmp/insttype
  303. clear
  304. #some passwords generation or manual input
  305. PASSW_MODE=`cat /tmp/insttype`
  306. case $PASSW_MODE in
  307. NEW)
  308. #generating mysql password
  309. GEN_MYS_PASS=`dd if=/dev/urandom count=128 bs=1 2>&1 | md5sum | cut -b-8`
  310. echo "mys"${GEN_MYS_PASS} > /tmp/wrmypass
  311. ;;
  312. MIG)
  313. #request previous MySQL password
  314. clear
  315. $DIALOG --title "MySQL root password" --inputbox "Enter your previous installation MySQL root password" 8 60 2> /tmp/wrmypass
  316. clear
  317. $DIALOG --title "WolfRecorder serial" --inputbox "Enter your previous installation WolfRecorder serial number" 8 60 2> /tmp/wrsrl
  318. ;;
  319. esac
  320. #setting some opts for future
  321. MYSQL_PASSWD=`cat /tmp/wrmypass`
  322. case $PASSW_MODE in
  323. NEW)
  324. WRSERIAL="AUTO"
  325. ;;
  326. MIG)
  327. WRSERIAL=`cat /tmp/wrsrl`
  328. ;;
  329. esac
  330. # cleaning temp files
  331. rm -fr /tmp/wrarch
  332. rm -fr /tmp/wrmypass
  333. rm -fr /tmp/wrsrl
  334. rm -fr /tmp/insttype
  335. #last chance to exit
  336. $DIALOG --title "Check settings" --yesno "Are all of these settings correct? \n \n MySQL password: ${MYSQL_PASSWD} \n System: ${ARCH} \n WolfRecorder serial: ${WRSERIAL}\n" 10 60
  337. AGREE=$?
  338. clear
  339. # confirm installation
  340. case $AGREE in
  341. 0)
  342. echo "Everything is okay! Installation is starting."
  343. # preparing for installation
  344. mkdir ${INSTALLER_WORK_DIR}
  345. cd ${INSTALLER_WORK_DIR}
  346. # install binary packages from repos
  347. $DIALOG --infobox "Software installation is in progress. This takes a while." 4 70
  348. #MariaDB setup
  349. apt install -y software-properties-common dirmngr >> ${INSTALLER_LOG} 2>&1
  350. $DIALOG --infobox "Installing MariaDB" 4 60
  351. $DIALOG --infobox "Installing MariaDB." 4 60
  352. $DIALOG --infobox "Installing MariaDB.." 4 60
  353. $DIALOG --infobox "Installing MariaDB..." 4 60
  354. apt install -y mariadb-server >> ${INSTALLER_LOG} 2>&1
  355. $DIALOG --infobox "Installing MariaDB...." 4 60
  356. apt install -y mariadb-client >> ${INSTALLER_LOG} 2>&1
  357. $DIALOG --infobox "Installing MariaDB....." 4 60
  358. apt install -y libmariadb-dev >> ${INSTALLER_LOG} 2>&1
  359. $DIALOG --infobox "Installing MariaDB......" 4 60
  360. apt install -y default-libmysqlclient-dev >> ${INSTALLER_LOG} 2>&1
  361. $DIALOG --infobox "MariaDB installed" 4 60
  362. mariadb --version >> ${INSTALLER_LOG} 2>&1
  363. systemctl start mariadb >> ${INSTALLER_LOG} 2>&1
  364. systemctl enable mariadb >> ${INSTALLER_LOG} 2>&1
  365. $DIALOG --infobox "MariaDB startup enabled" 4 60
  366. $DIALOG --infobox "Installing some required software" 4 60
  367. apt install -y expat >> ${INSTALLER_LOG} 2>&1
  368. apt install -y libexpat1-dev >> ${INSTALLER_LOG} 2>&1
  369. apt install -y sudo >> ${INSTALLER_LOG} 2>&1
  370. apt install -y curl >> ${INSTALLER_LOG} 2>&1
  371. $DIALOG --infobox "Installing Apache server" 4 60
  372. apt install -y apache2 >> ${INSTALLER_LOG} 2>&1
  373. apt install -y libapache2-mod-php8.2 >> ${INSTALLER_LOG} 2>&1
  374. $DIALOG --infobox "Installing misc software" 4 60
  375. apt install -y build-essential >> ${INSTALLER_LOG} 2>&1
  376. apt install -y libxmlrpc-c++8-dev >> ${INSTALLER_LOG} 2>&1
  377. apt install -y ipset >> ${INSTALLER_LOG} 2>&1
  378. $DIALOG --infobox "Installing memory caching servers" 4 60
  379. apt install -y memcached >> ${INSTALLER_LOG} 2>&1
  380. apt install -y redis >> ${INSTALLER_LOG} 2>&1
  381. $DIALOG --infobox "Installing PHP and required extensions" 4 60
  382. apt install -y php8.2-cli >> ${INSTALLER_LOG} 2>&1
  383. apt install -y php8.2-mysql >> ${INSTALLER_LOG} 2>&1
  384. apt install -y php8.2-mysqli >> ${INSTALLER_LOG} 2>&1
  385. apt install -y php8.2-mbstring >> ${INSTALLER_LOG} 2>&1
  386. apt install -y php8.2-bcmath >> ${INSTALLER_LOG} 2>&1
  387. apt install -y php8.2-curl >> ${INSTALLER_LOG} 2>&1
  388. apt install -y php8.2-gd >> ${INSTALLER_LOG} 2>&1
  389. apt install -y php8.2-snmp >> ${INSTALLER_LOG} 2>&1
  390. apt install -y php8.2-soap >> ${INSTALLER_LOG} 2>&1
  391. apt install -y php8.2-zip >> ${INSTALLER_LOG} 2>&1
  392. apt install -y php8.2-imap >> ${INSTALLER_LOG} 2>&1
  393. apt install -y php8.2-json >> ${INSTALLER_LOG} 2>&1
  394. apt install -y php8.2-tokenizer >> ${INSTALLER_LOG} 2>&1
  395. apt install -y php8.2-xml >> ${INSTALLER_LOG} 2>&1
  396. apt install -y php8.2-xmlreader >> ${INSTALLER_LOG} 2>&1
  397. apt install -y php8.2-xmlwriter >> ${INSTALLER_LOG} 2>&1
  398. apt install -y php8.2-simplexml >> ${INSTALLER_LOG} 2>&1
  399. apt install -y php8.2-sqlite3 >> ${INSTALLER_LOG} 2>&1
  400. apt install -y php8.2-sockets >> ${INSTALLER_LOG} 2>&1
  401. apt install -y php8.2-opcache >> ${INSTALLER_LOG} 2>&1
  402. apt install -y php8.2-json >> ${INSTALLER_LOG} 2>&1
  403. apt install -y php8.2-pdo >> ${INSTALLER_LOG} 2>&1
  404. apt install -y php8.2-pdo-sqlite >> ${INSTALLER_LOG} 2>&1
  405. apt install -y php8.2-phar >> ${INSTALLER_LOG} 2>&1
  406. apt install -y php8.2-posix >> ${INSTALLER_LOG} 2>&1
  407. apt install -y php8.2-memcached >> ${INSTALLER_LOG} 2>&1
  408. apt install -y php8.2-redis >> ${INSTALLER_LOG} 2>&1
  409. $DIALOG --infobox "Installing ffmpeg" 4 60
  410. apt install -y ffmpeg >> ${INSTALLER_LOG} 2>&1
  411. $DIALOG --infobox "Installing some optional software" 4 60
  412. apt install -y graphviz >> ${INSTALLER_LOG} 2>&1
  413. apt install -y vim-tiny >> ${INSTALLER_LOG} 2>&1
  414. apt install -y arping >> ${INSTALLER_LOG} 2>&1
  415. apt install -y elinks >> ${INSTALLER_LOG} 2>&1
  416. apt install -y mc >> ${INSTALLER_LOG} 2>&1
  417. apt install -y nano >> ${INSTALLER_LOG} 2>&1
  418. apt install -y nmap >> ${INSTALLER_LOG} 2>&1
  419. apt install -y mtr >> ${INSTALLER_LOG} 2>&1
  420. apt install -y expect >> ${INSTALLER_LOG} 2>&1
  421. apt install -y bwm-ng >> ${INSTALLER_LOG} 2>&1
  422. apt install -y git >> ${INSTALLER_LOG} 2>&1
  423. apt install -y netdiag >> ${INSTALLER_LOG} 2>&1
  424. apt install -y htop >> ${INSTALLER_LOG} 2>&1
  425. apt install -y rsyslog >> ${INSTALLER_LOG} 2>&1
  426. $DIALOG --infobox "Binary packages installation has been completed." 4 60
  427. ################################################
  428. # Downloading and unpacking WolfRecorder distro
  429. ################################################
  430. $DIALOG --infobox "WolfRecorder download, unpacking and installation is in progress." 4 60
  431. #back to installation directory
  432. cd ${INSTALLER_WORK_DIR}
  433. # downloading distro
  434. $FETCH ${DL_WR_URL}${DL_WR_NAME}
  435. #check is wolfrecorder distro download complete
  436. if [ -f ${DL_WR_NAME} ];
  437. then
  438. $DIALOG --infobox "WolfRecorder download has been completed." 4 60
  439. else
  440. echo "=== Error: WolfRecorder release is not available. Installation is aborted. ==="
  441. exit
  442. fi
  443. mkdir ${APACHE_DATA_PATH}${WR_WEB_DIR}
  444. cp -R ${DL_WR_NAME} ${APACHE_DATA_PATH}${WR_WEB_DIR}
  445. cd ${APACHE_DATA_PATH}${WR_WEB_DIR}
  446. tar zxvf ${DL_WR_NAME} >> ${INSTALLER_LOG} 2>&1
  447. chmod -R 777 content/ config/ exports/ howl/
  448. # setting up config presets
  449. cp -R dist/presets/debian121/${APACHE_CONFIG_PRESET_NAME} ${APACHE_CONFIG_DIR}${APACHE_CONFIG_NAME}
  450. cp -R dist/presets/debian121/${PHP_CONFIG_PRESET} /etc/php/8.2/apache2/php.ini
  451. cp -R dist/presets/debian121/000-default.conf ${APACHE_CONFIG_DIR}sites-enabled/000-default.conf
  452. # setting up default web awesomeness
  453. cp -R dist/landing/index.html ${APACHE_DATA_PATH}/index.html
  454. cp -R dist/landing/bg.gif ${APACHE_DATA_PATH}/
  455. # start reqired services
  456. $DIALOG --infobox "Starting web server.." 4 60
  457. ${APACHE_INIT_SCRIPT} start >> ${INSTALLER_LOG} 2>&1
  458. $DIALOG --infobox "Starting database server.." 4 60
  459. ${MYSQL_INIT_SCRIPT} start >> ${INSTALLER_LOG} 2>&1
  460. $DIALOG --infobox "Starting caching server.." 4 60
  461. ${CACHE_INIT_SCRIPT} start >> ${INSTALLER_LOG} 2>&1
  462. #Setting MySQL root password
  463. mysqladmin -u root password ${MYSQL_PASSWD} >> ${INSTALLER_LOG} 2>&1
  464. # updating passwords and login in mysql.ini
  465. perl -e "s/mylogin/root/g" -pi ./config/mysql.ini
  466. perl -e "s/newpassword/${MYSQL_PASSWD}/g" -pi ./config/mysql.ini
  467. # updating binary paths in binpaths.ini
  468. cp -R dist/presets/debian121/binpaths.ini ./config/binpaths.ini
  469. # creating wr database
  470. $DIALOG --infobox "Creating initial WolfRecorder DB" 4 60
  471. cat dist/dumps/wolfrecorder.sql | /usr/bin/mysql -u root --password=${MYSQL_PASSWD} >> ${INSTALLER_LOG} 2>&1
  472. # creation default storage
  473. $DIALOG --infobox "Creating default storage" 4 60
  474. cat dist/dumps/defaultstorage.sql | /usr/bin/mysql -u root -p wr --password=${MYSQL_PASSWD} >> ${INSTALLER_LOG} 2>&1
  475. mkdir /wrstorage
  476. chmod 777 /wrstorage
  477. # first install flag setup for the future
  478. touch ./exports/FIRST_INSTALL
  479. chmod 777 ./exports/FIRST_INSTALL
  480. # unpacking wrapi preset
  481. cp -R dist/wrap/deb121_wrapi /bin/wrapi
  482. chmod a+x /bin/wrapi
  483. $DIALOG --infobox "remote API wrapper installed" 4 60
  484. # updating sudoers
  485. echo "User_Alias WOLFRECORDER = www-data" >> /etc/sudoers.d/wolfrecorder
  486. echo "WOLFRECORDER ALL = NOPASSWD: ALL" >> /etc/sudoers.d/wolfrecorder
  487. #enabling required apache modules
  488. /usr/sbin/a2enmod headers
  489. /usr/sbin/a2enmod expires
  490. #restarting apache
  491. $DIALOG --infobox "Restarting web server.." 4 60
  492. ${APACHE_INIT_SCRIPT} restart >> ${INSTALLER_LOG} 2>&1
  493. #initial crontab configuration
  494. cd ${APACHE_DATA_PATH}${WR_WEB_DIR}
  495. if [ -f ./dist/crontab/crontab.preconf ];
  496. then
  497. #generating new WolfRecorder serial or using predefined
  498. case $PASSW_MODE in
  499. NEW)
  500. /usr/bin/curl -o /dev/null "http://127.0.0.1/${WR_WEB_DIR}?module=remoteapi&action=identify&param=save" >> ${INSTALLER_LOG} 2>&1
  501. #waiting saving data
  502. sleep 3
  503. NEW_WRSERIAL=`cat ./exports/wrserial`
  504. $DIALOG --infobox "New WolfRecorder serial generated: ${NEW_WRSERIAL}" 4 60
  505. ;;
  506. MIG)
  507. NEW_WRSERIAL=${WRSERIAL}
  508. $DIALOG --infobox "Using WolfRecorder serial: ${NEW_WRSERIAL}" 4 60
  509. ;;
  510. esac
  511. if [ -n "$NEW_WRSERIAL" ];
  512. then
  513. echo "OK: new WolfRecorder serial ${NEW_WRSERIAL}" >> ${INSTALLER_LOG} 2>&1
  514. else
  515. $DIALOG --infobox "No new WolfRecorder serial generated: ${NEW_WRSERIAL}" 4 60
  516. echo "Installation failed and aborted. Empty WolfRecorder serial. Retry your attempt."
  517. echo "FATAL: empty new WolfRecorder serial" >> ${INSTALLER_LOG} 2>&1
  518. exit
  519. fi
  520. #loading default crontab preset
  521. crontab ./dist/crontab/crontab.preconf
  522. $DIALOG --infobox "Installing default crontab preset" 4 60
  523. # updating serial in wrapi wrapper
  524. perl -e "s/WR00000000000000000000000000000000/${NEW_WRSERIAL}/g" -pi /bin/wrapi
  525. $DIALOG --infobox "New serial installed into wrapi wrapper" 4 60
  526. else
  527. echo "Looks like this WolfRecorder release is not supporting automatic crontab configuration"
  528. fi
  529. # Setting up autoupdate sctipt
  530. cp -R ./dist/presets/debian121/autowrupdate.sh /bin/
  531. chmod a+x /bin/autowrupdate.sh
  532. #cleaning up installer work directory
  533. cd /
  534. rm -fr ${INSTALLER_WORK_DIR}
  535. $DIALOG --title "WolfRecorder installation has been completed" --msgbox "Now you can access your web-interface by address http://server_ip/${WR_WEB_DIR} with login and password: admin/demo. Please reboot your server to check correct startup of all services" 15 50
  536. # Finishing installation
  537. ;;
  538. #cancel installstion
  539. 1)
  540. echo "Installation has been aborted"
  541. exit
  542. ;;
  543. esac
  544. #
  545. # End of Debian 12.1 script here
  546. #
  547. ;;
  548. esac
  549. # END
  550. ;;
  551. esac