blob: 749d1bd78e1aaff86d9d9e6887d47a7d25ba0af3 (
plain)
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
|
#!/bin/bash
notify_err() {
say "errexit on line $(caller)"
say "Error messages can be found at the end of setup.log"
exit 1
}
trap notify_err ERR
# Message
function say() {
echo "TALER: " "$@" >> setup.log
echo "TALER: " "$@"
}
# Check user if the user is root
function check_user() {
if [ "$(whoami)" != "root" ]; then
say "Please run this script as root"
exit 1
fi
}
# Set DISTRO to the detected distro or return non-zero
# status if distro not supported.
function detect_distro() {
unset DISTRO
# shellcheck disable=SC2034
uname -a | grep Ubuntu >/dev/null && DISTRO=ubuntu && return 0
# shellcheck disable=SC2034
uname -a | grep Debian >/dev/null && DISTRO=debian && return 0
echo "Unsupported distro, should be either ubuntu or debian" >&2
return 1
}
|