Skip to content

Commit

Permalink
fix: Configure script
Browse files Browse the repository at this point in the history
Signed-off-by: Schubert Anselme <[email protected]>
  • Loading branch information
sanselme committed Nov 9, 2024
1 parent 4a17062 commit 7fff95a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 18 deletions.
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,13 @@ fabric.properties
# Project files
.*
.env
!.*.json
!.*.yaml
!.commitlintrc
!.devcontainer/
!.editorconfig
!.github/
!.gitignore
!.gitmodules
!.trunk/
!.*.yaml
!.*.json
!example.env
44 changes: 28 additions & 16 deletions scripts/configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ if [[ -n $(command -v "usermod") ]]; then

# note: always set the user to "devcontainer" if it exists
if [[ "devcontainer" == "$(whoami)" ]]; then
USER="devcontainer"
user="devcontainer"
else
USER="$(whoami)"
user="$(whoami)"
fi

for g in "${groups[@]}"; do
sudo usermod -aG "${g}" "${USER}"
sudo usermod -aG "${g}" "${user}"
done

id "${USER}"
id "${user}"
fi

# environment
Expand All @@ -50,28 +50,40 @@ if [[ ! -d "${HOME}/.oh-my-zsh" ]]; then
rm -f /tmp/ohmyzsh-install.sh
fi

ln -sf \
modules/dotfiles/.bashrc \
modules/dotfiles/.zshrc \
modules/dotfiles/.commitlintrc \
modules/dotfiles/.idea \
modules/dotfiles/.vscode \
.trunk/configs/.* \
.

ITEMS=(
items=(
"modules/dotfiles/.devcontainer"
"modules/dotfiles/.editorconfig"
"modules/dotfiles/.gitignore"
"modules/dotfiles/.ssh"
"modules/dotfiles/.trunk"
"modules/dotfiles/compose-dev.yaml"
)
for ITEM in "${ITEMS[@]}"; do
for item in "${items[@]}"; do
# copy if not present in the root directory
ls -l $(basename "${ITEM}") >/dev/null 2>&1 || cp -r "${ITEM}" .
ls -l $(basename "${item}") >/dev/null 2>&1 || cp -r "${item}" .
done

ln -sf \
modules/dotfiles/.bashrc \
modules/dotfiles/.zshrc \
modules/dotfiles/.commitlintrc \
modules/dotfiles/.idea \
modules/dotfiles/.vscode \
.trunk/configs/.* \
.

if [[ -d modules/tooling ]]; then
mkdir -p config hack scripts tools

cp -f modules/tooling/.gitignore .

ln -sf modules/tooling/config/* config/
ln -sf modules/tooling/hack/* hack/
ln -sf modules/tooling/scripts/* scripts/
ln -sf modules/tooling/tools/* tools/
fi

# shell
sudo chsh -s "$(command -v zsh)" "${USER}"

# trunk.io
Expand Down

0 comments on commit 7fff95a

Please sign in to comment.