Skip to content

Commit

Permalink
Merge pull request #13 from jpfulton:linux-dev-setup
Browse files Browse the repository at this point in the history
Linux-dev-setup
  • Loading branch information
jpfulton authored Aug 27, 2023
2 parents 02fe34a + 14888a0 commit 84bfa6e
Show file tree
Hide file tree
Showing 11 changed files with 284 additions and 25 deletions.
7 changes: 7 additions & 0 deletions SETUP_BASIC_NETWORK.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,10 @@ place. It is not added to the key chain.
Once the disk has been set up, the backup will begin in 60 seconds. The first backup operation
is complete and may take some time. Future backup operations are incremental and significantly
faster.

## Next Steps

Once the basic infrastructure is in place from the steps described here, other
servers can now be created:

- [Setup a Linux Development Server](./SETUP_LINUX_DEV_SERVER.md)
53 changes: 53 additions & 0 deletions SETUP_LINUX_DEV_SERVER.md
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.
4 changes: 4 additions & 0 deletions linux/dev-tools/README.md
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.
31 changes: 31 additions & 0 deletions linux/dev-tools/create-dev-user.sh
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;
4 changes: 4 additions & 0 deletions linux/dev-tools/enable-node-corepack.sh
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;
7 changes: 7 additions & 0 deletions linux/dev-tools/install-chrome.sh
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;
25 changes: 25 additions & 0 deletions linux/dev-tools/install-desktop.sh
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;
38 changes: 38 additions & 0 deletions linux/dev-tools/install-dotnet-sdk.sh
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;
14 changes: 14 additions & 0 deletions linux/dev-tools/install-vscode.sh
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;
2 changes: 1 addition & 1 deletion linux/samba/create-samba-users.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ sudo adduser --no-create-home --disabled-password --shell /sbin/nologin --gecos
sudo echo "${LINUX_BACKUP_USER}:$(openssl rand -base64 12)" | sudo chpasswd;

# Set the linux back up user smb password
(echo "$LINUX_BACKUP_USER_PASS"; echo "$LINUX_BACKUP_USER_PASS") |sudo smbpasswd -s -a $LINUX_BACKUP_USER;
(echo "$LINUX_BACKUP_USER_PASS"; echo "$LINUX_BACKUP_USER_PASS") | sudo smbpasswd -s -a $LINUX_BACKUP_USER;

# Create a deployment output file with smb users and password for secure transfer to
# the control workstation later
Expand Down
Loading

0 comments on commit 84bfa6e

Please sign in to comment.