|
5 | 5 | #
|
6 | 6 | # Please see the MEGAlib software license and documentation for more informations.
|
7 | 7 |
|
8 |
| - |
9 | 8 | # Part 1:
|
| 9 | +# Store command line as array |
| 10 | +CMD=( "$@" ) |
| 11 | + |
10 | 12 | # Helper functions
|
11 | 13 |
|
12 | 14 | TIMESTART=$(date +%s)
|
@@ -77,6 +79,9 @@ confhelp() {
|
77 | 79 | echo " Check periodically for updates. Default is off."
|
78 | 80 | echo " Even if set to on, update checks will only be performed, if the user has write access to the MEGAlib installation."
|
79 | 81 | echo " "
|
| 82 | + #echo "--allowroot" |
| 83 | + #echo " By default this script does not allow to be installed as ROOT. This option allows it." |
| 84 | + #echo " " |
80 | 85 | echo "--help or -h"
|
81 | 86 | echo " Show this help."
|
82 | 87 | echo " "
|
@@ -104,7 +109,15 @@ if [ "$SHELL" != "/bin/bash" ]; then
|
104 | 109 | echo " "
|
105 | 110 | fi
|
106 | 111 |
|
107 |
| -if [[ $EUID -eq 0 ]]; then |
| 112 | +# Check if the command line contains "--allowroot" |
| 113 | +ALLOWROOT="off" |
| 114 | +for C in "${CMD[@]}"; do |
| 115 | + if [[ ${C} == *--allowroot* ]]; then |
| 116 | + ALLOWROOT="on" |
| 117 | + fi |
| 118 | +done |
| 119 | + |
| 120 | +if [[ $EUID -eq 0 ]] && [[ ${ALLOWROOT} == off ]]; then |
108 | 121 | echo " " 1>&2
|
109 | 122 | echo "Error: For security reasons, this script is not intended to be run as superuser/root." 1>&2
|
110 | 123 | echo " It is intended for a user installation of MEGAlib." 1>&2
|
|
130 | 143 | # Part 3:
|
131 | 144 | # Upgrade the input options:
|
132 | 145 |
|
133 |
| -# Store command line as array |
134 |
| -CMD=( "$@" ) |
135 |
| - |
136 | 146 | # Check for help
|
137 | 147 | for C in "${CMD[@]}"; do
|
138 | 148 | if [[ ${C} == *-h ]] || [[ ${C} == *-hel* ]]; then
|
@@ -171,6 +181,7 @@ UPDATES="off"
|
171 | 181 | PATCH="on"
|
172 | 182 | CLEANUP="off"
|
173 | 183 | BRANCH=""
|
| 184 | +# ALLOWROOT="off" - initialized in the beginning not here |
174 | 185 |
|
175 | 186 | MAXTHREADS=1;
|
176 | 187 | if [[ ${OSTYPE} == *arwin* ]]; then
|
@@ -253,6 +264,9 @@ for C in "${CMD[@]}"; do
|
253 | 264 | elif [[ ${C} == *-b* ]]; then
|
254 | 265 | BRANCH=`echo ${C} | awk -F"=" '{ print $2 }'`
|
255 | 266 | RELEASE="dev"
|
| 267 | + elif [[ ${C} == *--allowroot* ]]; then |
| 268 | + # Handled above too |
| 269 | + ALLOWROOT="on" |
256 | 270 | elif [[ ${C} == *-h ]] || [[ ${C} == *-hel* ]]; then
|
257 | 271 | echo ""
|
258 | 272 | confhelp
|
|
0 commit comments