#! /bin/bash main() { drivers_dir="" while getopts "hd:" arg; do case "${arg}" in h) echo '--help' ;; d) drivers_dir="${OPTARG}" ;; *) echo '??' ;; esac done shopt -s nullglob set -e echo "==== Driver dir: ${drivers_dir}" for file in "${drivers_dir}"/*; do echo "==== Processing ${file}..." case "${file}" in *.deb) dpkg -i "${file}" || : ;; *.sh) "${file}" ;; *.ppd) cp "${file}" /usr/share/ppd/ ;; *) echo "==== Ignoring ${file}" ;; esac done if ! apt-get install; then echo "==== Apt seems broken. Fixing..." apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -yqf && apt-get clean && rm -rf /var/lib/apt/lists/* fi } main "${@}"