Merge pull request #3 from infosiftr/homes

Fix "cd" / "cd ~" my creating missing home directories
This commit is contained in:
Tianon Gravi 2015-09-18 14:05:45 -07:00
commit c5311bc46b
1 changed files with 17 additions and 0 deletions

View File

@ -106,3 +106,20 @@ RUN mkdir -p rootfs/etc \
/usr/src/buildroot/system/skeleton/etc/shadow \
/usr/src/buildroot/system/skeleton/etc/group \
rootfs/etc/
# create /tmp
RUN mkdir -p rootfs/tmp \
&& chmod 1777 rootfs/tmp
# create missing home directories
RUN set -ex \
&& cd rootfs \
&& for userHome in $(awk -F ':' '{ print $3 ":" $4 "=" $6 }' etc/passwd); do \
user="${userHome%%=*}"; \
home="${userHome#*=}"; \
home="./${home#/}"; \
if [ ! -d "$home" ]; then \
mkdir -p "$home"; \
chown "$user" "$home"; \
fi; \
done