Skip to content

Commit 1aa9071

Browse files
author
twojstaryzdomu
committed
install.sh,update.sh,README.md: Run without sudo
1 parent 793e5e5 commit 1aa9071

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

README.md

+3-9
Original file line numberDiff line numberDiff line change
@@ -205,18 +205,12 @@ _Note: this assumes a clean Debian install, and there is no rollback method_
205205

206206
### Curl install scripts
207207

208-
This is executed as `root` as indicated by the `#`
208+
This script will be executed as `root`, `sudo` is not necessary
209209

210210
```
211211
# curl -sSL https://raw.githubusercontent.com/nextcloud/nextcloudpi/master/install.sh | bash
212212
```
213213

214-
If you're not `root` you can run it with `sudo` like so
215-
216-
```
217-
curl -sSL https://raw.githubusercontent.com/nextcloud/nextcloudpi/master/install.sh | sudo bash
218-
```
219-
220214
### Environment variables for install.sh
221215

222216
Environment variables control the installation process.
@@ -231,10 +225,10 @@ When set to any value:
231225
- `REINIT` - re-initialise the configuration from scratch: drop NC database & user environment
232226
- `NCDATA` - overrides the NC data directory, defined in `etc/ncp-config.d/nc-datadir.cfg`
233227

234-
NOTE: `sudo -E` is needed to source non-root user environment i.e.
228+
NOTE: `sudo -E` is normally needed to gain root and to source non-root user environment but not required here
235229

236230
```
237-
CODE_DIR=. NOUPDATE=1 NCHOSTNAME=my_own_hostname sudo -E bash install.sh
231+
CODE_DIR=. NOUPDATE=1 NCHOSTNAME=my_own_hostname | bash install.sh
238232
```
239233

240234
Also, for debug purposes:

install.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212
BRANCH="${BRANCH:-master}"
1313
#DBG=x
1414

15+
[[ ${EUID} -ne 0 ]] && {
16+
sudo -E bash $0
17+
exit $?
18+
}
19+
1520
set -e$DBG
1621

1722
TEMPDIR="$(mktemp -d /tmp/nextcloudpi.XXXXXX || (echo "Failed to create temp dir. Exiting" >&2 ; exit 1) )"
1823
trap "rm -rf \"${TEMPDIR}\"" 0 1 2 3 15
1924

20-
[[ ${EUID} -ne 0 ]] && {
21-
printf "Must be run as root. Try 'sudo $0'\n"
22-
exit 1
23-
}
24-
2525
export PATH="/usr/local/sbin:/usr/sbin:/sbin:${PATH}"
2626

2727
# check installed software

update.sh

+5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
# More at https://ownyourbits.com/
99
#
1010

11+
[[ ${EUID} -ne 0 ]] && {
12+
sudo -E $0
13+
exit $?
14+
}
15+
1116
source /usr/local/etc/library.sh
1217

1318
set -e$DBG

0 commit comments

Comments
 (0)