mirror of
https://github.com/kingomarnajjar/desktop-environment.git
synced 2026-07-31 02:26:44 +10:00
clean-permissions
This commit is contained in:
parent
2a5f4eb0df
commit
6edfc1e1d5
3 changed files with 30 additions and 10 deletions
25
docker/scripts/clean-ownership.sh
Executable file
25
docker/scripts/clean-ownership.sh
Executable file
|
|
@ -0,0 +1,25 @@
|
|||
REPO_ROOT=$(dirname $(readlink -f $0))/../..
|
||||
|
||||
# Export desktop environment shell configuration
|
||||
export $($REPO_ROOT/docker/scripts/environment.sh)
|
||||
|
||||
SECRETS_VOLUMES=$(cat $REPO_ROOT/docker/scripts/clean*.sh | grep DESKTOP_ | cut -f 2 -d ' ' | sort | uniq)
|
||||
|
||||
for VOLUME_NAME in $SECRETS_VOLUMES; do
|
||||
|
||||
VOLUME_PATH=$(printenv $VOLUME_NAME)
|
||||
|
||||
echo Owning $VOLUME_NAME...
|
||||
|
||||
# Give the desktop environment user ownership of the volume
|
||||
docker run \
|
||||
--rm \
|
||||
--user root \
|
||||
--volume $VOLUME_NAME:$VOLUME_PATH \
|
||||
alpine:latest \
|
||||
chown -R $DESKTOP_ENVIRONMENT_USER_ID:$DESKTOP_ENVIRONMENT_USER_ID $VOLUME_PATH &
|
||||
|
||||
done
|
||||
|
||||
# Wait for ownership changes to complete in parallel
|
||||
wait
|
||||
|
|
@ -7,5 +7,8 @@ $REPO_ROOT/docker/scripts/stop.sh 2>/dev/null
|
|||
$REPO_ROOT/docker/scripts/wipe-volume.sh DESKTOP_ENVIRONMENT_CACHE_VCSH &
|
||||
$REPO_ROOT/docker/scripts/wipe-volume.sh DESKTOP_ENVIRONMENT_USER_HOME &
|
||||
|
||||
# Ensure cleaned volumes are owned after removal
|
||||
$REPO_ROOT/docker/scripts/clean-ownership.sh
|
||||
|
||||
# Wait for cleans to complete in parallel
|
||||
wait
|
||||
|
|
|
|||
|
|
@ -4,15 +4,7 @@ REPO_ROOT=$(dirname $(readlink -f $0))/../..
|
|||
export $($REPO_ROOT/docker/scripts/environment.sh)
|
||||
|
||||
VOLUME_NAME=$1
|
||||
VOLUME_PATH=$(printenv $VOLUME_NAME)
|
||||
|
||||
echo Wiping $VOLUME_NAME...
|
||||
echo Removing $VOLUME_NAME...
|
||||
|
||||
# Remove all files in the volume rather than removing the volume so that ownership permissions are preserved
|
||||
docker run \
|
||||
--rm \
|
||||
--user root \
|
||||
--volume $VOLUME_NAME:$VOLUME_PATH \
|
||||
--workdir $VOLUME_PATH \
|
||||
alpine:latest \
|
||||
ash -c 'rm -rf ..?* .[!.]* *'
|
||||
docker volume rm $VOLUME_NAME
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue