-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create docker as root for user creation
- Loading branch information
Showing
6 changed files
with
33 additions
and
25 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,39 @@ | ||
#!/bin/bash | ||
|
||
DATA_OWNER=$(stat -c '%u' /data) | ||
set -e | ||
|
||
if [ "$DATA_OWNER" -ne "$UID" ]; then | ||
echo "Directory 'data' not owned by target user with $UID, instead owned by user with uid $DATA_OWNER" | ||
# check required variables | ||
if [ -z "$PUID" ]; then | ||
echo 'Environment variable $PUID not specified' | ||
exit 1 | ||
fi | ||
|
||
# create home folder | ||
export HOME="/home/$(id -u)" | ||
mkdir -p $HOME | ||
if [ -z "$GUID" ]; then | ||
echo 'Environment variable $PUID not specified' | ||
exit 1 | ||
fi | ||
|
||
# create astrid user and group | ||
if [ ! $(getent group astrid) ]; then | ||
groupadd --gid $GUID astrid | ||
echo "Group astrid with GID $GUID created." | ||
fi | ||
if [ ! $(getent passwd astrid) ]; then | ||
useradd --uid $PUID --gid $GUID --create-home --add-subids-for-system astrid | ||
echo "User astrid with UID $PUID created." | ||
fi | ||
|
||
# set ownership of /data to target user | ||
chown "$PUID:$GUID" /data | ||
|
||
# create needed files if missing | ||
mkdir -p /data/config /data/containers /data/log /data/repos /data/ssh | ||
su - astrid -c "mkdir -p /data/config /data/containers /data/log /data/repos /data/ssh" | ||
|
||
cp -n /app/config.ini.sample /data/config/config.ini | ||
cp -n /app/repos.ini.sample /data/config/repos.ini | ||
su - astrid -c "cp -n /app/config.ini.sample /data/config/config.ini" | ||
su - astrid -c "cp -n /app/repos.ini.sample /data/config/repos.ini" | ||
|
||
if [ $(ls "/data/ssh" | grep ".pub" | wc -l) -eq 0 ]; then | ||
ssh-keygen -t ed25519 -f /data/ssh/id_ed25519 | ||
su - astrid -c "ssh-keygen -t ed25519 -f /data/ssh/id_ed25519" | ||
fi | ||
|
||
python3 -u ./main | ||
su - astrid -c "python3 -u /app/main" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[fykos37] | ||
[email protected]:FYKOS/fykos37.git | ||
users=fykos,repo | ||
users=user | ||
image_version=latest | ||
build_usr=astrid | ||
build_cmd=make -k all |