ncp-update: Prevent running update script inside docker without explicit confirmation

Signed-off-by: Tobias K <6317548+theCalcaholic@users.noreply.github.com>
Signed-off-by: thecalcaholic <6317548+theCalcaholic@users.noreply.github.com>
This commit is contained in:
Tobias K 2022-09-25 12:25:29 +02:00 committed by thecalcaholic
parent 780d02a6bd
commit 0c3a817421
No known key found for this signature in database
GPG Key ID: 3510056072886A8F
3 changed files with 12 additions and 0 deletions

View File

@ -4,6 +4,15 @@
[[ -z "$DBG" ]] || set -$DBG
if [[ -f /.dockerenv ]] || [[ -f /.docker-image ]] || [[ "$DOCKERBUILD" == 1 ]]
then
echo "WARNING: Docker images should be updated by replacing the container from the latest docker image" \
"(refer to the documentation for instructions: https://docs.nextcloudpi.com)." \
"If you are sure that you know what you are doing, you can still execute the update script by running it like this:"
echo "> ALLOW_UPDATE_SCRIPT=1 ncp-update"
[[ "$ALLOW_UPDATE_SCRIPT" == "1" ]] || exit 1
fi
{
[ "$(id -u)" -ne 0 ] && { printf "Must be run as root. Try 'sudo $0'\n"; exit 1; }

2
ncp.sh
View File

@ -29,6 +29,8 @@ install()
test -f /usr/bin/raspi-config && {
sed -i '/Change User Password/i"0 NextCloudPi Configuration" "Configuration of NextCloudPi" \\' /usr/bin/raspi-config
sed -i '/1\\ \*) do_change_pass ;;/i0\\ *) ncp-config ;;' /usr/bin/raspi-config
# Disable raspberry pi default user
usermod pi -s /sbin/nologin
}
# add the ncc shortcut

View File

@ -17,6 +17,7 @@ UPDATESDIR=updates
# don't make sense in a docker container
EXCL_DOCKER="
nc-autoupdate-ncp
nc-automount
nc-format-USB
nc-datadir