|
#!/bin/bash |
|
|
|
set -x |
|
|
|
mkdir -p temp |
|
cd temp |
|
|
|
# Install prereqs |
|
|
|
sudo apt-get update |
|
sudo apt-get -y upgrade |
|
sudo apt-get -y install \ |
|
ca-certificates \ |
|
curl \ |
|
gnupg \ |
|
lsb-release \ |
|
unzip \ |
|
jq \ |
|
git \ |
|
gnupg \ |
|
software-properties-common |
|
|
|
# Install Docker Engine |
|
sudo mkdir -p /etc/apt/keyrings |
|
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg |
|
echo \ |
|
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ |
|
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null |
|
sudo apt-get update |
|
sudo apt-get install -y \ |
|
docker-ce \ |
|
docker-ce-cli \ |
|
containerd.io \ |
|
docker-compose-plugin |
|
sudo groupadd docker |
|
sudo usermod -aG docker $USER |
|
|
|
# Get latest AWS credentials from UDI API |
|
mkdir -p ~/.aws |
|
sudo cat << EOF | sudo tee /usr/local/bin/awsCreds.sh |
|
printf "[default]\naws_access_key_id=" > "${HOME}/.aws/credentials" |
|
curl -s 10.1.1.1/cloudAccounts | jq '.cloudAccounts[0]' | jq -r ' .apiKey' >> "${HOME}/.aws/credentials" |
|
printf "aws_secret_access_key=" >> "${HOME}/.aws/credentials" |
|
curl -s 10.1.1.1/cloudAccounts | jq '.cloudAccounts[0]' | jq -r ' .apiSecret' >> "${HOME}/.aws/credentials" |
|
printf "[default]\nregion=us-west-2" > "${HOME}/.aws/config" |
|
EOF |
|
|
|
sudo chmod +x /usr/local/bin/awsCreds.sh |
|
|
|
crontab -l > cron |
|
echo "@reboot /usr/local/bin/awsCreds.sh" >> cron |
|
crontab cron |
|
rm cron |
|
|
|
awsCreds.sh |
|
|
|
# Install AWS CLI |
|
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" |
|
unzip awscliv2.zip |
|
sudo ./aws/install |
|
|
|
# Install Terraform |
|
wget -O- https://apt.releases.hashicorp.com/gpg | \ |
|
gpg --dearmor | \ |
|
sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg |
|
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] \ |
|
https://apt.releases.hashicorp.com $(lsb_release -cs) main" | \ |
|
sudo tee /etc/apt/sources.list.d/hashicorp.list |
|
sudo apt update |
|
sudo apt-get -y install terraform |
|
|
|
# Install code-server |
|
export VERSION=4.4.0 |
|
curl -fOL "https://github.com/coder/code-server/releases/download/v${VERSION}/code-server_${VERSION}_amd64.deb" |
|
sudo dpkg -i "code-server_${VERSION}_amd64.deb" |
|
sudo systemctl enable --now code-server@${USER} |
|
|
|
mkdir -p ~/.config/code-server |
|
cat << 'EOF' > ~/.config/code-server/config.yaml |
|
bind-addr: 127.0.0.1:8080 |
|
auth: none |
|
cert: false |
|
EOF |
|
|
|
mkdir -p ~/.local/share/code-server/User |
|
cat << 'EOF' > ~/.local/share/code-server/User/settings.json |
|
{ |
|
"workbench.colorTheme": "GitHub Dark Default", |
|
"terminal.integrated.fontFamily": "MesloLGS NF", |
|
"security.workspace.trust.enabled": false, |
|
"workbench.editorAssociations": { |
|
"*.md": "vscode.markdown.preview.editor" |
|
}, |
|
"explorer.sortOrder": "type", |
|
"terminal.integrated.defaultProfile.linux": "zsh" |
|
} |
|
EOF |
|
|
|
# vscode extensions |
|
wget https://nightly.link/hangxingliu/vscode-nginx-conf-hint/actions/artifacts/304167943.zip |
|
unzip 304167943.zip |
|
curl -s https://api.github.com/repos/f5devcentral/vscode-f5/releases/latest | jq '.assets[0]' | jq -r '.browser_download_url' | wget -qi - |
|
code-server --install-extension vscode-nginx*.vsix |
|
code-server --install-extension vscode-f5*.vsix |
|
code-server --install-extension hashicorp.terraform |
|
code-server --install-extension GitHub.github-vscode-theme |
|
|
|
sudo systemctl restart --now code-server@${USER} |
|
|
|
sudo apt-get update && sudo apt-get -y install nginx libnginx-mod-http-subs-filter zsh |
|
|
|
# Install NGINX proxy |
|
sudo cat << 'EOF' | sudo tee /etc/nginx/sites-available/code-server |
|
server { |
|
listen 8081; |
|
location / { |
|
proxy_pass http://localhost:8080; |
|
proxy_set_header Accept-Encoding ""; |
|
proxy_set_header X-Real-IP $remote_addr; |
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
|
proxy_set_header Host $http_host; |
|
proxy_set_header X-NginX-Proxy true; |
|
sub_filter |
|
'</head>' |
|
'<link rel="stylesheet" type="text/css" href="/code-server/css/fonts.css"> |
|
</head>'; |
|
sub_filter |
|
'<meta http-equiv="Content-Security-Policy" content="' |
|
'<meta http-equiv="Content-Security-Policy" content=" |
|
style-src-elem * \'unsafe-inline\'; |
|
font-src * \'unsafe-inline\';'; |
|
sub_filter_once on; |
|
proxy_http_version 1.1; |
|
proxy_set_header Upgrade $http_upgrade; |
|
proxy_set_header Connection "upgrade"; |
|
proxy_redirect off; |
|
} |
|
location /code-server { |
|
autoindex on; |
|
root /var/www/html; |
|
} |
|
location /_static/src/browser/media { |
|
autoindex on; |
|
root /var/www/html/code-server; |
|
} |
|
location /manifest.json { |
|
autoindex on; |
|
root /var/www/html/code-server; |
|
} |
|
} |
|
|
|
EOF |
|
sudo ln -s /etc/nginx/sites-available/code-server /etc/nginx/sites-enabled/code-server |
|
|
|
# Install icons |
|
sudo mkdir -p /var/www/html/code-server/_static/src/browser/media |
|
sudo wget https://vscode.dev/static/stable/code-192.png -O /var/www/html/code-server/_static/src/browser/media/pwa-icon-192.png |
|
sudo wget https://vscode.dev/static/stable/code-192.png -O /var/www/html/code-server/_static/src/browser/media/pwa-icon-512.png |
|
sudo wget https://vscode.dev/static/stable/favicon.ico -O /var/www/html/code-server/_static/src/browser/media/favicon.ico |
|
|
|
# Install fonts |
|
sudo mkdir -p /var/www/html/code-server/fonts |
|
sudo wget https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/MesloLGS%20NF%20Regular.ttf -P /var/www/html/code-server/fonts |
|
sudo wget https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/MesloLGS%20NF%20Bold.ttf -P /var/www/html/code-server/fonts |
|
sudo wget https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/MesloLGS%20NF%20Italic.ttf -P /var/www/html/code-server/fonts |
|
sudo wget https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/MesloLGS%20NF%20Bold%20Italic.ttf -P /var/www/html/code-server/fonts |
|
sudo mkdir -p /var/www/html/code-server/css |
|
|
|
sudo cat << 'EOF' | sudo tee /var/www/html/code-server/css/fonts.css |
|
@font-face { |
|
font-family: "MesloLGS NF"; |
|
src: url("/code-server/fonts/MesloLGS%20NF%20Regular.ttf"); |
|
font-weight: normal; |
|
font-style: normal; |
|
} |
|
@font-face { |
|
font-family: "MesloLGS NF"; |
|
src: url("/code-server/fonts/MesloLGS%20NF%20Bold.ttf"); |
|
font-weight: bold; |
|
font-style: normal; |
|
} |
|
@font-face { |
|
font-family: "MesloLGS NF"; |
|
src: url("/code-server/fonts/MesloLGS%20NF%20Italic.ttf"); |
|
font-weight: normal; |
|
font-style: italic; |
|
} |
|
@font-face { |
|
font-family: "MesloLGS NF"; |
|
src: url("/code-server/fonts/MesloLGS%20NF%20Bold%20Italic.ttf"); |
|
font-weight: bold; |
|
font-style: italic; |
|
} |
|
EOF |
|
|
|
sudo cat << 'EOF' | sudo tee /var/www/html/code-server/manifest.json |
|
{ |
|
"name": "Visual Studio Code", |
|
"short_name": "Code", |
|
"start_url": ".", |
|
"display": "fullscreen", |
|
"description": "Run Code on a remote server.", |
|
"icons": [ |
|
{ |
|
"src": "./_static/src/browser/media/pwa-icon-192.png", |
|
"type": "image/png", |
|
"sizes": "192x192" |
|
}, |
|
{ |
|
"src": "./_static/src/browser/media/pwa-icon-512.png", |
|
"type": "image/png", |
|
"sizes": "512x512" |
|
} |
|
] |
|
} |
|
EOF |
|
|
|
sudo systemctl restart nginx |
|
|
|
mkdir -p ~/.zsh |
|
wget https://raw.githubusercontent.com/m-bers/udf-template/main/.p10k.zsh -P ~/.zsh |
|
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/.zsh/powerlevel10k |
|
|
|
cat << 'EOF' > ~/.zshrc |
|
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then |
|
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" |
|
fi |
|
source ~/.zsh/powerlevel10k/powerlevel10k.zsh-theme |
|
[[ ! -f ~/.zsh/.p10k.zsh ]] || source ~/.zsh/.p10k.zsh |
|
alias code="code-server" |
|
export EDITOR="code-server -w" |
|
EOF |
|
|
|
cd ~ |
|
rm -rf temp |