#!/bin/sh ADName=adis85_web_astra-1.7.3.tar.gz ADPath=/root/adis_web SERVER_PATH=/home/server USER=adis GROUP=adis MNT=media echo ADIS_WEB setup. Continue [N/y] read yn if [ -z "$yn" ]; then yn="n" fi if [ $yn != "y" ] && [ $yn != "Y" ]; then echo "User break" exit 0 fi if test $(whoami) != "root" ; then conv_cp "You are not root" exit 1 fi grep "$USER:" /etc/passwd >/dev/null if [ $? -ne 0 ]; then echo "User $USER not found" exit 1 fi grep "$USERadmin:" /etc/passwd >/dev/null if [ $? -ne 0 ]; then echo "User $USER""admin not found" exit 1 fi if test -e ' /root/adis.info' ; then echo "File adis.info not found" exit 1 fi OS_VER_ID=`sed -n '/VERSION_ID/p' /etc/os-release | cut -d= -f2 | cut -d. -f1-2` OS_VER_ID=`echo -n $OS_VER_ID` mkdir -p $ADPath echo Copy big files. Wait..... tar xvfz $ADName -C $ADPath > /dev/null cd $ADPath #cp /etc/resolv.conf /etc/resolv.conf.old #echo nameserver 8.8.8.8 >> /etc/resolv.conf PHP_VERSION=`php -v|cut -d ' ' -f2| sed 's/ //g'|cut -d '.' -f1,2|head -n1` APACHE_USER=`ps aux | grep apache | grep -v 'grep' | cut -d' ' -f1 | sort | uniq | grep -v 'root'` export APACHE_USER; dpkg -i /root/adis_web/deb/mariadb-common_10.3.31-0+deb10u1_all.deb dpkg -i /root/adis_web/deb/galera-3_25.3.25-2_amd64.deb /root/adis_web/deb/libdbd-mysql-perl_4.050-2_amd64.deb /root/adis_web/deb/libhtml-template-perl_2.97-1_all.deb /root/adis_web/deb/libxml2-utils_2.9.4+dfsg1-7+deb10u1_amd64.deb /root/adis_web/deb/mariadb-client-10.3_10.3.31-0+deb10u1_amd64.deb /root/adis_web/deb/mariadb-client-core-10.3_10.3.31-0+deb10u1_amd64.deb /root/adis_web/deb/mariadb-server-10.3_10.3.31-0+deb10u1_amd64.deb /root/adis_web/deb/mariadb-server-core-10.3_10.3.31-0+deb10u1_amd64.deb dpkg -i --ignore-depends php7.3-common /root/adis_web/deb/php7.3-mysql_7.3.31-1~deb10u1+ci202204271757+astra3+b1_amd64.deb dpkg -i --ignore-depends php7.3-common /root/adis_web/deb/php7.3-soap_7.3.31-1~deb10u1+ci202204271757+astra3+b1_amd64.deb dpkg -i --ignore-depends php7.3-common /root/adis_web/deb/php7.3-zip_7.3.31-1~deb10u1+ci202204271757+astra3+b1_amd64.deb echo "Install HTTP Data" mkdir -p $SERVER_PATH/www/html usermod -a -G $APACHE_USER adisadmin php_so_dir='20180731' cp -Rf etc / echo "zend_extension = /usr/lib/php/$php_so_dir/ioncube_loader_lin_$PHP_VERSION.so" > /etc/php/$PHP_VERSION/mods-available/ioncube.ini ln -s /etc/php/$PHP_VERSION/mods-available/ioncube.ini /etc/php/$PHP_VERSION/apache2/conf.d/00-ioncube.ini ln -s /etc/php/$PHP_VERSION/mods-available/ioncube.ini /etc/php/$PHP_VERSION/cli/conf.d/00-ioncube.ini ln -s /etc/php/$PHP_VERSION/mods-available/dbase.ini /etc/php/$PHP_VERSION/apache2/conf.d/20-dbase.ini ln -s /etc/php/$PHP_VERSION/mods-available/dbase.ini /etc/php/$PHP_VERSION/cli/conf.d/20-dbase.ini chmod 644 /etc/php/$PHP_VERSION/mods-available/ioncube.ini chown root:root /etc/php/$PHP_VERSION/mods-available/ioncube.ini chmod 644 /etc/php/$PHP_VERSION/mods-available/dbase.ini chown root:root /etc/php/$PHP_VERSION/mods-available/dbase.ini echo "Copy data" cp -Rpf exestatus /home/adis/ mkdir -p /home/adis/exestatus/logs chown -R adisadmin:adis /home/adis/exestatus chmod 750 /home/adis/exestatus chmod 750 /home/adis/exestatus/logs chmod 750 /home/adis/exestatus/get_status_file chmod 750 /home/adis/exestatus/put_status_file cp -Rf usr / cp -Rpf server/www $SERVER_PATH/ mv /var/www/html /var/www/html.old ln -s /home/server/www/html /var/www/html mkdir -p /server/www/html/adis/smarty/configs mkdir -p /server/www/html/adis/smarty/cache mkdir -p /server/www/html/adis/smarty/templates_c chmod 774 /server/www/html/adis/smarty/configs chmod 774 /server/www/html/adis/smarty/cache chmod 774 /server/www/html/adis/smarty/templates_c mkdir -p /server/www/html/smarty/smarty/configs mkdir -p /server/www/html/smarty/smarty/cache mkdir -p /server/www/html/smarty/smarty/templates_c chmod 774 /server/www/html/smarty/smarty/configs chmod 774 /server/www/html/smarty/smarty/cache chmod 774 /server/www/html/smarty/smarty/templates_c mkdir -p /server/www/html/adis-rremd/smarty/configs mkdir -p /server/www/html/adis-rremd/smarty/cache mkdir -p /server/www/html/adis-rremd/smarty/templates_c chmod 774 /server/www/html/adis-rremd/smarty/configs chmod 774 /server/www/html/adis-rremd/smarty/cache chmod 774 /server/www/html/adis-rremd/smarty/templates_c mkdir -p /server/www/html/adis-map/smarty/configs mkdir -p /server/www/html/adis-map/smarty/cache mkdir -p /server/www/html/adis-map/smarty/templates_c chmod 774 /server/www/html/adis-map/smarty/configs chmod 774 /server/www/html/adis-map/smarty/cache chmod 774 /server/www/html/adis-map/smarty/templates_c mkdir -p /server/www/html/adis-print-service/smarty/configs mkdir -p /server/www/html/adis-print-service/smarty/cache mkdir -p /server/www/html/adis-print-service/smarty/templates_c chmod 774 /server/www/html/adis-print-service/smarty/configs chmod 774 /server/www/html/adis-print-service/smarty/cache chmod 774 /server/www/html/adis-print-service/smarty/templates_c mkdir -p /server/www/html/adis-v2/smarty/configs mkdir -p /server/www/html/adis-v2/smarty/cache mkdir -p /server/www/html/adis-v2/smarty/templates_c chmod 774 /server/www/html/adis-v2/smarty/configs chmod 774 /server/www/html/adis-v2/smarty/cache chmod 774 /server/www/html/adis-v2/smarty/templates_c mkdir -p /server/www/html/adis-navitel-service/smarty/configs mkdir -p /server/www/html/adis-navitel-service/smarty/cache mkdir -p /server/www/html/adis-navitel-service/smarty/templates_c chmod 774 /server/www/html/adis-navitel-service/smarty/configs chmod 774 /server/www/html/adis-navitel-service/smarty/cache chmod 774 /server/www/html/adis-navitel-service/smarty/templates_c mkdir -p /server/www/html/adis-service/smarty/configs mkdir -p /server/www/html/adis-service/smarty/cache mkdir -p /server/www/html/adis-service/smarty/templates_c chmod 774 /server/www/html/adis-service/smarty/configs chmod 774 /server/www/html/adis-service/smarty/cache chmod 774 /server/www/html/adis-service/smarty/templates_c mkdir -p /server/www/html/adis-callback/smarty/configs mkdir -p /server/www/html/adis-callback/smarty/cache mkdir -p /server/www/html/adis-callback/smarty/templates_c chmod 774 /server/www/html/adis-callback/smarty/configs chmod 774 /server/www/html/adis-callback/smarty/cache chmod 774 /server/www/html/adis-callback/smarty/templates_c mkdir -p /server/www/html/adis-mobile/smarty/configs mkdir -p /server/www/html/adis-mobile/smarty/cache mkdir -p /server/www/html/adis-mobile/smarty/templates_c chmod 774 /server/www/html/adis-mobile/smarty/configs chmod 774 /server/www/html/adis-mobile/smarty/cache chmod 774 /server/www/html/adis-mobile/smarty/templates_c mkdir -p /server/www/html/adis-db/smarty/configs mkdir -p /server/www/html/adis-db/smarty/cache mkdir -p /server/www/html/adis-db/smarty/templates_c chmod 774 /server/www/html/adis-db/smarty/configs chmod 774 /server/www/html/adis-db/smarty/cache chmod 774 /server/www/html/adis-db/smarty/templates_c mkdir -p /server/www/html/utils/smarty/configs mkdir -p /server/www/html/utils/smarty/cache mkdir -p /server/www/html/utils/smarty/templates_c chmod 774 /server/www/html/utils/smarty/configs chmod 774 /server/www/html/utils/smarty/cache chmod 774 /server/www/html/utils/smarty/templates_c mkdir -p /server/www/html/adis-db-out/smarty/configs mkdir -p /server/www/html/adis-db-out/smarty/cache mkdir -p /server/www/html/adis-db-out/smarty/templates_c chmod 774 /server/www/html/adis-db-out/smarty/configs chmod 774 /server/www/html/adis-db-out/smarty/cache chmod 774 /server/www/html/adis-db-out/smarty/templates_c mkdir -p /server/www/html/adis-db-out/smarty/configs mkdir -p /server/www/html/adis-db-out/smarty/cache mkdir -p /server/www/html/adis-db-out/smarty/templates_c chmod 774 /server/www/html/adis-db-out/smarty/configs chmod 774 /server/www/html/adis-db-out/smarty/cache chmod 774 /server/www/html/adis-db-out/smarty/templates_c mkdir -p /server/www/html/adis-geo/smarty/configs mkdir -p /server/www/html/adis-geo/smarty/cache mkdir -p /server/www/html/adis-geo/smarty/templates_c chmod 774 /server/www/html/adis-geo/smarty/configs chmod 774 /server/www/html/adis-geo/smarty/cache chmod 774 /server/www/html/adis-geo/smarty/templates_c chown -R adisadmin:$APACHE_USER $SERVER_PATH/www/ #mysql_install_db cd $ADPath/ cat my.cnf.add >> /etc/mysql/conf.d/mysql.cnf echo "[mysqld]" >> /etc/mysql/mariadb.cnf echo "sql-mode=\"NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION\"" >> /etc/mysql/mariadb.cnf echo "Load DB Structure" cd $ADPath/sql mysql -uroot < adis-auth.sql mysql -uroot < adis-common.sql mysql -uroot < adis-conf.sql mysql -uroot < adis-data.sql mysql -uroot < adis-exchange.sql mysql -uroot < adis-exchange-service.sql mysql -uroot < adis-exchange-service-converter.sql mysql -uroot < adis-exchange-spr.sql mysql -uroot < adis-map.sql mysql -uroot < adis-mobile.sql mysql -uroot < adis-patient.sql mysql -uroot < adis-user.sql mysql -uroot < adis-send-service-data.sql mysql -uroot < adis-remd.sql mysql -uroot < adis-esvs-nsi.sql mysql -uroot < adis-remd-nsi.sql mysql -uroot < grant mysql -uroot < adis-user-add.sql #mysql -uroot adis-conf < adis-version.sql if [ -e adis-user-local.sql ] then mysql -uroot adis-user < adis-user-local.sql fi #/usr/bin/mysql_secure_installation cd $ADPath/ echo "MAILTO=\"\"" > setcron crontab -l >> setcron echo "55 0 * * * find /home/adis/status_in/TEMP -mtime +1 -type f -delete" >> setcron echo "56 0 * * * find /home/adis/status_in_move -mtime +30 -type f -delete" >> setcron echo "57 0 * * * find /home/adis/status_out_move -mtime +7 -type f -delete" >> setcron crontab -u root setcron rm -f setcron echo "MAILTO=\"\"" > setcron echo "40 0 * * * /server/www/html/utils/clear-logs --keep=7 --force" >> setcron echo "1 0 * * * /server/www/html/utils/server-info" >> setcron echo "*/1 * * * * /home/server/www/html/adis-utils/adis-check-online --smp=23 --save --quiet" >> setcron echo "#*/1 * * * * /server/www/html/adis-geo/wialon/wialonbin" >> setcron echo "#*/1 * * * * /server/www/html/adis-geo/scout/scoutbin" >> setcron echo "#*/2 * * * * /server/www/html/utils/convert-adis-report --report=day01,day31 --quiet --outpath=/server/www/html/adis/report-data/" >> setcron crontab -u adisadmin setcron rm -f setcron mkdir /home/adis/status_in_move/ &> /dev/null chown adisadmin:adis /home/adis/status_in_move/ chmod 750 /home/adis/status_in_move/ mkdir /home/adis/status_out_move/ &> /dev/null chown adisadmin:adis /home/adis/status_out_move/ chmod 750 /home/adis/status_out_move/ mkdir /home/adis/status_in/ &> /dev/null chown adisadmin:adis /home/adis/status_in chmod 750 /home/adis/status_in mkdir /home/adis/status_out &> /dev/null chown adisadmin:adis /home/adis/status_out chmod 750 /home/adis/status_out mkdir /home/adis/status_in/TEMP &> /dev/null chown adisadmin:adis /home/adis/status_in/TEMP chmod 750 /home/adis/status_in/TEMP INFO=/root/adis.info TIMEZONE=`sed -n /TIMEZONE/p $INFO | cut -d= -f2` IPADDR=`sed -n /IPADDR/p $INFO | cut -d= -f2` CITY_NAME=`sed -n /CITY_NAME/p $INFO | cut -d= -f2` SSMP=`sed -n /SSMP/p $INFO | cut -d= -f2` echo ";timezone" >> /etc/php/$PHP_VERSION/apache2/php.ini echo "date.timezone = $TIMEZONE" >> /etc/php/$PHP_VERSION/apache2/php.ini echo ";" >> /etc/php.ini echo ";timezone" >> /etc/php/$PHP_VERSION/cli/php.ini echo "date.timezone = $TIMEZONE" >> /etc/php/$PHP_VERSION/cli/php.ini echo ";" >> /etc/php.ini echo "UPDATE global set val='$SSMP' WHERE name='SSMP';UPDATE global set val='$CITY_NAME' WHERE name='CITY_NAME';UPDATE global set val='$TIMEZONE' WHERE name='TIMEZONE';UPDATE global set val='$IPADDR' WHERE name='EXT_IP_ADDRESS'"|mysql -uroot -pZinin adis-conf > /dev/null echo "UPDATE \`adis-map\` set val='$IPADDR' WHERE name='SERVER_SOCKET_ADDR'"|mysql -uroot -pZinin adis-conf > /dev/null echo "UPDATE \`ext_user\` SET wsdl_url = REPLACE( wsdl_url, '87.244.25.206:6680', '$IPADDR' ) WHERE wsdl_url LIKE '%87.244.25.206:6680%'"|mysql -uroot -pZinin adis-user > /dev/null echo "UPDATE \`adis-map\` SET val = '$IPADDR' WHERE name = 'SERVER_SOCKET_ADDR'"|mysql -uroot -pZinin adis-conf > /dev/null echo "UPDATE \`adis-map\` SET val = REPLACE( val, '87.244.25.206:6680', '$IPADDR' ) WHERE val LIKE '%87.244.25.206:6680%'"|mysql -uroot -pZinin adis-conf > /dev/null echo "UPDATE \`global\` SET val = REPLACE( val, '87.244.25.206:6680', '$IPADDR' ) WHERE val LIKE '%87.244.25.206:6680%'"|mysql -uroot -pZinin adis-conf > /dev/null echo "UPDATE \`adis-conf\`.\`global\` SET val='0' WHERE name='DEBUG';"|mysql -uroot -pZinin adis-conf > /dev/null echo "UPDATE \`global\` set val='_PROTOCOL_://_IP_/nominatim' WHERE name='NOMINATIM_LINK'"|mysql -uroot -pZinin adis-conf > /dev/null echo "UPDATE \`ext_user\` SET is_active = 0 WHERE login = 'ext_sys_test'" |mysql -uroot -pZinin adis-user > /dev/null echo "UPDATE \`ext_user\` SET passwd = md5('Zinin') WHERE login = 'adis'" |mysql -uroot -pZinin adis-user > /dev/null echo "update \`global\` set is_active='0' where name = 'STATUS_IN_ERROR';" |mysql -uroot -pZinin adis-conf > /dev/null echo "update \`global\` set is_active='1' where name = 'STATUS_IN_MOVE';" |mysql -uroot -pZinin adis-conf > /dev/null echo "update \`global\` set is_active='0' where name = 'STATUS_OUT_ERROR';" |mysql -uroot -pZinin adis-conf > /dev/null echo "update \`global\` set is_active='1' where name = 'STATUS_OUT_MOVE';" |mysql -uroot -pZinin adis-conf > /dev/null echo "update \`global\` set is_active='0' where name = 'CLOSE_STATUS_MOVE';" |mysql -uroot -pZinin adis-conf > /dev/null echo "update \`global\` set is_active='0' where name = 'MAP_BOUNDARY';" |mysql -uroot -pZinin adis-conf > /dev/null echo "update \`global\` set is_active='0' where name = 'ONLY_BOUNDING_BOX_SEARCH';" |mysql -uroot -pZinin adis-conf > /dev/null echo "update \`adis-v2\` set is_active='0' where name = 'SHOW_SES_REPORT';" |mysql -uroot -pZinin adis-conf > /dev/null echo "drop table \`adis-data\`.\`cmpstaff\`;" |mysql -uroot -pZinin adis-data > /dev/null # Привилегии для `adis`@`localhost` echo "GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, SHOW VIEW, CREATE ROUTINE ON *.* TO 'adis'@'localhost' IDENTIFIED BY PASSWORD '*F609D316CA728C10E80695E299F9C061A9376AA2';" |mysql -uroot -pZinin > /dev/null # Привилегии для `root`@`127.0.0.1` echo "GRANT ALL PRIVILEGES ON *.* TO 'root'@'127.0.0.1' IDENTIFIED BY PASSWORD '*F609D316CA728C10E80695E299F9C061A9376AA2' WITH GRANT OPTION;" |mysql -uroot -pZinin > /dev/null # Привилегии для `root`@`::1` echo "GRANT ALL PRIVILEGES ON *.* TO 'root'@'::1' IDENTIFIED BY PASSWORD '*F609D316CA728C10E80695E299F9C061A9376AA2' WITH GRANT OPTION;" |mysql -uroot -pZinin > /dev/null keyname=`uname -n` # Привилегии для `root`@ keyname echo "GRANT ALL PRIVILEGES ON *.* TO 'root'@'"$keyname"' IDENTIFIED BY PASSWORD '*F609D316CA728C10E80695E299F9C061A9376AA2' WITH GRANT OPTION;" |mysql -uroot -pZinin > /dev/null echo "GRANT PROXY ON ''@'%' TO 'root'@'"$keyname"' WITH GRANT OPTION;" |mysql -uroot -pZinin > /dev/null # Привилегии для `root`@`localhost` echo "GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*F609D316CA728C10E80695E299F9C061A9376AA2' WITH GRANT OPTION;" |mysql -uroot -pZinin > /dev/null echo "GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION;" |mysql -uroot -pZinin > /dev/null # INT_IP_ADDRESS ip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/') echo "UPDATE \`global\` set val='$ip' WHERE name='INT_IP_ADDRESS'"|mysql -uroot -pZinin adis-conf > /dev/null mkdir /root/certs cd /root/certs openssl genrsa -out $keyname.key 2048 openssl req -new -key $keyname.key -out $keyname.csr -subj "/C=RU/ST=$SSMP/L=$CITY_NAME/O=ADIS/OU=ssmp/CN=$keyname" openssl x509 -req -days 1095 -in $keyname.csr -signkey $keyname.key -out $keyname.crt #cp -f /root/certs/$keyname.crt /etc/pki/tls/certs/$keyname.crt #cp -f /root/certs/$keyname.key /etc/pki/tls/private/$keyname.key #cp -f /root/certs/$keyname.csr /etc/pki/tls/private/$keyname.csr #if [ $OS_VER_ID = "1.6" ]; then echo "AstraMode off" >> /etc/apache2/apache2.conf #fi chown -R adisadmin:$APACHE_USER /var/lib/php/sessions echo "APACHE_USER=$APACHE_USER" > /etc/profile.d/set_apache_user.sh echo "SetEnv APACHE_USER '$APACHE_USER'" >> /etc/apache2/apache2.conf systemctl restart apache2 mkdir -p /server/www/html/utils/logs chmod 771 /server/www/html/utils/logs mkdir -p /server/www/html/adis-mobile/logs chmod 771 /server/www/html/adis-mobile/logs mkdir -p /server/www/html/adis-db/logs chmod 771 /server/www/html/adis-db/logs mkdir -p /server/www/html/adis-map/logs chmod 771 /server/www/html/adis-map/logs vr=`sudo -u adisadmin /server/bin/clntlist /home/adis/exe | cut -d [ -f2 | cut -d ] -f1 | sed {/" "/d}` release=`/server/www/html/adis-utils/adis-server-info --show=release_short --quiet` version=`/server/www/html/adis-utils/adis-server-info --show=version --quiet` ln -s /home/server/www/html/adis-includes/data_def_$release.inc.php /home/server/www/html/includes/data_def_$version.inc.php /server/www/html/adis-utils/adis-reload-spr-data --force --quiet /server/www/html/adis-utils/adis-server-info --save --quiet chown -R adisadmin:www-data /server/www/html echo "" echo "Done."