NBash

Форк
0
75 строк · 1.8 Кб
1
#!/usr/bin/env bash
2
#
3
# Copyright (C) 2023  Etersoft
4
# Copyright (C) 2023  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
PROGDIR=$(dirname "$0")
21
PROGNAME=$(basename "$0")
22
[ -n "$EPMCURDIR" ] || export EPMCURDIR="$(pwd)"
23
CMDSHELL="/usr/bin/env bash"
24
# TODO: pwd for ./epm and which for epm
25
[ "$PROGDIR" = "." ] && PROGDIR="$EPMCURDIR"
26
if [ "$0" = "/dev/stdin" ] || [ "$0" = "sh" ] ; then
27
    PROGDIR=""
28
    PROGNAME=""
29
fi
30

31
# will replaced with /usr/share/eepm during install
32
SHAREDIR=$PROGDIR
33

34
load_helper()
35
{
36
    local shieldname="loaded$(echo "$1" | sed -e 's|-||g')"
37
    # already loaded
38
    eval "test -n \"\$$shieldname\"" && debug "Already loaded $1" && return
39

40
    local CMD="$SHAREDIR/$1"
41
    # do not use fatal() here, it can be initial state
42
    [ -r "$CMD" ] || { echo "FATAL: Have no $CMD helper file" ; exit 1; }
43
    eval "$shieldname=1"
44
    # shellcheck disable=SC1090
45
    . $CMD
46
}
47

48
load_helper epm-sh-functions
49

50
esu_print_help()
51
{
52
    cat <<EOF
53
esu - get root shell or run a command in root shell
54
Usage: esu [-c] [<command>]
55
EOF
56
}
57

58

59

60
if [ "$1" = "-h" ] || [ "$1" = "--help" ] ; then
61
    esu_print_help
62
    exit
63
fi
64

65
# just ignore
66
if [ "$1" = "-c" ] ; then
67
    shift
68
fi
69

70
# just ignore
71
if [ "$1" = "-" ] ; then
72
    shift
73
fi
74

75
esu "$@"
76

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

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

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

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