-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add start_local_env.sh script.sh
- Loading branch information
1 parent
48c3e59
commit 78bb6d8
Showing
1 changed file
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/bin/sh | ||
|
||
# remember to chmod +x start_local_env.sh | ||
kotorekisteri_start_tmux() { | ||
SESS_NAME=kotorekisteri | ||
PANE1=kotorekisteri | ||
REPO_ROOT=${1:-'.'} | ||
|
||
( | ||
cd $REPO_ROOT | ||
|
||
# Install dependencies | ||
echo "Installing dependencies..." | ||
mise install | ||
|
||
# Use old session if exists | ||
tmux has-session -t $SESS_NAME 2>/dev/null | ||
if [ $? -eq 0 ]; then | ||
tmux attach -t $SESS_NAME | ||
# TODO: Instead of return, kill the old session. | ||
return | ||
fi | ||
|
||
# If there is no session... | ||
# Start a new tmux session and detach immediately | ||
# Window 0:zsh | ||
echo "Starting new tmux session..." | ||
tmux new-session -d -s $SESS_NAME | ||
|
||
# Window 0:database | ||
WINDOW="database" | ||
# database: left pane (docker running) | ||
tmux rename-window -t $SESS_NAME:0 "$WINDOW" | ||
tmux send-keys -t $SESS_NAME:"$WINDOW.0" "open -a \"Docker\"" C-m | ||
tmux send-keys -t $SESS_NAME:"$WINDOW.0" "docker compose up" C-m | ||
|
||
# database: right pane (flyway migrate) | ||
tmux split-window -h -t $SESSION:"$WINDOW" | ||
tmux send-keys -t $SESS_NAME:"$WINDOW.1" "(cd server && | ||
sleep 5 && echo \"10 seconds left to run migrations...\" && | ||
sleep 5 && echo \"05 seconds left to run migrations...\" && | ||
./mvnw flyway:migrate)" C-m | ||
|
||
# Window 1:idea | ||
WINDOW="idea" | ||
tmux new-window -t $SESS_NAME -n "idea" | ||
tmux send-keys -t $SESS_NAME:"idea" "idea ." C-m | ||
|
||
# Window 2:springboot | ||
WINDOW="springboot" | ||
tmux new-window -t $SESS_NAME -n "$WINDOW" | ||
tmux send-keys -t $SESS_NAME:"$WINDOW" "cd server && sleep 5" C-m | ||
tmux send-keys -t $SESS_NAME:"$WINDOW" "mvn clean install" C-m | ||
tmux send-keys -t $SESS_NAME:"$WINDOW" "mvn package" C-m | ||
tmux send-keys -t $SESS_NAME:"$WINDOW" "./mvnw spring-boot:run" C-m | ||
|
||
# Window 3:workspace | ||
WINDOW="workspace" | ||
tmux new-window -t $SESS_NAME -n "$WINDOW" | ||
tmux send-keys -t $SESS_NAME:"$WINDOW" "git log --oneline --decorate=full --graph --all --oneline" C-m | ||
tmux split-window -h -t $SESSION:"$WINDOW" | ||
tmux send-keys -t $SESS_NAME:"$WINDOW.1" "ls -la" C-m | ||
tmux send-keys -t $SESS_NAME:"$WINDOW.1" "git status" C-m | ||
|
||
tmux attach | ||
) | ||
} | ||
|
||
kotorekisteri_start_tmux $1 |