Skip to content

Commit

Permalink
make entrypoint helpers exit non-critical helper funcs quietly
Browse files Browse the repository at this point in the history
  • Loading branch information
usrbinkat committed Feb 7, 2024
1 parent cce6c09 commit ad9fc14
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 23 deletions.
46 changes: 26 additions & 20 deletions .github/docker/slim/bin/devcontainer-links
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,35 @@

# Change ownership of all items in /workspaces to the current user
user="$(id -u)"
sudo chown "${user}" /workspaces/* 2>/dev/null

# Iterate over directories in /workspaces
for dir in /workspaces/*; do
# Check if it's a directory
if [[ -d "${dir}" ]]; then
# Extract the directory name
dir_name=$(basename "${dir}")

# Check if a symlink already exists in the home directory
if [[ -L "${HOME}/${dir_name}" ]]; then
# Remove the existing symlink if it exists
rm "${HOME}/${dir_name}"
elif [[ -e "${HOME}/${dir_name}" ]]; then
# Skip if it's not a symlink (to avoid destructive actions on actual directories or files)
echo "Skipping ${HOME}/${dir_name}, as it's not a symlink."
continue
run_links() {

sudo chown "${user}" /workspaces/* 2>/dev/null

for dir in /workspaces/*; do
# Check if it's a directory
if [[ -d "${dir}" ]]; then
# Extract the directory name
dir_name=$(basename "${dir}")

# Check if a symlink already exists in the home directory
if [[ -L "${HOME}/${dir_name}" ]]; then
# Remove the existing symlink if it exists
rm "${HOME}/${dir_name}"
elif [[ -e "${HOME}/${dir_name}" ]]; then
# Skip if it's not a symlink (to avoid destructive actions on actual directories or files)
echo "Skipping ${HOME}/${dir_name}, as it's not a symlink."
continue
fi

# Create a new symbolic link
ln -s "${dir}" "${HOME}/${dir_name}"
fi
done
}

# Create a new symbolic link
ln -s "${dir}" "${HOME}/${dir_name}"
fi
done
run_links 2>/dev/null || true

# Allow direnv to set environment variables
direnv allow 2>/dev/null
direnv allow 2>/dev/null || true
9 changes: 6 additions & 3 deletions .github/docker/slim/bin/entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,11 @@ run_ttyd() {

# Base Variables
export dir_platform=".platform"
export ssh_host_identity_path="/home/${USER}/${dir_platform}/secrets/ssh/host"
export ssh_user_identity_path="/home/${USER}/${dir_platform}/secrets/ssh/user"
export ssh_host_identity_path="/home/$USER/$dir_platform/secrets/ssh/host"
export ssh_user_identity_path="/home/$USER/$dir_platform/secrets/ssh/user"

# Validate environment variables
if [ -z "${USER}" ]; then
if [ -z "$USER" ]; then
echo "Error: USER environment variable not set"
exit 1
fi
Expand Down Expand Up @@ -204,4 +204,7 @@ else
fi

run_tmux_keepalive "pulumi" > /dev/null 2>&1 &

sleep 5 && devcontainer-links || true

sleep infinity

0 comments on commit ad9fc14

Please sign in to comment.