Skip to content

Commit

Permalink
adding lacework cli
Browse files Browse the repository at this point in the history
  • Loading branch information
robinmordasiewicz committed Feb 18, 2025
1 parent 0d47382 commit 0c72ed0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/lacework-cli/devcontainer-feature.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
"onCreateCommand": {
"lacework-cli-persistence-setup": "/usr/local/share/lacework-cli/scripts/oncreate.sh"
},
"version": "0.0.16"
"version": "0.0.17"
}
16 changes: 12 additions & 4 deletions src/lacework-cli/oncreate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,19 @@ fi
lacework completion zsh >"${HOME}/.oh-my-zsh/completions/_lacework"

# If a .lacework.toml file exists in the home directory, move it; otherwise, create an empty one
if [ -f "${HOME}/.lacework.toml" ]; then
if [ -L "${HOME}/.lacework.toml" ]; then
toml_link=$(readlink "${HOME}/.lacework.toml")
if [ "$toml_link" = "$TARGET/.lacework.toml" ]; then
echo "Symlink already exists and points to the correct target: $TARGET/.lacework.toml"
else
echo "Symlink exists but points to $toml_link. Recreating symlink..."
rm "${HOME}/.lacework.toml"
ln -s "${TARGET}/.lacework.toml" "${HOME}/.lacework.toml"
fi
elif [ -f "${HOME}/.lacework.toml" ]; then
mv "${HOME}/.lacework.toml" "${TARGET}/.lacework.toml"
else
touch "${TARGET}/.lacework.toml"
fi
touch "${TARGET}/.lacework.toml"

# Create a symlink from the target .lacework.toml to the home directory
ln -sf "${TARGET}/.lacework.toml" "${HOME}/.lacework.toml"
Expand Down Expand Up @@ -48,7 +56,7 @@ create_symlink() {
fi
shopt -s dotglob
if [ "$(ls -A "$LINK")" ]; then
mv "$LINK"/* "$TARGET"/ 2>/dev/null
mv "$LINK"/* "$TARGET"/
fi
shopt -u dotglob
rm -rf "$LINK"
Expand Down

0 comments on commit 0c72ed0

Please sign in to comment.