Add root check and print all dependencies at once (#46)
This commit is contained in:
parent
d7bbbdc3e7
commit
cc09127369
20
patcher.sh
20
patcher.sh
@ -35,6 +35,13 @@ function error() {
|
||||
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() {
|
||||
info "ffmpeg-patcher v$version"
|
||||
|
||||
@ -58,12 +65,18 @@ function restart_packages() {
|
||||
}
|
||||
|
||||
function check_dependencies() {
|
||||
missingDeps=false
|
||||
|
||||
for dependency in "${dependencies[@]}"; do
|
||||
if [[ ! -d "/var/packages/$dependency" ]]; then
|
||||
error "Missing $dependency package, please install it and re-run the patcher."
|
||||
exit 1
|
||||
missingDeps=true
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ $missingDeps ]]; then
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
################################
|
||||
@ -140,6 +153,9 @@ function unpatch() {
|
||||
################################
|
||||
# ENTRYPOINT
|
||||
################################
|
||||
root_check
|
||||
check_dependencies
|
||||
|
||||
while getopts a:b: flag; do
|
||||
case "${flag}" in
|
||||
a) action=${OPTARG};;
|
||||
@ -149,7 +165,6 @@ while getopts a:b: flag; do
|
||||
done
|
||||
|
||||
welcome_motd
|
||||
check_dependencies
|
||||
|
||||
info "You're running DSM $dsm_version"
|
||||
if [[ -d /var/packages/CodecPack/target/pack ]]; then
|
||||
@ -161,3 +176,4 @@ case "$action" in
|
||||
unpatch) unpatch;;
|
||||
patch) patch;;
|
||||
esac
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user