-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from jpfulton:linux-dev-setup
Linux-dev-setup
- Loading branch information
Showing
11 changed files
with
284 additions
and
25 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
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,53 @@ | ||
# Setup a Linux Development Server | ||
|
||
In this guide, a Linux development server will be created with the following | ||
features: | ||
|
||
- A minimal installation of Gnome Desktop | ||
- An xRDP server allowing access to the desktop environment using an RDP client | ||
- Git | ||
- Nodejs v18 | ||
- Nodejs Corepack Enabled | ||
- Yarn package manager | ||
- .NET 7 SDK | ||
- Google Chrome | ||
- VS Code | ||
|
||
## Install a Local RDP Client | ||
|
||
For macOS, use the App Store to install the | ||
[Microsoft Remote Desktop Client](https://apps.apple.com/us/app/microsoft-remote-desktop/id1295203466?mt=12). | ||
|
||
## Create a Linux Development Server | ||
|
||
From the root of this repository navigate to the control scripts folder in | ||
a terminal with the command: | ||
|
||
```bash | ||
cd scripts | ||
``` | ||
|
||
The next command creates a Linux development server with the features listed | ||
above. An account name and initial randomly generated password will be securely transferred | ||
to a deployment outputs folder in your local account's home folder in file named | ||
`dev-users.txt`. The output folder will be located in the current local | ||
user's home folder and will be labeled `deployment-outputs-{UUID}`. Output lines | ||
at the end of the script will identify this folder. | ||
|
||
Instead of selecting the default virtual machine size, select a larger version | ||
for this installation: `Standard_DS2_v2`. A two core instance with a larger RAM | ||
profile will make the system more responsive for the desktop environment. | ||
|
||
```bash | ||
./create-linux-server.sh -d personal-network linux-dev | ||
``` | ||
|
||
## Log into the Server via RDP | ||
|
||
Open the Microsoft Remote Desktop App, and from the **Connections** menu select | ||
**Add PC**. In the **Add PC** dialog, enter `linux-dev.yourprivatednszonehere.com` as | ||
the PC name. In the User account drop down, select **Add a User Account**, in the next | ||
step enter the credentials found in `dev-users.txt` within the deployment outputs folder. | ||
Select **Add** and then select **Add** in the Add PC dialog accepting the default settings | ||
for the connection. The new machine will be visible in the main application window. Double | ||
click the connection to log into the Linux server. |
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,4 @@ | ||
# dev-tools | ||
|
||
Scripts in this folder install a Gnome Desktop environment and | ||
developer tools on the target virtual machine. |
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,31 @@ | ||
#!/usr/bin/env bash | ||
|
||
DEPLOYMENT_OUTPUT_FILE="dev-users.txt"; | ||
|
||
if [ "$#" -ne 1 ] | ||
then | ||
echo "ERROR: This script requires one argument. Exiting..."; | ||
echo "INFO: Required argument one: Admin user name."; | ||
echo; | ||
|
||
exit 1; | ||
fi | ||
|
||
ADMIN_USERNAME="$1"; | ||
|
||
DEV_USER="${ADMIN_USERNAME}-dev"; | ||
DEV_USER_PASS="$(openssl rand -base64 12)"; # generate random password | ||
|
||
sudo adduser --disabled-password --gecos "Development User" $DEV_USER; | ||
sudo echo "${DEV_USER}:${DEV_USER_PASS}" | sudo chpasswd; | ||
|
||
# Add dev user to sudoers | ||
SUDOERS_FILE="/etc/sudoers.d/${DEV_USER}"; | ||
echo -n "${DEV_USER} ALL=(root) NOPASSWD:ALL" | sudo tee $SUDOERS_FILE > /dev/null; | ||
|
||
# Create a deployment output file with dev users and password for secure transfer to | ||
# the control workstation later | ||
touch $DEPLOYMENT_OUTPUT_FILE; | ||
echo "Developer Users:" > $DEPLOYMENT_OUTPUT_FILE; | ||
echo "" >> $DEPLOYMENT_OUTPUT_FILE; | ||
echo "${DEV_USER}:${DEV_USER_PASS}" >> $DEPLOYMENT_OUTPUT_FILE; |
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,4 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Enable corepack to support yarn upgrades among other things | ||
sudo corepack enable; |
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,7 @@ | ||
#!/usr/bin/env bash | ||
|
||
DEBIAN_FRONTEND="noninteractive"; | ||
|
||
wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb; | ||
chmod a+w ./google-chrome-stable_current_amd64.deb; | ||
sudo apt-get install ./google-chrome-stable_current_amd64.deb -y; |
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,25 @@ | ||
#!/usr/bin/env bash | ||
|
||
BASE_REPO_URL="https://raw.githubusercontent.com/jpfulton/example-linux-configs/main"; | ||
XRDP_CONFIG_DIR="/etc/xrdp/"; | ||
XRDP_WM_STARTUP_SCRIPT="startwm.sh"; | ||
|
||
DEBIAN_FRONTEND="noninteractive"; | ||
sudo -E apt-get update; | ||
|
||
# Install a minimal version of Gnome Desktop | ||
# This step essentially upgrades from Ubuntu Server version to a minimal Ubuntu Desktop version | ||
# X11 is a dependency | ||
sudo -E apt-get install ubuntu-desktop-minimal -y; | ||
|
||
# Install xRDP server | ||
sudo -E apt-get install xrdp -y; | ||
|
||
# Update xRDP start up script to provide traditional Gnome experience | ||
sudo wget -q ${BASE_REPO_URL}${XRDP_CONFIG_DIR}${XRDP_WM_STARTUP_SCRIPT}; | ||
sudo chmod a+x ./${XRDP_WM_STARTUP_SCRIPT}; | ||
sudo mv ./${XRDP_WM_STARTUP_SCRIPT} ${XRDP_CONFIG_DIR}${XRDP_WM_STARTUP_SCRIPT}; | ||
|
||
# Open firewall to RDP port | ||
sudo ufw allow 3389/tcp; | ||
sudo ufw status numbered; |
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,38 @@ | ||
#!/usr/bin/env bash | ||
|
||
DEBIAN_FRONTEND="noninteractive"; | ||
|
||
# Purge old packages | ||
sudo apt-get remove 'dotnet.*' -y; | ||
sudo apt-get remove 'aspnet.*' -y; | ||
|
||
# Get Ubuntu version | ||
declare repo_version=$(if command -v lsb_release &> /dev/null; then lsb_release -r -s; else grep -oP '(?<=^VERSION_ID=).+' /etc/os-release | tr -d '"'; fi); | ||
|
||
# Download Microsoft signing key and repository | ||
wget -q https://packages.microsoft.com/config/ubuntu/$repo_version/packages-microsoft-prod.deb -O packages-microsoft-prod.deb; | ||
|
||
# Install Microsoft signing key and repository | ||
sudo dpkg -i packages-microsoft-prod.deb; | ||
|
||
# Clean up | ||
rm packages-microsoft-prod.deb; | ||
|
||
# Establish preferences for MS feed | ||
sudo sh -c "cat > /etc/apt/preferences.d/dotnet <<'EOF' | ||
Package: dotnet* | ||
Pin: origin packages.microsoft.com | ||
Pin-Priority: 1001 | ||
EOF"; | ||
|
||
sudo sh -c "cat > /etc/apt/preferences.d/aspnet <<'EOF' | ||
Package: aspnet* | ||
Pin: origin packages.microsoft.com | ||
Pin-Priority: 1001 | ||
EOF"; | ||
|
||
# Update packages | ||
sudo apt-get update; | ||
|
||
# Install the .NET 7 SDK | ||
sudo apt-get install dotnet-sdk-7.0 -y; |
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,14 @@ | ||
#!/usr/bin/env bash | ||
|
||
DEBIAN_FRONTEND="noninteractive"; | ||
|
||
# Install VSCode | ||
|
||
# Get dependencies | ||
sudo -E apt-get install software-properties-common apt-transport-https -y; | ||
# Install the GPG key | ||
wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add -; | ||
# Add the VSCode package repo | ||
sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" -y; | ||
# Install VS Code package | ||
sudo apt-get install code -y; |
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
Oops, something went wrong.