Skip to content

Commit e06900e

Browse files
feature options.
1 parent 0f95aa9 commit e06900e

File tree

3 files changed

+128
-60
lines changed

3 files changed

+128
-60
lines changed

src/devcontainers/base/src/.devcontainer/nhsnotify/devcontainer-feature.json

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
{
22
"dependsOn": {
3-
"ghcr.io/devcontainers/features/python:1.7.1": {
3+
"ghcr.io/devcontainers/features/python:1.7.1": {
44
"version": "3.13.8",
55
"installTools": true
6-
},
7-
6+
},
87
"ghcr.io/devcontainers/features/aws-cli:1.1.2": {
98
"version": "2.31.18"
109
},
@@ -46,5 +45,17 @@
4645
"name": "NHS Notify",
4746
"postCreateCommand": "zsh /postcreatecommand.sh",
4847
"postStartCommand": "zsh /poststartcommand.sh",
49-
"version": "1.0.1"
48+
"version": "1.0.1",
49+
"options": {
50+
"updateFromTemplate": {
51+
"type": "boolean",
52+
"description": "Update from template",
53+
"default": true
54+
},
55+
"showWelcome": {
56+
"type": "boolean",
57+
"description": "Show welcome message",
58+
"default": true
59+
}
60+
}
5061
}
Lines changed: 107 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
#!/bin/bash
22
CURRENT_DIR=$(pwd)
3-
4-
echo "copying defaults"
5-
echo "getting nhse repo template"
6-
echo "Cloning $REPO into $DEST"
3+
update_from_template="${UPDATEFROMTEMPLATE:-true}"
74

85
REPO=https://github.com/NHSDigital/nhs-notify-repository-template.git
96
DEST=$HOME/nhsengland/repository-template
107
CURRENT_TIMESTAMP=$(date +%Y%m%d%H%M%S)
118
CHECKOUT_BRANCH="devcontainer-base"
129
UPDATE_BRANCH="updating-the-default-files-$CURRENT_TIMESTAMP"
1310

14-
mkdir -p $DEST
15-
echo "created destination directory $DEST"
16-
echo "Cloning repository from $REPO to $DEST"
17-
git clone -b $CHECKOUT_BRANCH $REPO $DEST
18-
echo "cloned repository $REPO branch $CHECKOUT_BRANCH to $DEST"
11+
get_repo_template(){
12+
echo "copying defaults"
13+
echo "getting nhse repo template"
14+
echo "Cloning $REPO into $DEST"
15+
mkdir -p $DEST
16+
echo "created destination directory $DEST"
17+
echo "Cloning repository from $REPO to $DEST"
18+
git clone -b $CHECKOUT_BRANCH $REPO $DEST
19+
echo "cloned repository $REPO branch $CHECKOUT_BRANCH to $DEST"
1920

20-
CURRENT_BRANCH=$(git symbolic-ref --short HEAD)
21-
echo "current branch is $CURRENT_BRANCH"
22-
git switch -C $UPDATE_BRANCH
21+
CURRENT_BRANCH=$(git symbolic-ref --short HEAD)
22+
echo "current branch is $CURRENT_BRANCH"
23+
git switch -C $UPDATE_BRANCH
24+
}
2325

2426
copy_folder_if_not_exists(){
2527
local FOLDER=$1
@@ -29,47 +31,96 @@ copy_folder_if_not_exists(){
2931
echo "Copied $FOLDER" \
3032
|| echo "Not copying $FOLDER, already exist"
3133
}
32-
copy_folder_if_not_exists ".github"
33-
copy_folder_if_not_exists "docs"
34-
copy_folder_if_not_exists "infrastructure"
35-
copy_folder_if_not_exists ".vscode"
36-
37-
\cp -rf $DEST/scripts ./
38-
\cp -f $DEST/Makefile ./
39-
\cp -f $DEST/.tool-versions ./
40-
\cp -f $DEST/.editorconfig ./
41-
\cp -f $DEST/.gitattributes ./
42-
\cp -f $DEST/.gitignore ./
43-
\cp -f $DEST/.gitleaksignore ./
44-
\cp --update=none $DEST/VERSION ./
45-
\cp --update=none $DEST/README.md ./
46-
\cp --update=none $DEST/LICENCE.md ./
47-
48-
echo "$REPO template complete"
49-
50-
echo "reload shell"
51-
source ~/.zshrc
52-
echo "reloaded shell"
53-
54-
export PATH="${ASDF_DATA_DIR:-$HOME/.asdf}/shims:$PATH"
55-
# echo "running make config"
56-
# make config
57-
# echo "make config complete"
58-
59-
cd $CURRENT_DIR
60-
61-
echo "sorting certs"
62-
sudo cp -r --update=none /home/ca-certificates/. /usr/local/share/ca-certificates
63-
sudo update-ca-certificates
64-
echo "sorted certs"
65-
66-
67-
echo "configuring ohmyzsh"
68-
echo 'export PATH="${ASDF_DATA_DIR:-$HOME/.asdf}/shims:$PATH"' >> ~/.zshrc
69-
sed -i "/plugins=/c\plugins=(git ssh-agent sudo terraform dirhistory)" ~/.zshrc
70-
cat ~/.zshrc
71-
echo "configured ohmyzsh"
72-
73-
echo "adding gpg tty to zshrc"
74-
echo 'export GPG_TTY=$(tty)' >> ~/.zshrc
75-
echo "added gpg tty to zshrc"
34+
35+
copy_folder_overwrite(){
36+
local FOLDER=$1
37+
echo "copying folder $FOLDER"
38+
\cp -rf $DEST/$FOLDER ./
39+
echo "Copied $FOLDER"
40+
}
41+
42+
copy_file_overwrite(){
43+
local FILE=$1
44+
echo "copying file $FILE"
45+
\cp -f $DEST/$FILE ./
46+
echo "Copied $FILE"
47+
}
48+
49+
copy_file_dont_overwrite(){
50+
local FILE=$1
51+
echo "checking for file $FILE"
52+
\cp --update=none $DEST/$FILE ./
53+
echo "Copied $FILE if it did not exist"
54+
}
55+
56+
update_from_template(){
57+
copy_folder_if_not_exists ".github"
58+
copy_folder_if_not_exists "docs"
59+
copy_folder_if_not_exists "infrastructure"
60+
copy_folder_if_not_exists ".vscode"
61+
62+
copy_folder_overwrite "scripts"
63+
64+
copy_file_overwrite "Makefile"
65+
copy_file_overwrite ".tool-versions"
66+
copy_file_overwrite ".editorconfig"
67+
copy_file_overwrite ".gitattributes"
68+
copy_file_overwrite ".gitignore"
69+
copy_file_overwrite ".gitleaksignore"
70+
71+
copy_file_dont_overwrite "VERSION"
72+
copy_file_dont_overwrite "README.md"
73+
copy_file_dont_overwrite "LICENCE.md"
74+
75+
echo "$REPO template update complete"
76+
}
77+
78+
update_from_template_if_enabled(){
79+
if [ "${update_from_template}" == "true" ]; then
80+
echo "Updating from template as per configuration"
81+
get_repo_template
82+
update_from_template
83+
else
84+
echo "Skipping update from template as per configuration"
85+
fi
86+
}
87+
88+
reload_shell(){
89+
echo "reload shell"
90+
source ~/.zshrc
91+
echo "reloaded shell"
92+
}
93+
94+
add_asdf_to_path(){
95+
echo "adding asdf to path"
96+
export PATH="${ASDF_DATA_DIR:-$HOME/.asdf}/shims:$PATH"
97+
echo "added asdf to path"
98+
}
99+
100+
sort_certs(){
101+
sudo cp -r --update=none /home/ca-certificates/. /usr/local/share/ca-certificates
102+
sudo update-ca-certificates
103+
echo "sorted certs"
104+
}
105+
106+
configure_ohmyzsh(){
107+
echo "configuring ohmyzsh"
108+
echo 'export PATH="${ASDF_DATA_DIR:-$HOME/.asdf}/shims:$PATH"' >> ~/.zshrc
109+
sed -i "/plugins=/c\plugins=(git ssh-agent sudo terraform dirhistory)" ~/.zshrc
110+
cat ~/.zshrc
111+
echo "configured ohmyzsh"
112+
}
113+
114+
add_gpg_tty_to_zshrc(){
115+
echo "adding gpg tty to zshrc"
116+
echo 'export GPG_TTY=$(tty)' >> ~/.zshrc
117+
echo "added gpg tty to zshrc"
118+
}
119+
120+
update_from_template_if_enabled
121+
reload_shell
122+
add_asdf_to_path
123+
sort_certs
124+
configure_ohmyzsh
125+
add_gpg_tty_to_zshrc
126+
cd $CURRENT_DIR

src/devcontainers/base/src/.devcontainer/nhsnotify/welcome.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#!/bin/bash
22

3+
# Check if SHOWWELCOME is set to true, exit if not
4+
show_welcome="${SHOWWELCOME:-true}"
5+
if [ "${show_welcome}" != "true" ]; then
6+
exit 0
7+
fi
8+
39
# Configuration
410
WEATHER_LOCATION="Leeds, UK" # Change this to any location
511

0 commit comments

Comments
 (0)