Additional Doc Restructure
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
*Purpose*: Sometimes you need two linux computers to be able to talk to eachother without requiring a password. Passwordless SSH can be achieved by running the following commands:
|
||||
|
||||
!!! note "Non-Root Key Storage Considerations"
|
||||
When you generate SSH keys, they will be stored in a specific user's profile, the one currently executing the commands. If you want to have passwordless SSH, you would run the commands from a non-root user (e.g. `nicole`).
|
||||
|
||||
``` sh
|
||||
ssh-keygen # (1)
|
||||
ssh-copy-id -i /home/nicole/.ssh/id_rsa.pub nicole@192.168.3.18 # (2)
|
||||
ssh -i /home/nicole/.ssh/id_rsa nicole@192.168.3.18 # (3)
|
||||
```
|
||||
|
||||
1. Just leave all of the default options and do not put a password on the SSH key. )
|
||||
2. Change the directories to account for your given username, and change the destination to the user@IP corresponding to the remote server. You will be prompted to enter the password once to store the SSH public key on the remote computer.
|
||||
3. This command is to validate that everything worked. If the remote user is the same as the local user (e.g. `nicole`) then you dont need to add the `-i /home/nicole/.ssh/id_rsa` section to the SSH command.
|
||||
|
||||
!!! warning "Run before configuring Global SSH Infrastructure Key"
|
||||
There is a global automation that leverages a [Global Infrastructure Public SSH Key](https://git.bunny-lab.io/Infrastructure/LinuxServer_SSH_PublicKey). If this runs before you run the commands above, you will be unable to configure SSH key relationships and it will need to be done manually.
|
||||
@@ -0,0 +1,5 @@
|
||||
``` sh
|
||||
xrandr --auto
|
||||
xrandr --setprovideroutputsource 4 0
|
||||
xrandr --output HDMI-1 --primary --mode 1920x1080 --rate 75.00 --output DVI-I-1-1 --mode 1920x1080 --rate 60.00 --right-of HDMI-1 --output -eDP-1 --off
|
||||
```
|
||||
61
operations/reference/bash/git-repo-updater.md
Normal file
61
operations/reference/bash/git-repo-updater.md
Normal file
@@ -0,0 +1,61 @@
|
||||
# Git Repo Updater (Script)
|
||||
## Purpose
|
||||
Standalone `repo_watcher.sh` script used by the Git Repo Updater container. This script clones or pulls one or more repositories and rsyncs them into destination paths.
|
||||
|
||||
For the containerized version and deployment details, see the [Git Repo Updater container doc](../../platforms/containerization/docker/custom-containers/git-repo-updater.md).
|
||||
|
||||
## Script
|
||||
```sh
|
||||
#!/bin/sh
|
||||
|
||||
# Function to process each repo-destination pair
|
||||
process_repo() {
|
||||
FULL_REPO_URL=$1
|
||||
DESTINATION=$2
|
||||
|
||||
# Extract the URL without credentials for logging and notifications
|
||||
CLEAN_REPO_URL=$(echo "$FULL_REPO_URL" | sed 's/https:\/\/[^@]*@/https:\/\//')
|
||||
|
||||
# Directory to hold the repository locally
|
||||
REPO_DIR="/root/Repo_Cache/$(basename $CLEAN_REPO_URL .git)"
|
||||
|
||||
# Clone the repo if it doesn't exist, or navigate to it if it does
|
||||
if [ ! -d "$REPO_DIR" ]; then
|
||||
curl -d "Cloning: $CLEAN_REPO_URL" $NTFY_URL
|
||||
git clone "$FULL_REPO_URL" "$REPO_DIR" > /dev/null 2>&1
|
||||
fi
|
||||
cd "$REPO_DIR" || exit
|
||||
|
||||
# Fetch the latest changes
|
||||
git fetch origin main > /dev/null 2>&1
|
||||
|
||||
# Check if the local repository is behind the remote
|
||||
LOCAL=$(git rev-parse @)
|
||||
REMOTE=$(git rev-parse @{u})
|
||||
|
||||
if [ "$LOCAL" != "$REMOTE" ]; then
|
||||
curl -d "Updating: $CLEAN_REPO_URL" $NTFY_URL
|
||||
git pull origin main > /dev/null 2>&1
|
||||
rsync -av --delete --exclude '.git/' ./ "$DESTINATION" > /dev/null 2>&1
|
||||
fi
|
||||
}
|
||||
|
||||
# Main loop
|
||||
while true; do
|
||||
# Iterate over each environment variable matching 'REPO_[0-9]+'
|
||||
env | grep '^REPO_[0-9]\+=' | while IFS='=' read -r name value; do
|
||||
# Split the value by comma and read into separate variables
|
||||
OLD_IFS="$IFS" # Save the original IFS
|
||||
IFS=',' # Set IFS to comma for splitting
|
||||
set -- $value # Set positional parameters ($1, $2, ...)
|
||||
REPO_URL="$1" # Assign first parameter to REPO_URL
|
||||
DESTINATION="$2" # Assign second parameter to DESTINATION
|
||||
IFS="$OLD_IFS" # Restore original IFS
|
||||
|
||||
process_repo "$REPO_URL" "$DESTINATION"
|
||||
done
|
||||
|
||||
# Wait for 5 seconds before the next iteration
|
||||
sleep 5
|
||||
done
|
||||
```
|
||||
19
operations/reference/bash/install-qemu-guest-agent.md
Normal file
19
operations/reference/bash/install-qemu-guest-agent.md
Normal file
@@ -0,0 +1,19 @@
|
||||
**Purpose**:
|
||||
You may need to install the QEMU guest agent on linux VMs manually, while Windows-based devices work out-of-the-box after installing the VirtIO guest tools installer.
|
||||
|
||||
=== "Ubuntu Server"
|
||||
|
||||
```sh
|
||||
sudo su
|
||||
apt update
|
||||
apt install -y qemu-guest-agent
|
||||
systemctl enable --now qemu-guest-agent
|
||||
```
|
||||
|
||||
=== "Rocky Linux"
|
||||
|
||||
```sh
|
||||
sudo su
|
||||
dnf install -y qemu-guest-agent
|
||||
systemctl enable --now qemu-guest-agent
|
||||
```
|
||||
18
operations/reference/bash/install-xrdp.md
Normal file
18
operations/reference/bash/install-xrdp.md
Normal file
@@ -0,0 +1,18 @@
|
||||
**Purpose**:
|
||||
If you need to set up RDP access to a Linux environment, you will want to install XRDP. Once it is installed, you can leverage other tools such as Apache Guacamole to remotely connect to it.
|
||||
|
||||
```
|
||||
# Install and Start XRDP Service
|
||||
sudo dnf install epel-release -y
|
||||
sudo dnf install xrdp -y
|
||||
sudo systemctl enable --now xrdp
|
||||
|
||||
# Open Firewall Rules for RDP Traffic
|
||||
sudo firewall-cmd --permanent --add-port=3389/tcp
|
||||
sudo firewall-cmd --reload
|
||||
|
||||
# Configure Desktop Environment to Launch when you Login via RDP (Run as Non-Root User)
|
||||
# XFCE4 Desktop Environment
|
||||
echo "startxfce4" > ~/.Xclients
|
||||
chmod +x ~/.Xclients
|
||||
```
|
||||
5
operations/reference/bash/mdadm-grow-array-size.md
Normal file
5
operations/reference/bash/mdadm-grow-array-size.md
Normal file
@@ -0,0 +1,5 @@
|
||||
https://www.digitalocean.com/community/tutorials/how-to-create-raid-arrays-with-mdadm-on-ubuntu-16-04
|
||||
``` sh
|
||||
sudo mdadm --grow /dev/md0 -l 5
|
||||
cat /proc/mdstat
|
||||
```
|
||||
7
operations/reference/bash/open-port-checker.md
Normal file
7
operations/reference/bash/open-port-checker.md
Normal file
@@ -0,0 +1,7 @@
|
||||
**Purpose**:
|
||||
If you want to check if a certain TCP port is open on a server.
|
||||
|
||||
## Netcat Command
|
||||
``` sh
|
||||
netcat -z -n -v <IP ADDRESS> <PORT>
|
||||
```
|
||||
@@ -0,0 +1,61 @@
|
||||
## Purpose
|
||||
This script is ran via cronjob on `cluster-node-02` at midnight to rollback the deeplab environment automatically to a previous snapshot nightly.
|
||||
|
||||
### Bash Script
|
||||
|
||||
```sh title="/root/deeplab-rollback.sh"
|
||||
#!/usr/bin/env bash
|
||||
# ProxmoxVE Nightly DeepLab Rollback Script
|
||||
|
||||
SNAPNAME="ROLLBACK"
|
||||
|
||||
DC=140
|
||||
WIN10=141
|
||||
WIN11=111
|
||||
ALL=("$DC" "$WIN10" "$WIN11")
|
||||
|
||||
log(){ echo "[$(date '+%F %T')] $*"; }
|
||||
|
||||
# Force Stop DeepLab VMs
|
||||
for id in "${ALL[@]}"; do
|
||||
log "Force stopping VM $id"
|
||||
/usr/sbin/qm stop "$id" || true
|
||||
done
|
||||
|
||||
# Rollback Snapshots
|
||||
for id in "${ALL[@]}"; do
|
||||
log "Rolling back VM $id to snapshot $SNAPNAME"
|
||||
/usr/sbin/qm rollback "$id" "$SNAPNAME"
|
||||
done
|
||||
|
||||
# Start DC
|
||||
log "Starting DC ($DC)"
|
||||
/usr/sbin/qm start "$DC"
|
||||
|
||||
# Wait 2 minutes
|
||||
log "Waiting 2 minutes for DC to initialize..."
|
||||
sleep 120
|
||||
|
||||
# Start Win10 + Win11
|
||||
log "Starting WIN10 ($WIN10) and WIN11 ($WIN11)"
|
||||
/usr/sbin/qm start "$WIN10" &
|
||||
/usr/sbin/qm start "$WIN11" &
|
||||
wait
|
||||
|
||||
log "Lab Rollback Complete."
|
||||
```
|
||||
|
||||
### Crontab Scheduling
|
||||
Type `crontab -e` to add an entry to run the job at midnight every day.
|
||||
|
||||
=== "With Logging"
|
||||
|
||||
``` sh
|
||||
0 0 * * * /root/deeplab-rollback.sh >> /var/log/deeplab-rollback.log 2>&1
|
||||
```
|
||||
|
||||
=== "Without Logging"
|
||||
|
||||
``` sh
|
||||
0 0 * * * /root/deeplab-rollback.sh 2>&1
|
||||
```
|
||||
11
operations/reference/bash/time-adjustment.md
Normal file
11
operations/reference/bash/time-adjustment.md
Normal file
@@ -0,0 +1,11 @@
|
||||
The commands outlined in this short document are meant to be a quick-reference for setting the timezone and date/time of a Linux-based server.
|
||||
|
||||
### Set Timezone:
|
||||
```sh
|
||||
sudo timedatectl set-timezone America/Denver
|
||||
```
|
||||
|
||||
### Set Time & Date
|
||||
```sh
|
||||
date -s "1 JAN 2025 03:30:00"
|
||||
```
|
||||
49
operations/reference/bash/transfer-docker-containers.md
Normal file
49
operations/reference/bash/transfer-docker-containers.md
Normal file
@@ -0,0 +1,49 @@
|
||||
**Purpose**:
|
||||
If you find that you need to migrate a container, along with any supporting files, permissions, etc from an old server to a new server, rsync helps make this as painless as possible.
|
||||
Be sure to perform the following steps to make sure that you can copy the container's files.
|
||||
|
||||
!!! warning
|
||||
You need to stop the running containers on the old server before copying their data over, otherwise the state of the data may be unstable. Once you have migrated the data, you can spin up the containers on the new server and confirm they work before deleting the data on the old server.
|
||||
|
||||
On the destination (new) server, the directory needs to exist and be writable via the person copying the data over SSH:
|
||||
|
||||
## Copying Data Between the Old and New Servers
|
||||
|
||||
=== "Safe Method"
|
||||
|
||||
``` sh
|
||||
sudo mkdir -p /srv/containers/example
|
||||
sudo chmod 740 /srv/containers/example
|
||||
sudo chown nicole:nicole /srv/containers/example
|
||||
```
|
||||
|
||||
=== "Quick & Dirty Method"
|
||||
|
||||
``` sh
|
||||
sudo mkdir -p /srv/containers
|
||||
sudo chmod 777 /srv/containers
|
||||
```
|
||||
|
||||
On the source (old) server, perform an rsync over to the new server, authenticating yourself as you will be prompted to do so:
|
||||
|
||||
=== "Safe Method"
|
||||
|
||||
``` sh
|
||||
rsync -avz -e ssh --progress /srv/containers/example/* nicole@192.168.3.30:/srv/containers/example
|
||||
```
|
||||
|
||||
=== "Quick & Dirty Method"
|
||||
|
||||
``` sh
|
||||
rsync -avz -e ssh --progress /srv/containers/example nicole@192.168.3.30:/srv/containers
|
||||
```
|
||||
|
||||
=== "Quick & Dirty w/ Provided SSH Key Method"
|
||||
This method assumes that you have the private key for your SSH-based authentication locally on the server somewhere safe with permissions `chmod 600` applied to it. In this example, I placed the private key at `/tmp/id_rsa_OpenSSH`.
|
||||
|
||||
``` sh
|
||||
rsync -avz -e "ssh -i /tmp/id_rsa_OpenSSH" --progress /srv/containers/pihole nicole@192.168.3.62:/srv/containers
|
||||
```
|
||||
|
||||
## Spinning Up Docker / Portainer Stack
|
||||
Once everything has been moved over, copy the `docker-compose` and `.env` (environment variables) from the old server to the new one, pointing to the same location since we maintained the same folder structure, and the container should spin up like nothing ever happened.
|
||||
19
operations/reference/bash/transfer-files-with-netcat.md
Normal file
19
operations/reference/bash/transfer-files-with-netcat.md
Normal file
@@ -0,0 +1,19 @@
|
||||
**Purpose**: You may find that you need to transfer a file, such as a public SSH key, or some other kind of file between two devices. In this scenario, we assume both devices have the `netcat` command available to them. By putting a network listener on the device recieving the file, then sending the file to that device's IP and port, you can successfully transfer data between computers without needing to set up SSH, FTP, or anything else to establish initial trust between the devices. [Original Reference Material](https://www.youtube.com/shorts/1j17UBGqSog).
|
||||
|
||||
!!! warning
|
||||
The data being transferred will not be encrypted. If you are transferring relatively-safe files such as public SSH keys, etc, this should be fine.
|
||||
|
||||
### Destination Computer
|
||||
Run the following command on the computer that will be recieving the file.
|
||||
``` sh
|
||||
netcat -l <random-port> > /tmp/OUTPUT-AS-FILE.txt
|
||||
```
|
||||
|
||||
### Source Computer
|
||||
Run the following command on the computer that will be sending the file to the destination computer.
|
||||
``` sh
|
||||
cat INPUT-DATA.txt | netcat <IP-of-Destination-Computer> <Port-of-Destination-Computer> -q 0
|
||||
```
|
||||
|
||||
!!! info
|
||||
The `-q 0` command argument causes the netcat connection to close itself automatically when the transfer is complete.
|
||||
Reference in New Issue
Block a user