Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support default user is not /etc/passwd 's last line #47

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions lxd.patch
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
diff --git a/images/ubuntu/assets/post-gen/environment-variables.sh b/images/ubuntu/assets/post-gen/environment-variables.sh
index 975c8a4a..016995a1 100644
--- a/images/ubuntu/assets/post-gen/environment-variables.sh
+++ b/images/ubuntu/assets/post-gen/environment-variables.sh
@@ -2,5 +2,5 @@

# Replace $HOME with the default user's home directory for environmental variables related to the default user home directory

-homeDir=$(cut -d: -f6 /etc/passwd | tail -1)
-sed -i "s|\$HOME|$homeDir|g" /etc/environment
\ No newline at end of file
+homeDir=$(cut -d: -f1,6 /etc/passwd | grep "runner:" | cut -d: -f2)
+sed -i "s|\$HOME|$homeDir|g" /etc/environment
diff --git a/images/ubuntu/assets/post-gen/systemd-linger.sh b/images/ubuntu/assets/post-gen/systemd-linger.sh
index 294c8f1b..bfc28952 100644
--- a/images/ubuntu/assets/post-gen/systemd-linger.sh
+++ b/images/ubuntu/assets/post-gen/systemd-linger.sh
@@ -1,5 +1,5 @@
#!/bin/bash

# Enable user session on boot, not on login
-UserId=$(cut -d: -f3 /etc/passwd | tail -1)
+UserId=$(cut -d: -f1,3 /etc/passwd | grep "runner:" | cut -d: -f2)
loginctl enable-linger $UserId
diff --git a/images/ubuntu/scripts/build/configure-environment.sh b/images/ubuntu/scripts/build/configure-environment.sh
index 3c149295..19097573 100644
--- a/images/ubuntu/scripts/build/configure-environment.sh
Expand Down
Loading