Skip to content

Commit

Permalink
Add default shared services config
Browse files Browse the repository at this point in the history
  • Loading branch information
manics committed Mar 6, 2023
1 parent 765e0e9 commit 3a97ae7
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 14 deletions.
1 change: 1 addition & 0 deletions configs/hic-ubuntu-22.04-desktop-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ modules:
- ssms
- utils
- vscode
- shared-services-config

files:
- src: conda-envs/example.yml
Expand Down
1 change: 1 addition & 0 deletions configs/hic-windows-2019-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ modules:
- ssms
- vscode
- autohibernate
- shared-services-config

files:
- src: conda-envs/example.yml
Expand Down
7 changes: 0 additions & 7 deletions modules/rstudio.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ Start-Process C:\Tools\RTools.exe -ArgumentList "/VERYSILENT" -NoNewWindow -Wait
$RConfig = @"
# Set the default help type
options(help_type="html")
# HIC TRE R Repository
local({r <- getOption("repos")
r["CRAN"] <- "http://cran.hic-tre.dundee.ac.uk/"
options(repos=r)
})
# Set timezone
Sys.setenv(TZ='Europe/London')
"@
Expand Down
7 changes: 0 additions & 7 deletions modules/rstudio.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@ fi
cat > "$HOME/.Rprofile" <<EOF
# Set the default help type
options(help_type="html")
# HIC TRE R Repository
local({r <- getOption("repos")
r["CRAN"] <- "http://cran.hic-tre.dundee.ac.uk/"
options(repos=r)
})
# Set timezone
Sys.setenv(TZ='Europe/London')
EOF
Expand Down
28 changes: 28 additions & 0 deletions modules/shared-services-config.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Configure the workspace to access shared services

if (-not $env:SHARED_SERVICES_DOMAIN) {
$env:SHARED_SERVICES_DOMAIN = "tre.internal"
}
if (-not $env:SHARED_SERVICES_DNS) {
$env:SHARED_SERVICES_DNS = "10.253.0.253"
}

$condarc = @"
channels:
- conda-forge
channel_alias: http://conda.${env:SHARED_SERVICES_DOMAIN}/
"@
Set-Content -Path C:\Users\Administrator\.condarc $condarc

$RConfig = @"
# TRE CRAN repository
local({r <- getOption("repos")
r["CRAN"] <- "http://cran.${env:SHARED_SERVICES_DOMAIN}/"
options(repos=r)
})
"@
Get-ChildItem "C:\Program Files\R" -Directory | ForEach-Object {
Add-Content "$($_.FullName)\etc\Rprofile.site" $RConfig
}

Add-DnsClientNrptRule -Namespace ".${env:SHARED_SERVICES_DOMAIN}" -NameServers $env:SHARED_SERVICES_DNS
32 changes: 32 additions & 0 deletions modules/shared-services-config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

set -eu

if [ -z "$SHARED_SERVICES_DOMAIN" ]; then
SHARED_SERVICES_DOMAIN="tre.internal"
fi
if [ -z "$SHARED_SERVICES_DNS" ]; then
SHARED_SERVICES_DNS="10.253.0.253"
fi

cat <<EOF > "$HOME/.condarc"
channels:
- conda-forge
channel_alias: "http://conda.${SHARED_SERVICES_DOMAIN}/"
EOF

cat <<EOF >> "$HOME/.Rprofile"
# TRE CRAN repository
local({r <- getOption("repos")
r["CRAN"] <- "http://cran.${SHARED_SERVICES_DOMAIN}/"
options(repos=r)
})
EOF

# The following sets the global DNS server which is used for entries in
# the Domains key when prefixed with a tilde. The Link name server (set
# by DHCP) is used for all other queries, allowing SSM endpoints etc to
# still be resolved within the VPC.
echo "DNS=${SHARED_SERVICES_DNS}" | sudo tee -a /etc/systemd/resolved.conf
echo "Domains=~${SHARED_SERVICES_DOMAIN}" | sudo tee -a /etc/systemd/resolved.conf
sudo systemctl restart systemd-resolved

0 comments on commit 3a97ae7

Please sign in to comment.