-
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.
Initial commit: Start over with a clean slate
- Removed the 'main' branch and its commit history.
- Loading branch information
0 parents
commit b58e8d3
Showing
97 changed files
with
8,037 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
#!/bin/bash | ||
|
||
# Script Name: gpg_keygen_script.sh | ||
# Author: GJS (homelab-aplha) | ||
# Date: 2024-05-18T12:08:56+02:00 | ||
# Version: 1.0 | ||
|
||
# Description: This script generates a GPG key pair for secure communication. | ||
# It checks for required software, generates the key pair, and logs the actions. | ||
# The script also provides options for verbose output and specifying the GPG directory. | ||
|
||
# Usage: ./gpg_keygen_script.sh [-v] [-d /path/to/gpg_directory] | ||
|
||
# Options: | ||
# -v, --verbose Enable verbose mode | ||
# -d, --directory Specify the path to the GPG directory (default is \$HOME/.gnupg) | ||
|
||
# Examples: | ||
# Generate key pair: | ||
# $ ./gpg_keygen_script.sh | ||
# Verbose mode: | ||
# $ ./gpg_keygen_script.sh -v | ||
# Specify GPG directory: | ||
# $ ./gpg_keygen_script.sh -d /path/to/gpg_directory | ||
|
||
# Notes: | ||
# - Requires GPG to be installed. If not installed, the script will exit with an error message. | ||
# - Checks for existing GPG key pair and prevents generation if it already exists. | ||
# - Logs all actions and errors to a specified log file. | ||
|
||
# Functions: | ||
|
||
# Function to print text in cyan color | ||
print_cyan() { | ||
echo -e "\e[36m$1\e[0m" | ||
} | ||
|
||
# Function to print section headers | ||
print_section_header() { | ||
echo "" | ||
echo "" | ||
echo -e "$(print_cyan "=== $1 ===")" | ||
} | ||
|
||
# Function for displaying verbose information | ||
display_verbose_info() { | ||
if [ "$verbose" == "true" ]; then | ||
print_section_header "GPG Key:" | ||
gpg --list-keys --keyid-format LONG | ||
fi | ||
} | ||
|
||
# Function for logging actions and errors to a single log file | ||
log_message() { | ||
local timestamp | ||
timestamp=$(date +"%Y-%m-%d %H:%M:%S") | ||
local message="$1" | ||
|
||
echo "${timestamp} - ${message}" | tee -a "$log_file" >&2 | ||
} | ||
|
||
# Function for displaying usage instructions | ||
display_usage() { | ||
echo "Usage: $0 [-v] [-d /path/to/gpg_directory]" | ||
echo "Options:" | ||
echo " -v, --verbose Enable verbose mode" | ||
echo " -d, --directory Specify the path to the GPG directory (default is \$HOME/.gnupg)" | ||
exit 1 | ||
} | ||
|
||
# Function for checking required software and informing the user if not present | ||
check_required_software() { | ||
if ! command -v "gpg" >/dev/null 2>&1; then | ||
log_message "Error: GPG is not installed. Please install GPG before running this script." | ||
exit 1 | ||
else | ||
log_message "GPG is installed." | ||
fi | ||
} | ||
|
||
# Function for generating the GPG key pair | ||
generate_key_pair() { | ||
log_message "Generating new GPG key pair..." | ||
print_section_header "Generating new GPG key pair" | ||
log_message "Executing command: gpg --full-generate-key" | ||
gpg --full-generate-key | ||
} | ||
|
||
# Function for checking the existence of the key file | ||
check_key_file_existence() { | ||
if [ -f "$gpg_dir/pubring.kbx" ]; then | ||
log_message "The GPG key pair already exists." | ||
log_message "=== end of the log ===" | ||
echo "$(print_cyan "Error:") The GPG key pair already exists." | ||
exit 1 | ||
fi | ||
} | ||
|
||
# Function for processing command line options | ||
parse_command_line_options() { | ||
while [[ $# -gt 0 ]]; do | ||
case "$1" in | ||
-v | --verbose) | ||
verbose=true | ||
shift | ||
;; | ||
-d | --directory) | ||
shift | ||
gpg_dir="$1" | ||
shift | ||
;; | ||
*) | ||
display_usage | ||
;; | ||
esac | ||
done | ||
} | ||
|
||
# Trap signals (interrupts) | ||
trap trap_handler SIGINT SIGTERM | ||
|
||
# Main Program: | ||
|
||
# Default values | ||
gpg_dir="$HOME/.gnupg" | ||
log_file="$gpg_dir/gpg_keygen_script.log" | ||
|
||
# Start logging | ||
echo "" >>"$log_file" # Add an empty line after the marker for separation | ||
log_message "=== beginning of the log ===" | ||
log_message "Script execution started" | ||
|
||
# Check if required software is installed | ||
check_required_software | ||
|
||
# Initialize options | ||
verbose=false | ||
|
||
# Parse command line options | ||
parse_command_line_options "$@" | ||
|
||
# Check if the GPG directory and log file exist, create them if they don't | ||
if [ ! -d "$gpg_dir" ]; then | ||
mkdir -p "$gpg_dir" && log_message "Created directory: $gpg_dir" | ||
fi | ||
|
||
if [ ! -f "$log_file" ]; then | ||
touch "$log_file" && log_message "Created log file: $log_file" | ||
fi | ||
|
||
# Check if the GPG key pair already exists | ||
check_key_file_existence | ||
|
||
# Generate GPG key pair | ||
generate_key_pair | ||
|
||
# Display verbose information | ||
display_verbose_info | ||
|
||
# Logging completion | ||
log_message "Script execution completed." | ||
log_message "=== end of the log ===" |
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,73 @@ | ||
#!/bin/bash | ||
|
||
# Script Name: install_latest_dart_sass.sh | ||
# Author: GJS (homelab-alpha) | ||
# Date: 2024-05-18T12:09:00+02:00 | ||
# Version: 1.0 | ||
|
||
# Description: This script fetches the latest version of Dart Sass from the | ||
# official GitHub repository, downloads it, installs it to /usr/local/dart-sass, | ||
# and cleans up the downloaded files. | ||
|
||
# Usage: ./install_latest_dart_sass.sh | ||
|
||
# Fetch the latest version of Dart Sass from the GitHub API | ||
LATEST_VERSION=$(curl -s https://api.github.com/repos/sass/dart-sass/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') | ||
|
||
# Check if we successfully fetched the latest version | ||
if [ -z "$LATEST_VERSION" ]; then | ||
echo "Failed to fetch the latest version of Dart Sass." | ||
exit 1 | ||
fi | ||
|
||
# Construct the download URL using the latest version | ||
DOWNLOAD_URL="https://github.com/sass/dart-sass/releases/download/${LATEST_VERSION}/dart-sass-${LATEST_VERSION}-linux-x64.tar.gz" | ||
|
||
# Define the download directory | ||
DOWNLOAD_DIR="$HOME/Downloads" | ||
|
||
# Use wget to download the latest version of Dart Sass to the specified directory | ||
if ! wget "$DOWNLOAD_URL" -O "$DOWNLOAD_DIR/dart-sass-${LATEST_VERSION}-linux-x64.tar.gz"; then | ||
echo "Failed to download Dart Sass version ${LATEST_VERSION}." | ||
exit 1 | ||
fi | ||
|
||
echo "Successfully downloaded Dart Sass version ${LATEST_VERSION} to $DOWNLOAD_DIR." | ||
|
||
# Extract the downloaded tar.gz file in the download directory | ||
tar -xzf "$DOWNLOAD_DIR/dart-sass-${LATEST_VERSION}-linux-x64.tar.gz" -C "$DOWNLOAD_DIR" | ||
|
||
# Create the target directory if it doesn't exist | ||
sudo mkdir -p /usr/local/dart-sass | ||
|
||
# Remove any previous Dart Sass installation if it exists | ||
sudo rm -rf /usr/local/dart-sass/* | ||
|
||
# Move the extracted files to /usr/local/dart-sass | ||
if ! sudo mv "$DOWNLOAD_DIR/dart-sass"/* /usr/local/dart-sass/; then | ||
echo "Failed to move Dart Sass files to /usr/local/dart-sass." | ||
exit 1 | ||
fi | ||
|
||
echo "Successfully installed Dart Sass version ${LATEST_VERSION} to /usr/local/dart-sass." | ||
|
||
# Clean up by removing the downloaded tar.gz file and the extracted directory | ||
rm -r "$DOWNLOAD_DIR/dart-sass-${LATEST_VERSION}-linux-x64.tar.gz" | ||
rm -rf "$DOWNLOAD_DIR/dart-sass" | ||
echo "Cleanup complete." | ||
echo "" | ||
|
||
# Check if Sass is available and provide instructions if not | ||
if ! command -v sass &>/dev/null; then | ||
echo "Sass command not found. You may need to add Dart Sass to your PATH." | ||
echo "To do this, add the following line to your ~/.bashrc or ~/.bash_profile:" | ||
echo "" | ||
echo "export PATH=\$PATH:/usr/local/dart-sass" | ||
echo "" | ||
echo "Then, run: source ~/.bashrc" | ||
echo "and/or" | ||
echo "Then, run: source ~/.bash_profile" | ||
exit 1 | ||
else | ||
echo "Sass version: $(sass --version)" | ||
fi |
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,75 @@ | ||
#!/bin/bash | ||
|
||
# Script Name: install_latest_go.sh | ||
# Author: GJS (homelab-alpha) | ||
# Date: 2024-05-18T12:09:02+02:00 | ||
# Version: 1.0 | ||
|
||
# Description: This script fetches the latest version of Go from the official Go | ||
# download page, downloads it, installs it to /usr/local/go, and cleans up the | ||
# downloaded files. | ||
|
||
# Usage: ./install_latest_go.sh | ||
|
||
# Fetch the latest version of Go from the official download page | ||
LATEST_VERSION_OUTPUT=$(curl -s https://go.dev/VERSION?m=text) | ||
|
||
# Extract the version number from the output | ||
LATEST_VERSION="$(echo $LATEST_VERSION_OUTPUT | awk '{print $1}' | sed 's/go//')" | ||
|
||
# Check if we successfully fetched the latest version | ||
if [ -z "$LATEST_VERSION" ]; then | ||
echo "Failed to fetch the latest version of Go." | ||
exit 1 | ||
fi | ||
|
||
# Construct the download URL using the latest version | ||
DOWNLOAD_URL="https://go.dev/dl/go${LATEST_VERSION}.linux-amd64.tar.gz" | ||
|
||
# Define the download directory | ||
DOWNLOAD_DIR="$HOME/Downloads" | ||
|
||
# Use wget to download the latest version of Go to the specified directory | ||
if ! wget "$DOWNLOAD_URL" -O "$DOWNLOAD_DIR/go${LATEST_VERSION}.linux-amd64.tar.gz"; then | ||
echo "Failed to download Go version ${LATEST_VERSION}." | ||
exit 1 | ||
fi | ||
|
||
echo "Successfully downloaded Go version ${LATEST_VERSION} to $DOWNLOAD_DIR." | ||
|
||
# Extract the downloaded tar.gz file in the download directory | ||
tar -xzf "$DOWNLOAD_DIR/go${LATEST_VERSION}.linux-amd64.tar.gz" -C "$DOWNLOAD_DIR" | ||
|
||
# Create the target directory if it doesn't exist | ||
sudo mkdir -p /usr/local/go | ||
|
||
# Remove any previous Go installation if it exists | ||
sudo rm -rf /usr/local/go | ||
|
||
# Move the extracted files to /usr/local/go | ||
if ! sudo mv "$DOWNLOAD_DIR/go" /usr/local/; then | ||
echo "Failed to move Go files to /usr/local/go." | ||
exit 1 | ||
fi | ||
|
||
echo "Successfully installed Go version ${LATEST_VERSION} to /usr/local/go." | ||
|
||
# Clean up by removing the downloaded tar.gz file | ||
rm "$DOWNLOAD_DIR/go${LATEST_VERSION}.linux-amd64.tar.gz" | ||
echo "Cleanup complete." | ||
echo "" | ||
|
||
# Check if Go is available and provide instructions if not | ||
if ! command -v go &>/dev/null; then | ||
echo "Go command not found. You may need to add Go to your PATH." | ||
echo "To do this, add the following line to your ~/.bashrc or ~/.bash_profile:" | ||
echo "" | ||
echo "export PATH=\$PATH:/usr/local/go/bin" | ||
echo "" | ||
echo "Then, run: source ~/.bashrc" | ||
echo "and/or" | ||
echo "Then, run: source ~/.bash_profile" | ||
exit 1 | ||
else | ||
echo "Go version: $(go version)" | ||
fi |
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,81 @@ | ||
#!/bin/bash | ||
|
||
# Script Name: install_latest_hugo.sh | ||
# Author: GJS (homelab-alpha) | ||
# Date: 2024-05-18T12:09:08+02:00 | ||
# Version: 1.0 | ||
|
||
# Description: This script fetches the latest version of Hugo from the official | ||
# GitHub repository, downloads it, installs it to /usr/local/hugo-extended, and | ||
# cleans up the downloaded files. | ||
|
||
# Usage: ./install_latest_hugo.sh | ||
|
||
# Fetch the latest version of Hugo from the GitHub API | ||
LATEST_VERSION=$(curl -s https://api.github.com/repos/gohugoio/hugo/releases/latest | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/') | ||
|
||
# Check if we successfully fetched the latest version | ||
if [ -z "$LATEST_VERSION" ]; then | ||
echo "Failed to fetch the latest version of Hugo." | ||
exit 1 | ||
fi | ||
|
||
# Construct the download URL using the latest version | ||
DOWNLOAD_URL="https://github.com/gohugoio/hugo/releases/download/v${LATEST_VERSION}/hugo_extended_${LATEST_VERSION}_linux-amd64.tar.gz" | ||
|
||
# Define the download directory | ||
DOWNLOAD_DIR="$HOME/Downloads" | ||
|
||
# Use wget to download the latest version of Hugo to the specified directory | ||
wget "$DOWNLOAD_URL" -O "$DOWNLOAD_DIR"/hugo_extended_"${LATEST_VERSION}"_linux-amd64.tar.gz | ||
|
||
# Check if wget successfully downloaded the file | ||
if ! wget -q --spider "$DOWNLOAD_URL"; then | ||
echo "Failed to download Hugo version ${LATEST_VERSION}." | ||
exit 1 | ||
fi | ||
|
||
echo "Successfully downloaded Hugo version ${LATEST_VERSION} to $DOWNLOAD_DIR." | ||
|
||
# Extract the downloaded tar.gz file in the download directory | ||
tar -xzf "$DOWNLOAD_DIR"/hugo_extended_"${LATEST_VERSION}"_linux-amd64.tar.gz -C "$DOWNLOAD_DIR" | ||
|
||
# Create the target directory if it doesn't exist | ||
sudo mkdir -p /usr/local/hugo-extended | ||
|
||
# Remove any previous Hugo installation if it exists | ||
sudo rm -rf /usr/local/hugo-extended/* | ||
|
||
# Move the Hugo binary and additional files to /usr/local/hugo-extended | ||
sudo mv "$DOWNLOAD_DIR"/hugo /usr/local/hugo-extended/ | ||
sudo mv "$DOWNLOAD_DIR"/LICENSE /usr/local/hugo-extended/ | ||
sudo mv "$DOWNLOAD_DIR"/README.md /usr/local/hugo-extended/ | ||
|
||
# Check if the Hugo binary was successfully moved | ||
if [ ! -f "/usr/local/hugo-extended/hugo" ]; then | ||
echo "Failed to move Hugo binary to /usr/local/hugo-extended." | ||
exit 1 | ||
fi | ||
|
||
echo "Successfully installed Hugo version ${LATEST_VERSION} to /usr/local/hugo-extended." | ||
|
||
# Clean up by removing the downloaded tar.gz file | ||
rm "$DOWNLOAD_DIR"/hugo_extended_"${LATEST_VERSION}"_linux-amd64.tar.gz | ||
|
||
echo "Cleanup complete." | ||
echo "" | ||
|
||
# Check if Hugo is available and provide instructions if not | ||
if ! command -v hugo &>/dev/null; then | ||
echo "Hugo command not found. You may need to add Go to your PATH." | ||
echo "To do this, add the following line to your ~/.bashrc or ~/.bash_profile:" | ||
echo "" | ||
echo "export PATH=\$PATH:/usr/local/hugo-extended" | ||
echo "" | ||
echo "Then, run: source ~/.bashrc" | ||
echo "Or" | ||
echo "Then, run: source ~/.bash_profile" | ||
exit 1 | ||
else | ||
echo "Hugo version: $(hugo version)" | ||
fi |
Oops, something went wrong.