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

Enable setting a hostname after creating users #18

Merged
merged 2 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
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
18 changes: 6 additions & 12 deletions yocto-build-env/s6-overlay/s6-rc.d/lock-manager/run
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,23 @@ LOCKFILE=/tmp/balena/updates.lock

while true; do
(
# request an exclusive lock in non-blocking mode
flock -n 200 || exit 0

# check for active sessions
while last | grep -q "still logged in"; do

# create the lockfile
touch $LOCKFILE

# create a file descriptor over the given lockfile
exec {fd}<>${LOCKFILE}

# request an exclusive lock in non-blocking mode
flock -n $fd || exit 0

echo "Updates are locked while sessions are active..."
last | grep "still logged in"

# wait 30 seconds before checking again
# updates are locked during this time
sleep 30

done
)
) 200>$LOCKFILE

# remove the lockfile (this should be unecessary?)
# remove the lockfile
# FIXME: why is this required when the lock is already released?
rm -f $LOCKFILE

# wait 5 seconds before checking again
Expand Down
7 changes: 7 additions & 0 deletions yocto-build-env/s6-overlay/scripts/addusers
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,10 @@ for user_id in ${user_ids}; do
# fetch the user's ssh keys from github
fetch_ssh_keys "${name}" "$(eval echo ~"${name}")" || true
done

if [ -n "${SET_HOSTNAME:-}" ]; then
# set the desired hostname
echo "${SET_HOSTNAME}" > /etc/hostname
hostname -F /etc/hostname
hostname
fi