summaryrefslogtreecommitdiff
path: root/regional-currency/functions.sh
diff options
context:
space:
mode:
Diffstat (limited to 'regional-currency/functions.sh')
-rwxr-xr-xregional-currency/functions.sh36
1 files changed, 36 insertions, 0 deletions
diff --git a/regional-currency/functions.sh b/regional-currency/functions.sh
new file mode 100755
index 0000000..0663fec
--- /dev/null
+++ b/regional-currency/functions.sh
@@ -0,0 +1,36 @@
+#!/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
+ [[ -f /etc/os-release ]] && source /etc/os-release
+ # shellcheck disable=SC2034
+ echo $NAME | grep Ubuntu >/dev/null && DISTRO=ubuntu && return 0
+ # shellcheck disable=SC2034
+ echo $NAME | grep Debian >/dev/null && DISTRO=debian && return 0
+ echo "Unsupported distro, should be either ubuntu or debian" >&2
+ return 1
+}