Skip to content

Commit

Permalink
Merge pull request #18 from balena-os/kyle/set-hostname
Browse files Browse the repository at this point in the history
Enable setting a hostname after creating users
  • Loading branch information
flowzone-app[bot] authored Nov 22, 2023
2 parents 74523b8 + 5200443 commit 14cd14e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
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

0 comments on commit 14cd14e

Please sign in to comment.