5604d6da by Adam Heath

Add better file ownership changing.

1 parent 8c5c11c5
...@@ -5,13 +5,18 @@ set -ex ...@@ -5,13 +5,18 @@ set -ex
5 node_home="$(getent passwd node | cut -f 6 -d :)" 5 node_home="$(getent passwd node | cut -f 6 -d :)"
6 6
7 if [[ $GID && $GID -ne 0 ]]; then 7 if [[ $GID && $GID -ne 0 ]]; then
8 old_gid=$(getent group node | cut -f 3 -d :)
9 groupmod -g $GID node 8 groupmod -g $GID node
10 find "$node_home" -gid $old_gid -print0 | xargs -0r chgrp node
11 fi 9 fi
12 if [[ $UID && $UID -ne 0 ]]; then 10 if [[ $UID && $UID -ne 0 ]]; then
13 usermod -u $UID node 11 usermod -u $UID node
14 fi 12 fi
13
14 find "$node_home" \
15 '(' -not -user node -a -not -group node -exec chown node:node '{}' + ')' -o \
16 '(' -not -user node -exec chown node '{}' + ')' -o \
17 '(' -not -group node -exec chgrp node '{}' + ')' -o \
18 -true
19
15 if [[ -e package.json ]]; then 20 if [[ -e package.json ]]; then
16 sudo -u node npm install 21 sudo -u node npm install
17 fi 22 fi
......