среда, 1 апреля 2015 г.

Скрипт создания зеркала обновлений для ESET на FreeBSD

Сам скрипт взят с сайта за что им большое спасибо

Ставим bash, curl, wget, unrar
# cd /usr/ports/shells/bash && make install clean
# chsh -s /usr/local/bin/bash root

cd /usr/ports/ftp/curl && make install clean
# cd /usr/ports/ftp/wget && make install clean
# cd /usr/ports/archivers/unrar && make install clean

Ставим скрипт
# cd /tmp
# wget https://github.com/tarampampam/nod32-update-mirror/archive/master.zip
# unzip master.zip; cd ./nod32-update-mirror-master/

Переносим набор скриптов в директорию недоступную «извне», но доступную для пользователя, который будет его запускать:
# mv -f ./nod32upd/ /home/

Переходим в новое расположение скриптов и выполняем их настройку (подробнее об этом в readme.md):
# cd /home/nod32upd/
# nano ./settings.cfg

Даем права на запуск скриптов:
# chmod +x ./*.sh

Проверяем наличие unrar, если планируем обновляться с официальных зеркал Eset NOD32:
# type -P unrar

В файлах settings.cfg и update.shgetkey.sh меняем #!/bin/bash на #!/usr/local/bin/bash

Меняем переменную pathToSaveBase="$HOME/nod32mirror/"; на pathToSaveBase="/var/nod32mirror/";

Выполняем пробный запуск:
# ./update.sh

Добавляем в cron
# ee /etc/crontab
*       1       *       *       *       root    /home/nod32upd/update.sh > /dev/null 2>&1
и правим PATH к такому виду PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin

Ставим NGINX с параметром fancyindex
# cd /usr/ports/www/nginx && make install clean
# echo 'nginx_enable="YES"' >> /etc/rc.conf
# ee /usr/local/etc/nginx/nginx.conf

events {
        worker_connections 1024;
}

http {

        server {
                listen *:80;
                server_name имя сервера;
                root        /папка зеркала;
                error_log   off;
                access_log  off;

                charset utf-8;
                index index.html;

                if ($http_user_agent ~* ^(Wget|aria2|NOD32view|perl|php|curl|Google|Yandex|Yahoo)|(Mirror|spider|bot|Parser|RSS|grab)) {
                        return 403;
                }

                location ~* ^.+.(htaccess|htpasswd|pl|cqi|sh|sql|conf|tmp)$ {
                        return 403;
                }

                location / {
                        autoindex  on;
                        fancyindex on;
                        fancyindex_localtime on;
                        fancyindex_header /.webface/header.html;
                        fancyindex_footer /.webface/footer.html;
                        fancyindex_ignore "(^\.(htpasswd|htaccess|webface)$|\.(php.?|htm.?|txt|conf|log|tmp.?)$)";
                }

                set $errordocs $document_root/.webface/errorpages;
                error_page 401 /401.html; location = /401.html {root $errordocs;}
                error_page 403 /403.html; location = /403.html {root $errordocs;}
                error_page 404 /404.html; location = /404.html {root $errordocs;}
                error_page 500 /500.html; location = /500.html {root $errordocs;}
                error_page 502 /502.html; location = /502.html {root $errordocs;}
                error_page 503 /503.html; location = /503.html {root $errordocs;}
                }
}

Копируем файл .htaccess и папку .webface в папку зеркала и наблюдаем такой мини сайт

Комментариев нет:

Отправить комментарий