Created
December 21, 2014 00:17
-
-
Save billryan/08904a357a7e1f53f099 to your computer and use it in GitHub Desktop.
user mapping for docker shared volume
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export ORIG_PASSWD=$(grep hexo /etc/passwd) | |
export ORIG_UID=$(echo $ORIG_PASSWD | cut -f3 -d:) | |
export ORIG_GID=$(echo $ORIG_PASSWD | cut -f4 -d:) | |
# set NEW_UID with ORIG_UID if MAP_UID not exist | |
export NEW_UID=${MAP_UID:=$ORIG_UID} | |
export NEW_GID=${MAP_GID:=$ORIG_GID} | |
ORIG_HOME=$(echo $ORIGPASSWD | cut -f6 -d:) | |
sed -i -e "s/:$ORIG_UID:$ORIG_GID:/:$NEW_UID:$NEW_GID:/" /etc/passwd | |
sed -i -e "s/hexo:x:$ORIG_GID:/hexo:x:$NEW_GID:/" /etc/group | |
exec su - hexo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment