Skip to content

Commit

Permalink
Move check for root after options evaluation (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
Olf0 committed Apr 29, 2023
1 parent 41e4349 commit 9a93222
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions bin/sfos-upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -104,22 +104,17 @@ compare_versions ()

# Main script

called="$(basename "$0")"
if ! printf '%s' " $(id -un) $(id -Gn) " | fgrep -q ' root '
then
printf '%s\n' "Aborting: $called must be started with root privileges." >&2
exit 3
fi
called="${0##*/}"

installed_release="$(version | grep -o '[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*' | head -1)"
installed_release="$(version | grep -o '[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*' | head -1)" # `version` may emit multiple version strings, see issue #32
if [ -z "$*" ]
then
set_ssu=""
upgrade_release="$(ssu re)"
upgrade_release="$(ssu re | tail -1)" # ´ssu´ emits a prefix-line, if not called by root user
upgrade_release="${upgrade_release##* }"
else
set_ssu=yes
ssu_set="$(ssu re)"
ssu_set="$(ssu re | tail -1)"
ssu_set="${ssu_set##* }"
upgrade_release="$1"
shift
Expand Down Expand Up @@ -173,6 +168,11 @@ else
;;
esac
fi
if ! printf '%s' " $(id -un) $(id -Gn) " | fgrep -q ' root '
then
printf '%s\n' "Aborting: $called must be started with root privileges." >&2
exit 3
fi

mylist_sfos_releases='4.5.0.19,4.5.0.18,4.5.0.16,4.4.0.72,4.4.0.68,4.4.0.64,4.4.0.58,4.3.0.15,4.3.0.12,4.2.0.21,4.2.0.19,4.1.0.24,4.1.0.23,4.0.1.48,4.0.1.45,3.4.0.24,3.4.0.22,3.3.0.16,3.3.0.14,3.2.1.20,3.2.1.19,3.2.0.14,3.2.0.12,3.1.0.12,3.1.0.11,3.0.3.10,3.0.3.9,3.0.3.8,3.0.2.8,3.0.1.14,3.0.1.13,3.0.1.11,3.0.0.11,3.0.0.8,3.0.0.5,2.2.1.23,2.2.1.20,2.2.1.19,2.2.1.18,2.2.0.29,2.1.4.15,2.1.4.14,2.1.4.13,2.1.4.12,2.1.3.7,2.1.3.5,2.1.3.3,2.1.2.3,2.1.1.26,2.1.1.25,2.1.1.24,2.1.1.23,2.1.1.12,2.1.0.11,2.1.0.10,2.1.0.9,2.0.5.6,2.0.4.14,2.0.4.13,2.0.3.14,2.0.3.11,2.0.2.51,2.0.2.48,2.0.2.47,2.0.2.45,2.0.2.43,2.0.1.11,2.0.1.9,2.0.1.7,2.0.0.10,1.1.9.30,1.1.9.28,1.1.9.27,1.1.9.24,1.1.9.23,1.1.7.28,1.1.7.27,1.1.7.25,1.1.7.24,1.1.7.23,1.1.6.27,1.1.6.26,1.1.6.24,1.1.4.29,1.1.4.28,1.1.4.24,1.1.4.22,1.1.2.16,1.1.2.15,1.1.2.13,1.1.2.10,1.1.1.27,1.1.1.26,1.1.1.24,1.1.0.39,1.1.0.38,1.1.0.37,1.1.0.29,1.1.0.26,1.1.0.23,1.1.0.22,1.1.0.19,1.0.8.21,1.0.8.20,1.0.8.19,1.0.8.18,1.0.7.18,1.0.7.16,1.0.7.14,1.0.7.12,1.0.5.19,1.0.5.16,1.0.5.13,1.0.5.12,1.0.5.11,1.0.4.20,1.0.4.16,1.0.4.12,1.0.4.10,1.0.3.8,1.0.3.7,1.0.3.5,1.0.2.5,1.0.1.12,1.0.1.10,1.0.1.6,1.0.0.5,1.0.0.3,1.0.0.1,0.99.6.8,0.99.6.3,0.99.5.11,0.99.5.8,0.99.5.6'
my_recent_sfos_release="${mylist_sfos_releases%%,*}"
Expand Down

0 comments on commit 9a93222

Please sign in to comment.