diff --git a/expand.sh b/expand.sh index 58d2e11b..5409e9a0 100644 --- a/expand.sh +++ b/expand.sh @@ -1,6 +1,8 @@ #!/bin/bash -sudo apt install -y cloud-guest-utils fdisk e2fsck-static || true +source utils/system.sh + +installDependencies cloud-guest-utils e2fsprogs lsblk | grep -v loop diff --git a/setup.sh b/setup.sh index 2f81b36a..e17448d7 100644 --- a/setup.sh +++ b/setup.sh @@ -41,9 +41,6 @@ source utils/distros/${DISTRO}.sh # Exit on errors set -e -# Determine host system -whichOperatingSystem - # Many much importance installDependencies toilet diff --git a/utils/system.sh b/utils/system.sh index 12410c87..1c913e0b 100755 --- a/utils/system.sh +++ b/utils/system.sh @@ -1,5 +1,10 @@ #!/bin/bash +# Source other files to simplify importing this script on more minimal bash scripts +# (e.g. expand.sh or genimg.sh) +DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +source ${DIR}/functions.sh + # Determine host system function whichOperatingSystem { @@ -38,12 +43,19 @@ function installDependencies () { # NOTE: "$*" is used to call all function arguments + # Identify the distro if it is undefined + if [[ -z $DIST ]]; then + whichOperatingSystem + fi + + echo "Installing $*" + # Download dependencies based on distribution case $DIST in Debian) # Install dependencies on a Debian host system - sudo apt install -y $* + sudo apt install -y "$@" ;; Arch) @@ -60,6 +72,11 @@ function installDependencies () { var=vboot-utils; ;; + # growpart + cloud-guest-utils) + var=growpartfs; + ;; + # cgpt cgpt) unset var; # Included in vboot-utils @@ -87,6 +104,11 @@ function installDependencies () { var=vboot-utils; ;; + # growpart + cloud-guest-utils) + var=cloud-utils-growpart; + ;; + # cgpt cgpt) unset var; # Included in vboot-utils