From 7dd3b013236761e0d4e47a516fae9d68e2418c58 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 19 Jan 2022 15:42:37 +0100 Subject: [PATCH] Update _common.sh --- scripts/_common.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/scripts/_common.sh b/scripts/_common.sh index 944a65e..8fc49a5 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -15,3 +15,24 @@ #================================================= # FUTURE OFFICIAL HELPERS #================================================= + +# Check the architecture +# +# example: architecture=$(ynh_detect_arch) +# +# usage: ynh_detect_arch +# +# Requires YunoHost version 2.2.4 or higher. +ynh_detect_arch() { + local architecture + if [ -n "$(uname -m | grep arm64)" ] || [ -n "$(uname -m | grep aarch64)" ]; then + architecture="arm64" + elif [ -n "$(uname -m | grep 86)" ]; then + architecture="i386" + elif [ -n "$(uname -m | grep 64)" ]; then + architecture="x86_64" + else + architecture="unknown" + fi + echo $architecture +}