123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698 |
- #!/bin/sh
- #
- # Acta, non verba
- #
- OS_NAME=`uname`
- case $OS_NAME in
- FreeBSD)
- DIALOG=${DIALOG=dialog}
- FETCH="/usr/bin/fetch"
- APACHE_VERSION="apache24"
- APACHE_DATA_PATH="/usr/local/www/apache24/data/"
- APACHE_CONFIG_DIR="/usr/local/etc/apache24/"
- APACHE_INIT_SCRIPT="/usr/local/etc/rc.d/apache24"
- APACHE_CONFIG_PRESET_NAME="httpd24f8.conf"
- APACHE_CONFIG_NAME="httpd.conf"
- PHP_CONFIG_PRESET="php8.ini"
- MYSQL_INIT_SCRIPT="/usr/local/etc/rc.d/mysql-server"
- CACHE_INIT_SCRIPT="/usr/local/etc/rc.d/memcached"
- WR_WEB_DIR="wr/"
- INSTALLER_WORK_DIR="/usr/local/wrinstaller/"
- INSTALLER_LOG="/var/log/wrinstaller.log"
- #some remote paths here
- DL_PACKAGES_URL="http://wolfrecorder.com/packages/"
- DL_PACKAGES_EXT=".tar.gz"
- DL_WR_URL="http://wolfrecorder.com/"
- DL_WR_NAME="wr.tgz"
- set PATH=/usr/local/bin:/usr/local/sbin:$PATH
- # config interface section
- clear
- $DIALOG --title "WolfRecorder NVR installation" --msgbox "This wizard helps you to install WolfRecorder of the latest stable version to CLEAN (!) FreeBSD distribution" 10 50
- clear
- #new or migration installation
- clear
- $DIALOG --menu "Type of WolfRecorder installation" 10 75 8 \
- NEW "This is new WolfRecorder installation"\
- MIG "Migrating existing WolfRecorder setup from another host"\
- 2> /tmp/insttype
- clear
- $DIALOG --menu "Choose FreeBSD version and architecture" 16 50 8 \
- 142_6L "FreeBSD 14.2 amd64"\
- 141_6K "FreeBSD 14.1 amd64"\
- 140_6K "FreeBSD 14.0 amd64"\
- 134_6K "FreeBSD 13.4 amd64"\
- 133_6K "FreeBSD 13.3 amd64"\
- 2> /tmp/wrarch
- clear
- #some passwords generation or manual input
- PASSW_MODE=`cat /tmp/insttype`
- case $PASSW_MODE in
- NEW)
- #generating mysql password
- GEN_MYS_PASS=`dd if=/dev/urandom count=128 bs=1 2>&1 | md5 | cut -b-8`
- echo "mys"${GEN_MYS_PASS} > /tmp/wrmypass
- ;;
- MIG)
- #request previous MySQL password
- clear
- $DIALOG --title "MySQL root password" --inputbox "Enter your previous installation MySQL root password" 8 60 2> /tmp/wrmypass
- clear
- $DIALOG --title "WolfRecorder serial" --inputbox "Enter your previous installation WolfRecorder serial number" 8 60 2> /tmp/wrsrl
- ;;
- esac
- #setting some opts for future
- MYSQL_PASSWD=`cat /tmp/wrmypass`
- ARCH=`cat /tmp/wrarch`
- case $PASSW_MODE in
- NEW)
- WRSERIAL="AUTO"
- ;;
- MIG)
- WRSERIAL=`cat /tmp/wrsrl`
- ;;
- esac
- # generating snmp community string
- GEN_SNM_COMM=`dd if=/dev/urandom count=128 bs=1 2>&1 | md5 | cut -b-8`
- echo "snm"${GEN_SNM_COMM} > /tmp/wrsnmpcomm
- SNMP_COMMUNITY=`cat /tmp/wrsnmpcomm`
- # cleaning temp files
- rm -fr /tmp/wrarch
- rm -fr /tmp/wrmypass
- rm -fr /tmp/wrsrl
- rm -fr /tmp/insttype
- rm -fr /tmp/wrsnmpcomm
- #last chance to exit
- $DIALOG --title "Check settings" --yesno "Are all of these settings correct? \n \n MySQL password: ${MYSQL_PASSWD} \n SNMP RO community: ${SNMP_COMMUNITY} \n System: ${ARCH} \n WolfRecorder serial: ${WRSERIAL}\n" 10 60
- AGREE=$?
- clear
- # confirm installation
- case $AGREE in
- 0)
- echo "Everything is okay! Installation is starting."
- # preparing for installation
- mkdir ${INSTALLER_WORK_DIR}
- cd ${INSTALLER_WORK_DIR}
- #######################################
- # Platform specific issues handling #
- #######################################
- case $ARCH in
- 140_6K)
- # 14.0K contains PHP 8.3 binaries
- #APACHE_CONFIG_PRESET_NAME="httpd24f8.conf"
- #PHP_CONFIG_PRESET="php8.ini"
- ;;
- esac
- #botstrapping pkg ng
- pkg info
- #check is FreeBSD installation clean
- PKG_COUNT=`/usr/sbin/pkg info | /usr/bin/wc -l`
- if [ $PKG_COUNT -ge 2 ]
- then
- echo "WRinstaller supports setup only for clean FreeBSD distribution. Installation is aborted."
- exit
- fi
- # install prebuilded binary packages
- $DIALOG --infobox "Downloading binary packages." 4 60
- $FETCH ${DL_PACKAGES_URL}${ARCH}${DL_PACKAGES_EXT}
- #check is binary packages download has beed completed
- if [ -f ${ARCH}${DL_PACKAGES_EXT} ];
- then
- $DIALOG --infobox "Binary packages download has been completed." 4 60
- else
- echo "=== Error: binary packages are not available. Installation is aborted. ==="
- exit
- fi
- # unpacking and installing packages
- $DIALOG --infobox "Unpacking binary packages." 4 60
- tar zxvf ${ARCH}${DL_PACKAGES_EXT} 2>> ${INSTALLER_LOG}
- cd ${ARCH}
- $DIALOG --infobox "Software installation is in progress. This takes a while." 4 70
- ls -1 | xargs -n 1 pkg add >> ${INSTALLER_LOG}
- $DIALOG --infobox "Binary packages installation has been completed." 4 60
- ################################################
- # Downloading and unpacking WolfRecorder distro
- ################################################
- $DIALOG --infobox "WolfRecorder download, unpacking and installation is in progress." 4 60
- #back to installation directory
- cd ${INSTALLER_WORK_DIR}
- # downloading distro
- $FETCH ${DL_WR_URL}${DL_WR_NAME}
- #check is wolfrecorder distro download complete
- if [ -f ${DL_WR_NAME} ];
- then
- $DIALOG --infobox "WolfRecorder download has been completed." 4 60
- else
- echo "=== Error: WolfRecorder release is not available. Installation is aborted. ==="
- exit
- fi
- mkdir ${APACHE_DATA_PATH}${WR_WEB_DIR}
- cp -R ${DL_WR_NAME} ${APACHE_DATA_PATH}${WR_WEB_DIR}
- cd ${APACHE_DATA_PATH}${WR_WEB_DIR}
- tar zxvf ${DL_WR_NAME} 2>> ${INSTALLER_LOG}
- chmod -R 777 content/ config/ exports/ howl/
- # setting up config presets
- cp -R dist/presets/freebsd/${APACHE_CONFIG_PRESET_NAME} ${APACHE_CONFIG_DIR}${APACHE_CONFIG_NAME}
- cp -R dist/presets/freebsd/${PHP_CONFIG_PRESET} /usr/local/etc/php.ini
- cat dist/presets/freebsd/rc.preconf >> /etc/rc.conf
- cat dist/presets/freebsd/sysctl.preconf >> /etc/sysctl.conf
- cat dist/presets/freebsd/loader.preconf >> /boot/loader.conf
- cp -R dist/presets/freebsd/firewall.conf /etc/firewall.conf
- chmod a+x /etc/firewall.conf
- cp -R dist/presets/freebsd/snmpd.preconf /usr/local/etc/snmpd.conf
- # setting up default web awesomeness
- cp -R dist/landing/index.html ${APACHE_DATA_PATH}/index.html
- cp -R dist/landing/bg.gif ${APACHE_DATA_PATH}/
- # database specific issues handling
- case $ARCH in
- 133_6K)
- # MySQL 8.0 requires custom config
- cp -R dist/presets/freebsd/80_my.cnf /usr/local/etc/mysql/my.cnf
- $DIALOG --infobox "MySQL 8.0 config replaced" 4 60
- ;;
- 134_6K)
- # MySQL 8.0 requires custom config
- cp -R dist/presets/freebsd/80_my.cnf /usr/local/etc/mysql/my.cnf
- $DIALOG --infobox "MySQL 8.0 config replaced" 4 60
- ;;
- 140_6K)
- # MySQL 8.0 requires custom config
- cp -R dist/presets/freebsd/80_my.cnf /usr/local/etc/mysql/my.cnf
- $DIALOG --infobox "MySQL 8.0 config replaced" 4 60
- ;;
- 141_6K)
- # MySQL 8.0 requires custom config
- cp -R dist/presets/freebsd/80_my.cnf /usr/local/etc/mysql/my.cnf
- $DIALOG --infobox "MySQL 8.0 config replaced" 4 60
- ;;
- 142_6L)
- # MySQL 8.0 requires custom config
- cp -R dist/presets/freebsd/80_my.cnf /usr/local/etc/mysql/my.cnf
- $DIALOG --infobox "MySQL 8.0 config replaced" 4 60
- ;;
- esac
- # start reqired services
- $DIALOG --infobox "Starting web server.." 4 60
- ${APACHE_INIT_SCRIPT} start 2>> ${INSTALLER_LOG}
- $DIALOG --infobox "Starting database server.." 4 60
- ${MYSQL_INIT_SCRIPT} start 2>> ${INSTALLER_LOG}
- $DIALOG --infobox "Starting caching server.." 4 60
- ${CACHE_INIT_SCRIPT} start 2>> ${INSTALLER_LOG}
- #Setting MySQL root password
- mysqladmin -u root password ${MYSQL_PASSWD} 2>> ${INSTALLER_LOG}
- # updating passwords and login in mysql.ini
- perl -e "s/mylogin/root/g" -pi ./config/mysql.ini
- perl -e "s/newpassword/${MYSQL_PASSWD}/g" -pi ./config/mysql.ini
- # creating wr database
- $DIALOG --infobox "Creating initial WolfRecorder DB" 4 60
- cat dist/dumps/wolfrecorder.sql | /usr/local/bin/mysql -u root --password=${MYSQL_PASSWD} 2>> ${INSTALLER_LOG}
- # creation default storage
- $DIALOG --infobox "Creating default storage" 4 60
- cat dist/dumps/defaultstorage.sql | /usr/local/bin/mysql -u root -p wr --password=${MYSQL_PASSWD} 2>> ${INSTALLER_LOG}
- mkdir /wrstorage
- chmod 777 /wrstorage
- # first install flag setup for the future
- touch ./exports/FIRST_INSTALL
- chmod 777 ./exports/FIRST_INSTALL
- # unpacking wrapi preset
- cp -R dist/wrap/wrapi /bin/
- chmod a+x /bin/wrapi
- $DIALOG --infobox "remote API wrapper installed" 4 60
- # updating sudoers
- echo "User_Alias WOLFRECORDER = www" >> /usr/local/etc/sudoers
- echo "WOLFRECORDER ALL = NOPASSWD: ALL" >> /usr/local/etc/sudoers
- #disabling mysql>=5.6 strict trans tables in various config locations
- if [ -f /usr/local/my.cnf ];
- then
- perl -e "s/,STRICT_TRANS_TABLES//g" -pi /usr/local/my.cnf
- $DIALOG --infobox "Disabling MySQL STRICT_TRANS_TABLES in /usr/local/my.cnf done" 4 60
- else
- $DIALOG --infobox "Looks like no MySQL STRICT_TRANS_TABLES disable required in /usr/local/my.cnf" 4 60
- fi
- if [ -f /usr/local/etc/my.cnf ];
- then
- perl -e "s/,STRICT_TRANS_TABLES//g" -pi /usr/local/etc/my.cnf
- $DIALOG --infobox "Disabling MySQL STRICT_TRANS_TABLES in /usr/local/etc/my.cnf done" 4 60
- else
- $DIALOG --infobox "Looks like no MySQL STRICT_TRANS_TABLES disable required in /usr/local/etc/my.cnf" 4 60
- fi
- if [ -f /usr/local/etc/mysql/my.cnf ];
- then
- perl -e "s/,STRICT_TRANS_TABLES//g" -pi /usr/local/etc/mysql/my.cnf
- $DIALOG --infobox "Disabling MySQL STRICT_TRANS_TABLES in /usr/local/etc/mysql/my.cnf done" 4 60
- else
- $DIALOG --infobox "Looks like no MySQL STRICT_TRANS_TABLES disable required in /usr/local/etc/mysql/my.cnf" 4 60
- fi
- #initial crontab configuration
- cd ${APACHE_DATA_PATH}${WR_WEB_DIR}
- if [ -f ./dist/crontab/crontab.preconf ];
- then
- #generating new WolfRecorder serial or using predefined
- case $PASSW_MODE in
- NEW)
- /usr/local/bin/curl -o /dev/null "http://127.0.0.1/${WR_WEB_DIR}?module=remoteapi&action=identify¶m=save" 2>> ${INSTALLER_LOG}
- NEW_WRSERIAL=`cat ./exports/wrserial`
- $DIALOG --infobox "New WolfRecorder serial generated: ${NEW_WRSERIAL}" 4 60
- ;;
- MIG)
- NEW_WRSERIAL=${WRSERIAL}
- $DIALOG --infobox "Using WolfRecorder serial: ${NEW_WRSERIAL}" 4 60
- ;;
- esac
- #loading default crontab preset
- crontab ./dist/crontab/crontab.preconf
- $DIALOG --infobox "Installing default crontab preset" 4 60
- # updating serial in wrapi wrapper
- perl -e "s/WR00000000000000000000000000000000/${NEW_WRSERIAL}/g" -pi /bin/wrapi
- $DIALOG --infobox "New serial installed into wrapi wrapper" 4 60
- else
- echo "Looks like this WolfRecorder release is not supporting automatic crontab configuration"
- fi
- # Setting up autoupdate sctipt
- cp -R ./dist/presets/freebsd/autowrupdate.sh /bin/
- chmod a+x /bin/autowrupdate.sh
- # Setting snmpd read only community string
- perl -e "s/SNMPCOMMTPL/${SNMP_COMMUNITY}/g" -pi /usr/local/etc/snmpd.conf
- $DIALOG --infobox "SNMP read only community set: ${SNMP_COMMUNITY}" 4 60
- #cleaning up installer work directory
- cd /
- rm -fr ${INSTALLER_WORK_DIR}
- $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
- # Finishing installation
- ;;
- #cancel installstion
- 1)
- echo "Installation has been aborted"
- exit
- ;;
- esac
- #
- # End of FreeBSD setup
- #
- ;;
- Linux)
- # START of Linux installation scripts here
- DIALOG="dialog"
- INSTALLER_LOG="/var/log/wrinstaller.log"
- #initial repos update
- echo "Preparing to installation.."
- apt update >> ${INSTALLER_LOG} 2>&1
- apt -y upgrade >> ${INSTALLER_LOG} 2>&1
- #installation of basic software required for installer
- echo "Installing basic software required for Debianstaller.."
- apt install -y dialog >> ${INSTALLER_LOG} 2>&1
- apt install -y net-tools >> ${INSTALLER_LOG} 2>&1
- apt install -y gnupg2 >> ${INSTALLER_LOG} 2>&1
- $DIALOG --menu "Choose your Linux distribution" 16 50 8 \
- DEB126 "Debian 12.6 Bookworm"\
- 2> /tmp/wrarch
- clear
- ARCH=`cat /tmp/wrarch`
- case $ARCH in
- DEB126)
- #some remote paths here
- FETCH="/usr/bin/wget"
- APACHE_VERSION="apache24"
- APACHE_DATA_PATH="/var/www/html/"
- APACHE_CONFIG_DIR="/etc/apache2/"
- APACHE_INIT_SCRIPT="/usr/sbin/service apache2"
- APACHE_CONFIG_PRESET_NAME="debi12_apache2.conf"
- APACHE_CONFIG_NAME="apache2.conf"
- PHP_CONFIG_PRESET="php82.ini"
- MYSQL_INIT_SCRIPT="/usr/sbin/service mariadb"
- CACHE_INIT_SCRIPT="/usr/sbin/service memcached"
- WR_WEB_DIR="wr/"
- INSTALLER_WORK_DIR="/usr/local/wrinstaller/"
- DL_WR_URL="http://wolfrecorder.com/"
- DL_WR_NAME="wr.tgz"
- # config interface section
- clear
- $DIALOG --title "WolfRecorder NVR installation" --msgbox "This wizard helps you to install WolfRecorder of the latest stable version to CLEAN (!) Linux distribution" 10 50
- clear
- #new or migration installation
- clear
- $DIALOG --menu "Type of WolfRecorder installation" 10 75 8 \
- NEW "This is new WolfRecorder installation"\
- MIG "Migrating existing WolfRecorder setup from another host"\
- 2> /tmp/insttype
- clear
- #some passwords generation or manual input
- PASSW_MODE=`cat /tmp/insttype`
- case $PASSW_MODE in
- NEW)
- #generating mysql password
- GEN_MYS_PASS=`dd if=/dev/urandom count=128 bs=1 2>&1 | md5sum | cut -b-8`
- echo "mys"${GEN_MYS_PASS} > /tmp/wrmypass
- ;;
- MIG)
- #request previous MySQL password
- clear
- $DIALOG --title "MySQL root password" --inputbox "Enter your previous installation MySQL root password" 8 60 2> /tmp/wrmypass
- clear
- $DIALOG --title "WolfRecorder serial" --inputbox "Enter your previous installation WolfRecorder serial number" 8 60 2> /tmp/wrsrl
- ;;
- esac
- #setting some opts for future
- MYSQL_PASSWD=`cat /tmp/wrmypass`
- case $PASSW_MODE in
- NEW)
- WRSERIAL="AUTO"
- ;;
- MIG)
- WRSERIAL=`cat /tmp/wrsrl`
- ;;
- esac
- # cleaning temp files
- rm -fr /tmp/wrarch
- rm -fr /tmp/wrmypass
- rm -fr /tmp/wrsrl
- rm -fr /tmp/insttype
- #last chance to exit
- $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
- AGREE=$?
- clear
- # confirm installation
- case $AGREE in
- 0)
- echo "Everything is okay! Installation is starting."
- # preparing for installation
- mkdir ${INSTALLER_WORK_DIR}
- cd ${INSTALLER_WORK_DIR}
- # install binary packages from repos
- $DIALOG --infobox "Software installation is in progress. This takes a while." 4 70
- #MariaDB setup
- apt install -y software-properties-common dirmngr >> ${INSTALLER_LOG} 2>&1
- $DIALOG --infobox "Installing MariaDB" 4 60
- $DIALOG --infobox "Installing MariaDB." 4 60
- $DIALOG --infobox "Installing MariaDB.." 4 60
- $DIALOG --infobox "Installing MariaDB..." 4 60
- apt install -y mariadb-server >> ${INSTALLER_LOG} 2>&1
- $DIALOG --infobox "Installing MariaDB...." 4 60
- apt install -y mariadb-client >> ${INSTALLER_LOG} 2>&1
- $DIALOG --infobox "Installing MariaDB....." 4 60
- apt install -y libmariadb-dev >> ${INSTALLER_LOG} 2>&1
- $DIALOG --infobox "Installing MariaDB......" 4 60
- apt install -y default-libmysqlclient-dev >> ${INSTALLER_LOG} 2>&1
- $DIALOG --infobox "MariaDB installed" 4 60
- mariadb --version >> ${INSTALLER_LOG} 2>&1
- systemctl start mariadb >> ${INSTALLER_LOG} 2>&1
- systemctl enable mariadb >> ${INSTALLER_LOG} 2>&1
- $DIALOG --infobox "MariaDB startup enabled" 4 60
- $DIALOG --infobox "Installing some required software" 4 60
- apt install -y expat >> ${INSTALLER_LOG} 2>&1
- apt install -y libexpat1-dev >> ${INSTALLER_LOG} 2>&1
- apt install -y sudo >> ${INSTALLER_LOG} 2>&1
- apt install -y curl >> ${INSTALLER_LOG} 2>&1
- $DIALOG --infobox "Installing Apache server" 4 60
- apt install -y apache2 >> ${INSTALLER_LOG} 2>&1
- apt install -y libapache2-mod-php8.2 >> ${INSTALLER_LOG} 2>&1
- $DIALOG --infobox "Installing misc software" 4 60
- apt install -y build-essential >> ${INSTALLER_LOG} 2>&1
- apt install -y libxmlrpc-c++8-dev >> ${INSTALLER_LOG} 2>&1
- apt install -y ipset >> ${INSTALLER_LOG} 2>&1
- $DIALOG --infobox "Installing memory caching servers" 4 60
- apt install -y memcached >> ${INSTALLER_LOG} 2>&1
- apt install -y redis >> ${INSTALLER_LOG} 2>&1
- $DIALOG --infobox "Installing PHP and required extensions" 4 60
- apt install -y php8.2-cli >> ${INSTALLER_LOG} 2>&1
- apt install -y php8.2-mysql >> ${INSTALLER_LOG} 2>&1
- apt install -y php8.2-mysqli >> ${INSTALLER_LOG} 2>&1
- apt install -y php8.2-mbstring >> ${INSTALLER_LOG} 2>&1
- apt install -y php8.2-bcmath >> ${INSTALLER_LOG} 2>&1
- apt install -y php8.2-curl >> ${INSTALLER_LOG} 2>&1
- apt install -y php8.2-gd >> ${INSTALLER_LOG} 2>&1
- apt install -y php8.2-snmp >> ${INSTALLER_LOG} 2>&1
- apt install -y php8.2-soap >> ${INSTALLER_LOG} 2>&1
- apt install -y php8.2-zip >> ${INSTALLER_LOG} 2>&1
- apt install -y php8.2-imap >> ${INSTALLER_LOG} 2>&1
- apt install -y php8.2-json >> ${INSTALLER_LOG} 2>&1
- apt install -y php8.2-tokenizer >> ${INSTALLER_LOG} 2>&1
- apt install -y php8.2-xml >> ${INSTALLER_LOG} 2>&1
- apt install -y php8.2-xmlreader >> ${INSTALLER_LOG} 2>&1
- apt install -y php8.2-xmlwriter >> ${INSTALLER_LOG} 2>&1
- apt install -y php8.2-simplexml >> ${INSTALLER_LOG} 2>&1
- apt install -y php8.2-sqlite3 >> ${INSTALLER_LOG} 2>&1
- apt install -y php8.2-sockets >> ${INSTALLER_LOG} 2>&1
- apt install -y php8.2-opcache >> ${INSTALLER_LOG} 2>&1
- apt install -y php8.2-json >> ${INSTALLER_LOG} 2>&1
- apt install -y php8.2-pdo >> ${INSTALLER_LOG} 2>&1
- apt install -y php8.2-pdo-sqlite >> ${INSTALLER_LOG} 2>&1
- apt install -y php8.2-phar >> ${INSTALLER_LOG} 2>&1
- apt install -y php8.2-posix >> ${INSTALLER_LOG} 2>&1
- apt install -y php8.2-memcached >> ${INSTALLER_LOG} 2>&1
- apt install -y php8.2-redis >> ${INSTALLER_LOG} 2>&1
- $DIALOG --infobox "Installing ffmpeg" 4 60
- apt install -y ffmpeg >> ${INSTALLER_LOG} 2>&1
- $DIALOG --infobox "Installing some optional software" 4 60
- apt install -y graphviz >> ${INSTALLER_LOG} 2>&1
- apt install -y vim-tiny >> ${INSTALLER_LOG} 2>&1
- apt install -y arping >> ${INSTALLER_LOG} 2>&1
- apt install -y elinks >> ${INSTALLER_LOG} 2>&1
- apt install -y mc >> ${INSTALLER_LOG} 2>&1
- apt install -y nano >> ${INSTALLER_LOG} 2>&1
- apt install -y nmap >> ${INSTALLER_LOG} 2>&1
- apt install -y mtr >> ${INSTALLER_LOG} 2>&1
- apt install -y expect >> ${INSTALLER_LOG} 2>&1
- apt install -y bwm-ng >> ${INSTALLER_LOG} 2>&1
- apt install -y git >> ${INSTALLER_LOG} 2>&1
- apt install -y netdiag >> ${INSTALLER_LOG} 2>&1
- apt install -y htop >> ${INSTALLER_LOG} 2>&1
- apt install -y rsyslog >> ${INSTALLER_LOG} 2>&1
- $DIALOG --infobox "Binary packages installation has been completed." 4 60
- ################################################
- # Downloading and unpacking WolfRecorder distro
- ################################################
- $DIALOG --infobox "WolfRecorder download, unpacking and installation is in progress." 4 60
- #back to installation directory
- cd ${INSTALLER_WORK_DIR}
- # downloading distro
- $FETCH ${DL_WR_URL}${DL_WR_NAME}
- #check is wolfrecorder distro download complete
- if [ -f ${DL_WR_NAME} ];
- then
- $DIALOG --infobox "WolfRecorder download has been completed." 4 60
- else
- echo "=== Error: WolfRecorder release is not available. Installation is aborted. ==="
- exit
- fi
- mkdir ${APACHE_DATA_PATH}${WR_WEB_DIR}
- cp -R ${DL_WR_NAME} ${APACHE_DATA_PATH}${WR_WEB_DIR}
- cd ${APACHE_DATA_PATH}${WR_WEB_DIR}
- tar zxvf ${DL_WR_NAME} >> ${INSTALLER_LOG} 2>&1
- chmod -R 777 content/ config/ exports/ howl/
- # setting up config presets
- cp -R dist/presets/debian121/${APACHE_CONFIG_PRESET_NAME} ${APACHE_CONFIG_DIR}${APACHE_CONFIG_NAME}
- cp -R dist/presets/debian121/${PHP_CONFIG_PRESET} /etc/php/8.2/apache2/php.ini
- cp -R dist/presets/debian121/000-default.conf ${APACHE_CONFIG_DIR}sites-enabled/000-default.conf
- # setting up default web awesomeness
- cp -R dist/landing/index.html ${APACHE_DATA_PATH}/index.html
- cp -R dist/landing/bg.gif ${APACHE_DATA_PATH}/
- # start reqired services
- $DIALOG --infobox "Starting web server.." 4 60
- ${APACHE_INIT_SCRIPT} start >> ${INSTALLER_LOG} 2>&1
- $DIALOG --infobox "Starting database server.." 4 60
- ${MYSQL_INIT_SCRIPT} start >> ${INSTALLER_LOG} 2>&1
- $DIALOG --infobox "Starting caching server.." 4 60
- ${CACHE_INIT_SCRIPT} start >> ${INSTALLER_LOG} 2>&1
- #Setting MySQL root password
- mysqladmin -u root password ${MYSQL_PASSWD} >> ${INSTALLER_LOG} 2>&1
- # updating passwords and login in mysql.ini
- perl -e "s/mylogin/root/g" -pi ./config/mysql.ini
- perl -e "s/newpassword/${MYSQL_PASSWD}/g" -pi ./config/mysql.ini
- # updating binary paths in binpaths.ini
- cp -R dist/presets/debian121/binpaths.ini ./config/binpaths.ini
- # creating wr database
- $DIALOG --infobox "Creating initial WolfRecorder DB" 4 60
- cat dist/dumps/wolfrecorder.sql | /usr/bin/mysql -u root --password=${MYSQL_PASSWD} >> ${INSTALLER_LOG} 2>&1
- # creation default storage
- $DIALOG --infobox "Creating default storage" 4 60
- cat dist/dumps/defaultstorage.sql | /usr/bin/mysql -u root -p wr --password=${MYSQL_PASSWD} >> ${INSTALLER_LOG} 2>&1
- mkdir /wrstorage
- chmod 777 /wrstorage
- # first install flag setup for the future
- touch ./exports/FIRST_INSTALL
- chmod 777 ./exports/FIRST_INSTALL
- # unpacking wrapi preset
- cp -R dist/wrap/deb121_wrapi /bin/wrapi
- chmod a+x /bin/wrapi
- $DIALOG --infobox "remote API wrapper installed" 4 60
- # updating sudoers
- echo "User_Alias WOLFRECORDER = www-data" >> /etc/sudoers.d/wolfrecorder
- echo "WOLFRECORDER ALL = NOPASSWD: ALL" >> /etc/sudoers.d/wolfrecorder
- #enabling required apache modules
- /usr/sbin/a2enmod headers
- /usr/sbin/a2enmod expires
- #restarting apache
- $DIALOG --infobox "Restarting web server.." 4 60
- ${APACHE_INIT_SCRIPT} restart >> ${INSTALLER_LOG} 2>&1
- #initial crontab configuration
- cd ${APACHE_DATA_PATH}${WR_WEB_DIR}
- if [ -f ./dist/crontab/crontab.preconf ];
- then
- #generating new WolfRecorder serial or using predefined
- case $PASSW_MODE in
- NEW)
- /usr/bin/curl -o /dev/null "http://127.0.0.1/${WR_WEB_DIR}?module=remoteapi&action=identify¶m=save" >> ${INSTALLER_LOG} 2>&1
- #waiting saving data
- sleep 3
- NEW_WRSERIAL=`cat ./exports/wrserial`
- $DIALOG --infobox "New WolfRecorder serial generated: ${NEW_WRSERIAL}" 4 60
- ;;
- MIG)
- NEW_WRSERIAL=${WRSERIAL}
- $DIALOG --infobox "Using WolfRecorder serial: ${NEW_WRSERIAL}" 4 60
- ;;
- esac
- if [ -n "$NEW_WRSERIAL" ];
- then
- echo "OK: new WolfRecorder serial ${NEW_WRSERIAL}" >> ${INSTALLER_LOG} 2>&1
- else
- $DIALOG --infobox "No new WolfRecorder serial generated: ${NEW_WRSERIAL}" 4 60
- echo "Installation failed and aborted. Empty WolfRecorder serial. Retry your attempt."
- echo "FATAL: empty new WolfRecorder serial" >> ${INSTALLER_LOG} 2>&1
- exit
- fi
- #loading default crontab preset
- crontab ./dist/crontab/crontab.preconf
- $DIALOG --infobox "Installing default crontab preset" 4 60
- # updating serial in wrapi wrapper
- perl -e "s/WR00000000000000000000000000000000/${NEW_WRSERIAL}/g" -pi /bin/wrapi
- $DIALOG --infobox "New serial installed into wrapi wrapper" 4 60
- else
- echo "Looks like this WolfRecorder release is not supporting automatic crontab configuration"
- fi
- # Setting up autoupdate sctipt
- cp -R ./dist/presets/debian121/autowrupdate.sh /bin/
- chmod a+x /bin/autowrupdate.sh
- #cleaning up installer work directory
- cd /
- rm -fr ${INSTALLER_WORK_DIR}
- $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
- # Finishing installation
- ;;
- #cancel installation
- 1)
- echo "Installation has been aborted"
- exit
- ;;
- esac
- #
- # End of Debian 12.6 script here
- #
- ;;
- esac
- # END
- ;;
- esac
|