NBash

Форк
0
88 строк · 1.9 Кб
1
#!/bin/sh
2
#
3
# Copyright (C) 2017  Etersoft
4
# Copyright (C) 2017  Vitaly Lipatov <lav@etersoft.ru>
5
#
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU Affero General Public License as published by
8
# the Free Software Foundation, either version 3 of the License, or
9
# (at your option) any later version.
10
#
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU Affero General Public License for more details.
15
#
16
# You should have received a copy of the GNU Affero General Public License
17
# along with this program. If not, see <http://www.gnu.org/licenses/>.
18
#
19

20
is_warmup_allowed()
21
{
22
    # disable warming up until set warmup in /etc/eepm/eepm.conf
23
    [ -n "$warmup" ] || return 1
24

25
    # disable warm if have no enough memory
26
    [ "$DISTRMEMORY" -ge 1024 ] && return 0
27
    warning "Skipping warmup bases due low memory size"
28
    return 1
29
}
30

31
__warmup_files()
32
{
33
    local D="$1"
34
    shift
35
    #showcmd "$*"
36
    [ -n "$D" ] && info "Warming up $D ..."
37
    # TODO: use progress, calc files size before
38
    docmd cat $* >/dev/null 2>/dev/null
39
}
40

41
warmup_rpmbase()
42
{
43
    is_warmup_allowed || return 0
44
    __warmup_files "rpm" "/var/lib/rpm/*"
45
}
46

47
warmup_dpkgbase()
48
{
49
    is_warmup_allowed || return 0
50
    __warmup_files "dpkg" "/var/lib/dpkg/*"
51
}
52

53
warmup_lowbase()
54
{
55
    case $PKGFORMAT in
56
        "rpm")
57
            warmup_rpmbase "$@"
58
            ;;
59
        "dpkg")
60
            warmup_dpkgbase "$@"
61
            ;;
62
        *)
63
            ;;
64
    esac
65
}
66

67
warmup_aptbase()
68
{
69
    is_warmup_allowed || return
70
    __warmup_files "apt" "/var/lib/apt/lists/* /var/cache/apt/*.bin"
71
}
72

73
warmup_hibase()
74
{
75
    case $PMTYPE in
76
        "apt-rpm"|"apt-dpkg")
77
            warmup_aptbase "$@"
78
            ;;
79
        *)
80
            ;;
81
    esac
82
}
83

84
warmup_bases()
85
{
86
    DISquiet=1 warmup_lowbase
87
    DISquiet=1 warmup_hibase
88
}
89

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.