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
|
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:
|
# WHY:
|
||||||
# This import will give you the following variables:
|
# This import will give you the following variables:
|
||||||
# _sudo="sudo -E" <- only if non root user
|
# _sudo="sudo -E" <- only if non root user
|
||||||
|
@ -31,8 +55,8 @@
|
||||||
fi
|
fi
|
||||||
|
|
||||||
source "$import"
|
source "$import"
|
||||||
sleep 0.2
|
sleep 0.1
|
||||||
rm "$import"
|
rm -f "$import"
|
||||||
}
|
}
|
||||||
|
|
||||||
getDependencies() {
|
getDependencies() {
|
||||||
|
@ -65,15 +89,25 @@
|
||||||
declare -n pkgArray="${deps[$distro]}"
|
declare -n pkgArray="${deps[$distro]}"
|
||||||
|
|
||||||
case "$distro" in
|
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
|
return 69
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
|
if $silent; then
|
||||||
|
echo_warning "Executing script silently!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! getDependencies; then
|
||||||
|
echo_error "Error when installing dependencies.."
|
||||||
|
fi
|
||||||
|
|
||||||
case "$distro" in
|
case "$distro" in
|
||||||
arch)
|
arch)
|
||||||
echo "arch"
|
echo "arch"
|
||||||
|
@ -100,22 +134,7 @@
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
setup() {
|
if getImports; then
|
||||||
if getImports; then
|
main
|
||||||
case "$@" in
|
|
||||||
--silent | -s)
|
|
||||||
silent=true
|
|
||||||
echo_warning "Running script silently!"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
silent=false
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
if setup; then
|
|
||||||
getDependencies
|
|
||||||
main </dev/tty
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue