Add root check and print all dependencies at once (#46)

pull/144/head
AlexPresso 4 years ago committed by GitHub
parent 2f38b9f6cd
commit 6ba58dacf1

@ -35,6 +35,13 @@ function error() {
log "ERROR" "$1" log "ERROR" "$1"
} }
function root_check() {
if [[ "$EUID" -ne 0 ]]; then
error "This tool needs root access (please run 'sudo -i' before proceeding)."
exit 1
fi
}
function welcome_motd() { function welcome_motd() {
info "ffmpeg-patcher v$version" info "ffmpeg-patcher v$version"
@ -58,12 +65,18 @@ function restart_packages() {
} }
function check_dependencies() { function check_dependencies() {
missingDeps=false
for dependency in "${dependencies[@]}"; do for dependency in "${dependencies[@]}"; do
if [[ ! -d "/var/packages/$dependency" ]]; then if [[ ! -d "/var/packages/$dependency" ]]; then
error "Missing $dependency package, please install it and re-run the patcher." error "Missing $dependency package, please install it and re-run the patcher."
exit 1 missingDeps=true
fi fi
done done
if [[ $missingDeps ]]; then
exit 1
fi
} }
################################ ################################
@ -140,6 +153,9 @@ function unpatch() {
################################ ################################
# ENTRYPOINT # ENTRYPOINT
################################ ################################
root_check
check_dependencies
while getopts a:b: flag; do while getopts a:b: flag; do
case "${flag}" in case "${flag}" in
a) action=${OPTARG};; a) action=${OPTARG};;
@ -149,7 +165,6 @@ while getopts a:b: flag; do
done done
welcome_motd welcome_motd
check_dependencies
info "You're running DSM $dsm_version" info "You're running DSM $dsm_version"
if [[ -d /var/packages/CodecPack/target/pack ]]; then if [[ -d /var/packages/CodecPack/target/pack ]]; then
@ -161,3 +176,4 @@ case "$action" in
unpatch) unpatch;; unpatch) unpatch;;
patch) patch;; patch) patch;;
esac esac

Loading…
Cancel
Save