#!/bin/bash install_package() { echo "# Installing packages $* ... " apt-get $INSTALLOPTIONS install "$@" && return 0 echo echo "# Could not install $*" echo "# Trying an apt-get update..." if ! apt-get update; then perror "apt-get update failed. Abort." fi echo "# Retrying installing package $* ... " apt-get $INSTALLOPTIONS install "$@" && return 0 perror "Could not install $* - Giving up." } install_packages() { local NEEDED_PACKAGES="$2" local INSTALLOPTIONS= echo "#" echo "# Installing packages. This may take a while." echo "#" case "$1" in NOREC) INSTALLOPTIONS="-qq -y --no-install-recommends" ;; RECOM) INSTALLOPTIONS="-qq -y" ;; *) perror "Invalid install_packages mode: $1" ;; esac install_package $NEEDED_PACKAGES # No quotes } # install_files install_files() { local dir="${BASEDIR}/static_files/${1}" [ -d "$dir" ] || perror "static files for module $1 not found" tar -cpP --owner=root --group=root --transform "s,^\(./\)*${dir}/*,," "$dir" | tar -xp -C / local ps=( "${PIPESTATUS[@]}" ) [ "${ps[0]}" != 0 ] && perror "tarcopy: Read failed" [ "${ps[1]}" != 0 ] && perror "tarcopy: Write failed" return 0 }