wip
This commit is contained in:
parent
53508118a2
commit
f2696d3dd3
1 changed files with 40 additions and 21 deletions
61
template.sh
61
template.sh
|
@ -6,6 +6,30 @@
|
|||
command -v "$@" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# ─< package variable >───────────────────────────────────────────────────────────────────
|
||||
unset PACKAGE
|
||||
|
||||
# ─< argument list variables >────────────────────────────────────────────────────────────
|
||||
unset silent
|
||||
|
||||
sleep 0.1
|
||||
|
||||
PACKAGE=packagename
|
||||
if command_exists "$PACKAGE"; then
|
||||
echo_warning "$PACKAGE is already installed!"
|
||||
echo_warning "Exiting now!"
|
||||
exit 69
|
||||
fi
|
||||
|
||||
# ─< parse arguments and get variable contents >──────────────────────────────────────────
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
--silent | -s)
|
||||
silent=true
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# WHY:
|
||||
# This import will give you the following variables:
|
||||
# _sudo="sudo -E" <- only if non root user
|
||||
|
@ -31,8 +55,8 @@
|
|||
fi
|
||||
|
||||
source "$import"
|
||||
sleep 0.2
|
||||
rm "$import"
|
||||
sleep 0.1
|
||||
rm -f "$import"
|
||||
}
|
||||
|
||||
getDependencies() {
|
||||
|
@ -65,15 +89,25 @@
|
|||
declare -n pkgArray="${deps[$distro]}"
|
||||
|
||||
case "$distro" in
|
||||
debian | ubuntu | arch | fedora | alpine | opensuse) checkAndInstall "${pkgArray[@]}" ;;
|
||||
debian | ubuntu | arch | fedora | alpine | opensuse)
|
||||
checkAndInstall "${pkgArray[@]}"
|
||||
;;
|
||||
*)
|
||||
echo_error "Cannot install for $distro"
|
||||
echo_error "There are no dependencies to install for $distro"
|
||||
return 69
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
main() {
|
||||
if $silent; then
|
||||
echo_warning "Executing script silently!"
|
||||
fi
|
||||
|
||||
if ! getDependencies; then
|
||||
echo_error "Error when installing dependencies.."
|
||||
fi
|
||||
|
||||
case "$distro" in
|
||||
arch)
|
||||
echo "arch"
|
||||
|
@ -100,22 +134,7 @@
|
|||
esac
|
||||
}
|
||||
|
||||
setup() {
|
||||
if getImports; then
|
||||
case "$@" in
|
||||
--silent | -s)
|
||||
silent=true
|
||||
echo_warning "Running script silently!"
|
||||
;;
|
||||
*)
|
||||
silent=false
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
|
||||
if setup; then
|
||||
getDependencies
|
||||
main </dev/tty
|
||||
if getImports; then
|
||||
main
|
||||
fi
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue