-
-
Notifications
You must be signed in to change notification settings - Fork 132
Expand file tree
/
Copy pathdebian-setup-functions.inc.sh
More file actions
75 lines (62 loc) 路 1.58 KB
/
Copy pathdebian-setup-functions.inc.sh
File metadata and controls
75 lines (62 loc) 路 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# shellcheck shell=bash
#
# Common functions for debian-setup
#
# VERSION :2.1.0
Error()
{
echo "ERROR: $(tput bold;tput setaf 7;tput setab 1)${*}$(tput sgr0)" 1>&2
}
Is_installed()
{
local PKG="$1"
test "$(dpkg-query --showformat="\${Status}" --show "$PKG" 2>/dev/null)" == "install ok installed"
}
export -f Is_installed
Is_installed_regexp()
{
local PKG="$1"
local SEARCH="?and(?installed, ?name(${PKG}))"
test -n "$(aptitude --disable-columns --display-format "%p" search "$SEARCH")"
}
export -f Is_installed_regexp
Pkg_install_quiet()
{
DEBIAN_FRONTEND=noninteractive NEEDRESTART_SUSPEND=1 apt-get install -q -y "$@"
}
export -f Pkg_install_quiet
# Download architecture-independent packages
Getpkg()
{
local P="$1"
local R="${2:-sid}"
local PKG_PAGE="https://packages.debian.org/${R}/all/${P}/download"
local URL
URL="$(wget -q -O- "$PKG_PAGE" | grep -o '[^"]\+ftp\.de\.debian\.org/debian[^"]\+\.deb')"
test -z "$URL" && return 1
(
cd /root/dist-mod/ || return 1
wget -nv -O "${P}.deb" "$URL"
dpkg -i "${P}.deb"
)
}
export -f Getpkg
# Install a script from debian-server-tools
Dinstall()
{
(
cd /usr/local/src/ || return 1
if [ ! -d debian-server-tools ]; then
git clone "https://github.com/szepeviktor/debian-server-tools.git"
fi
cd debian-server-tools/ || return 1
./install.sh "$@"
)
}
export -f Dinstall
Data()
{
#PYTHONIOENCODING="utf_8" shyaml "$@" </root/server.yml
python3 /usr/local/bin/shyaml "$@" </root/server.yml
}
export -f Data