Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 33 additions & 30 deletions scripts/localscript.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,42 @@

# This script is run after the workspace is created


local_script(){

# Workspace root is $PWD at the start
WORK_DIR=$PWD
VSCODE_DIR="$WORK_DIR/.vscode"
DEVCONTAINER_JSON="$WORK_DIR/.devcontainer/devcontainer.json"

# Create patch directory in workspace root ($PWD at start)
PATCHDIR="$WORK_DIR/patches"
mkdir -p $PATCHDIR
mkdir -p $VSCODE_DIR

# Copy the which_r and set_build_r function definitions to .bashrc
cat $WORK_DIR/scripts/which_r.sh >> ~/.bashrc
cat $WORK_DIR/scripts/set_build_r.sh >> ~/.bashrc

# Copy over the welcome message script to be run when bash terminal starts
cat $WORK_DIR/scripts/welcome_msg.sh >> ~/.bashrc

#bash ~/.bashrc

# Remove git directory if it exists
#rm -rf .git

# copying vscode extension settings from devcontainer json to vscode settings json using jq
if [ -f "$DEVCONTAINER_JSON" ]; then
# Workspace root is $PWD at the start
WORK_DIR=$PWD
VSCODE_DIR="$WORK_DIR/.vscode"
DEVCONTAINER_JSON="$WORK_DIR/.devcontainer/devcontainer.json"

# Create patch directory in workspace root ($PWD at start)
PATCHDIR="$WORK_DIR/patches"
mkdir -p "$PATCHDIR"
mkdir -p "$VSCODE_DIR"

# Copy the which_r and set_build_r function definitions to .bashrc
cat "$WORK_DIR/scripts/which_r.sh" >> ~/.bashrc
cat "$WORK_DIR/scripts/set_build_r.sh" >> ~/.bashrc

# Copy over the welcome message script to be run when bash terminal starts
cat "$WORK_DIR/scripts/welcome_msg.sh" >> ~/.bashrc

# Install git-r tool to /usr/local/bin (already on PATH)
echo "Installing git-r tool..."
curl -L -o /tmp/git-r \
https://raw.githubusercontent.com/HenrikBengtsson/git-r/master/bin/git-r

if [ $? -eq 0 ]; then
chmod +x /tmp/git-r
sudo mv /tmp/git-r /usr/local/bin/git-r
echo "git-r installed successfully to /usr/local/bin/git-r"
else
echo "Failed to download git-r"
fi

# Copy VS Code settings from devcontainer.json to .vscode/settings.json
if [ -f "$DEVCONTAINER_JSON" ]; then
jq '.customizations.vscode.settings' "$DEVCONTAINER_JSON" > "$VSCODE_DIR/settings.json"
fi


fi
}


# Run the main function
local_script