Bik Code Commit (Lots of Arma)

This commit is contained in:
Price Hiller 2021-07-28 09:32:08 -05:00
parent 945fba41f9
commit e49b428dee
21 changed files with 498 additions and 1041 deletions

990
.gitignore vendored
View File

@ -1,987 +1,5 @@
#!/usr/bin/env file .
# -*- Coding: UTF-8 -*-
# -*- System: Linux -*-
# -*- Usage: *.* -*-
# Owner: Jacob B. Sanders
# License: BSD 2-Clause License
# Website: code.cloud-technology.io
#
# Copyright 2020, Jacob B. Sanders - Cloud Hybrid LLC. & Affiliates
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
# OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
# OF SUCH DAMAGE.
#
# =================================================================================================
# Local Configuration
# =================================================================================================
Nexus.PID
alembic.ini
Nexus-API-Log.JSON
Nexus-API-Log.Log
Nexus-API-Log.Yaml
Nexus-API-Log.Yaml.*
Asynchronous.Log
Asynchronous.Log.*
Fast-API.Log
Fast-API.Log.*
Uvicorn.Log
Uvicorn.Log.*
Starlette.Log
Starlette.Log.*
Discord-Bot.Log
Discord-Bot.Log.*
TTY.Wrapper
node_modules
node_modules/
node_modules/*
node_modules/*/**
*/node_modules
**/*/node_modules
**node_modules**
*.pem
*.key
*.ca
*.cert
Artifact/Distribution
Artifact/Distribution/*
Artifact/Distribution/**
!IDE-Settings.zip
*Log.*
!Dependencies
!API/Discord/Source
.CI-CD-Project-ID
.CI-CD-UAT-Token
.CI-CD-Default-Branch
API/Configuration/Token
Cloud-ASGI-Log.UTF-8
Cloud_ASGI.egg-info
Nexus-API-Log.*
Nexus-API-Log.YAML
Nexus-API-Log.YAML.*
*.egg_info
*.egg_info/*
*egg*
**egg*
**egg**
./API/__version__.py
./API/Version.py
./API/PEM.py
*.whl
#
# =================================================================================================
# Cloud-Technology Universal .gitignore
# =================================================================================================
#
# The following sections will contain directories, files, & wildcards relating
# to special rules that either force include or prevent file-descriptors
# from being tracked via source [version] control.
#
# Note: Sections may contain duplicates -- which is intentional. Usage can
# simply include the entire file, or copy-and-pasted sections.
#
# General Section Stucture
# -------------------------
# >>> # [File]
# >>> # [Folder]/
# >>> # .[Dot-File]
# >>> # .[Dot-Folder]/
# >>> # *[Wild-Card-File]
# >>> # *[Wild-Card-Folder]/
# >>> # *.[Wild-Card-Dot-File]
# >>> # *.[Wild-Card-Dot-Folder]/
#
#
# ============================================================================
# Python
# ============================================================================
#
# References
# -----------
# PEP: https://github.com/github/gitignore/blob/master/Python.gitignore
# VirtualEnv: https://github.com/github/gitignore/blob/master/Global/VirtualEnv.gitignore
#
# Table of Contents
# ------------------
# ├── Byte Compilations
# ├── C Extensions
# ├── PyInstaller
# ├── Logging
# ├── PyBuilder
# ├── Unit Testing
# ├── Translations
# ├── Django
# ├── Flask
# ├── Scrapy
# ├── Jupyter
# ├── IPython
# ├── Sphinx
# ├── Packaging
# ├── Celery
# ├── Virtual Environments
# ├── Environments
# ├── Static Typing
# ├── Debug Symbols
#
# ----------------------------------------------------------------------------
# Byte Compilations (Python)
# -----------------------------------------------------------------------------
__pycache__
*.py[cod]
*$py.class
# -----------------------------------------------------------------------------
# C Extensions (Python)
# -----------------------------------------------------------------------------
*.so
# -----------------------------------------------------------------------------
# PyInstaller (Python)
# -----------------------------------------------------------------------------
*.manifest
*.spec
# -----------------------------------------------------------------------------
# Logging (Python)
# -----------------------------------------------------------------------------
pip-log.txt
pip-delete-this-directory.txt
*.log
# ------------------------------------------------------------------------------
# PyBuilder (Python)
# ------------------------------------------------------------------------------
target/
.pybuilder/
# -----------------------------------------------------------------------------
# Unit Testing (Python)
# -----------------------------------------------------------------------------
coverage.xml
nosetests.xml
site/
cover/
htmlcov/
.cache
.coverage
.coverage.*
.tox/
.nox/
.hypothesis/
.pytest_cache/
*.cover
*.py.cover
# -----------------------------------------------------------------------------
# Translations (Python)
# -----------------------------------------------------------------------------
*.mo
*.pot
# -----------------------------------------------------------------------------
# Django (Python)
# -----------------------------------------------------------------------------
db.sqlite3
db.sqlite3-journal
local_settings.py
*.log
# -----------------------------------------------------------------------------
# Flask (Python)
# -----------------------------------------------------------------------------
instance/
.env
.flask
.token
.flask-token
.webassets-cache
# -----------------------------------------------------------------------------
# Scrapy (Python)
# -----------------------------------------------------------------------------
.scrapy
# -----------------------------------------------------------------------------
# Jupyter (Python)
# -----------------------------------------------------------------------------
.ipynb_checkpoints
# -----------------------------------------------------------------------------
# IPython (Python)
# -----------------------------------------------------------------------------
ipython_config.py
profile_default/
# -----------------------------------------------------------------------------
# Sphinx (Python)
# -----------------------------------------------------------------------------
docs/
_build/
source/
# -----------------------------------------------------------------------------
# Packaging (Python)
# -----------------------------------------------------------------------------
MANIFEST
MANIFEST.in
lib
var
dist
eggs
build
Build
lib64
parts
sdist
wheels
downloads
develop-eggs
pip-wheel-metadata
share/python-wheels
__pypackages__
__pycache__
.Python
.installed.cfg
.eggs
*.egg
*.whl
*.dist-info
*.egg-info
*.egg-info/
*.egg-info/*
**/*.egg-info
**/*.egg-info/
**/*.egg-info/*
**/*/*.egg-info
**/*/*.egg-info/
**/*/*.egg-info/*
*.pyc
!setup.cfg
Key.PEM
# -----------------------------------------------------------------------------
# Celery (Python)
# -----------------------------------------------------------------------------
celerybeat-schedule
celerybeat.pid
# -----------------------------------------------------------------------------
# Virtual Environments (Python)
# -----------------------------------------------------------------------------
.Python
pyvenv.cfg
Pipfile.lock
pip-selfcheck.json
.python-version
.venv/
.Virtual-Environment/
.Virtualization/
[Bb]in
[Ii]nclude
[Ll]ib
[Ll]ib64
[Ll]ocal
[Ss]cripts
# -----------------------------------------------------------------------------
# Environments (Python)
# -----------------------------------------------------------------------------
.env
.venv
Environment.env
env
venv
ENV
env.bak
venv.bak
*.lock
*.Lock
*.LOCK
# -----------------------------------------------------------------------------
# Static Typing (Python)
# -----------------------------------------------------------------------------
.pytype/
# -----------------------------------------------------------------------------
# Debug Symbols (Python)
# -----------------------------------------------------------------------------
.cython_debug
# -----------------------------------------------------------------------------
# Settings & Build (Python)
# -----------------------------------------------------------------------------
setup.cfg
Static.zip
#
# ============================================================================
# C
# ============================================================================
# Python is a run-time language developed through C-Python (C). Therefore,
# some .gitignore C files may contain python-related contexts.
#
# References
# -----------
# GitHub: https://github.com/github/gitignore/blob/master/C.gitignore
#
# Table of Contents
# ------------------
# ├── Prerequisites
# ├── C Extensions (Python)
# ├── Object files
# ├── Linker Output
# ├── Precompiled Headers
# ├── Libraries
# ├── Shared Objects (Windows)
# ├── Executables
# ├── Debug Files
# ├── Kernel Module Compilations
# ├── Core Dumps
#
# -----------------------------------------------------------------------------
# Prerequisites (C Programming Language)
# -----------------------------------------------------------------------------
*.d
# -----------------------------------------------------------------------------
# Object files (C Programming Language)
# -----------------------------------------------------------------------------
*.o
*.ko
*.obj
*.elf
# -----------------------------------------------------------------------------
# Linker output (C Programming Language)
# -----------------------------------------------------------------------------
*.ilk
*.map
*.exp
# -----------------------------------------------------------------------------
# Precompiled Headers (C Programming Language)
# -----------------------------------------------------------------------------
*.gch
*.pch
# -----------------------------------------------------------------------------
# Libraries (C Programming Language)
# -----------------------------------------------------------------------------
*.lib
*.a
*.la
*.lo
# -----------------------------------------------------------------------------
# Shared objects (inc. Windows DLLs) (C Programming Language)
# -----------------------------------------------------------------------------
*.dll
*.so
*.so.*
*.dylib
# -----------------------------------------------------------------------------
# Executables (C Programming Language)
# -----------------------------------------------------------------------------
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex
# -----------------------------------------------------------------------------
# Debug files (C Programming Language)
# -----------------------------------------------------------------------------
*.dSYM/
*.su
*.idb
*.pdb
# -----------------------------------------------------------------------------
# Kernel Module Compile Results (C Programming Language)
# -----------------------------------------------------------------------------
dkms.conf
modules.order
Module.symvers
Mkfile.old
.tmp_versions
*.cmd
*.mod*
# -----------------------------------------------------------------------------
# Core Dumps (C Programming Language)
# -----------------------------------------------------------------------------
core
#
# ============================================================================
# Integrated Development Environments (IDEs)
# ============================================================================
#
# References
# -----------
# GitHub: https://github.com/github/gitignore/blob/master/C.gitignore
#
# Table of Contents
# ------------------
# ├── Visual Studio Code
# ├── X-Code
# │ ├── User settings
# │ ├── Legacy X-Code IDEs
# │ ├── GCC
# ├── Jet-Brains
# │ ├── User
# │ ├── Generated files
# │ ├── Sensitive or high-churn files
# │ ├── Gradle
# │ ├── ( Gradle || Maven ) && Auto-Import
# │ ├── CMake
# │ ├── Mongo Explorer plugin
# │ ├── File Project Format
# │ ├── IntelliJ
# │ ├── Modules
# │ ├── Jira
# │ ├── Android Studio
# │ ├── Editor-based Rest Client
# │ ├── Android Studio 3.1+ Serialized Cache File
#
# -----------------------------------------------------------------------------
# Visual Studio Code (IDEs)
# -----------------------------------------------------------------------------
.history/
.vscode/*
*.code-workspace
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
# -----------------------------------------------------------------------------
# X-Code (IDEs)
# -----------------------------------------------------------------------------
# --> User settings
xcuserdata
# --> Legacy X-Code IDEs
build
DerivedData
*.xcscmblueprint
*.xccheckout
*.moved-aside
*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3
!default.pbxuser
!default.mode1v3
!default.mode2v3
!default.perspectivev3
# --> GCC
/*.gcno
# -----------------------------------------------------------------------------
# Jet-Brains (IDEA, PyCharm, etc.) (IDEs)
# -----------------------------------------------------------------------------
# --> IDE Settings
**/.idea
**/.idea/
**/.idea/*
**/*.idea
**/*.idea/
**/*.idea/*
# --> User
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# --> Generated files
.idea/**/contentModel.xml
# --> Sensitive or high-churn files
.idea/**/dataSources
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# --> Gradle
.idea/**/gradle.xml
.idea/**/libraries
# --> ( Gradle || Maven ) && Auto-Import
.idea/artifacts
.idea/compiler.xml
.idea/jarRepositories.xml
.idea/modules.xml
.idea/*.iml
.idea/modules
*.iml
*.ipr
# --> CMake
cmake-build-*
# --> Mongo Explorer plugin
.idea/**/mongoSettings.xml
# --> File Project Format
*.iws
# --> IntelliJ
out
# --> Modules
.idea_modules
# --> Jira
atlassian-ide-plugin.xml
# --> Android Studio
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# --> Editor-based Rest Client
.idea/httpRequests
# --> Android Studio 3.1+ Serialized Cache File
.idea/caches/build_file_checksums.ser
#
# ============================================================================
# MacOS System Files
# ============================================================================
#
# Table of Contents
# ------------------
# N/A
#
.DS_Store
.AppleDouble
.LSOverride
Icon
*.hmap
*.ipa
*.dSYM.zip
*.dSYM
timeline.xctimeline
playground.xcworkspace
Carthage/Build
.accio
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots/**/*.png
fastlane/test_output
iOSInjectionProject
._*
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
.apdisk
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
#
# ============================================================================
# Go
# ============================================================================
#
# Table of Contents
# ------------------
# ├── Executables
# ├── Libraries
# ├── Coverage & Testing
# ├── Logging
#
# -----------------------------------------------------------------------------
# Executables (Go Programming Language)
# -----------------------------------------------------------------------------
*.exe
*.exe~
# -----------------------------------------------------------------------------
# Libraries (Go Programming Language)
# -----------------------------------------------------------------------------
*.dll
*.dll
*.dylib
# -----------------------------------------------------------------------------
# Coverage & Testing (Go Programming Language)
# -----------------------------------------------------------------------------
*.test
# -----------------------------------------------------------------------------
# Logging (Go Programming Language)
# -----------------------------------------------------------------------------
*.out
#
# ============================================================================
# Discord API & Bot Development
# ============================================================================
#
# Table of Contents
# ------------------
# N/A
#
Discord-Token
Discord-Token.env
Discord-Token.Environment
Token
Token.env
Token.Environment
Discord.Token
.Discord
.Token
.Discord-Token
# -----------------------------------------------------------------------------
# Installers (Discord)
# -----------------------------------------------------------------------------
*.deb
*.debian
#
# ============================================================================
# Java
# ============================================================================
#
# References
# -----------
# GitHub: https://github.com/github/gitignore/blob/master/Java.gitignore
#
# Table of Contents
# ------------------
# ├── Compilations
# ├── Logging
# ├── BlueJ
# ├── Mobile Tools (J2ME)
# ├── Package Files
#
# -----------------------------------------------------------------------------
# Compilations (Java Programming Language)
# -----------------------------------------------------------------------------
*.class
# -----------------------------------------------------------------------------
# Logging (Java Programming Language)
# -----------------------------------------------------------------------------
hs_err_pid*
*.log
# -----------------------------------------------------------------------------
# BlueJ (Java Programming Language)
# -----------------------------------------------------------------------------
*.ctxt
# -----------------------------------------------------------------------------
# Mobile Tools (J2ME) (Java Programming Language)
# -----------------------------------------------------------------------------
.mtj.tmp/
# -----------------------------------------------------------------------------
# Package Files (Java Programming Language)
# -----------------------------------------------------------------------------
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
#
# ============================================================================
# Cloud-Technology & Cloud-Hybrid LLC.(s)
# ============================================================================
#
# Table of Contents
# ------------------
# ├── Process Management
# ├── File Buffers
# ├── Automation
#
# -----------------------------------------------------------------------------
# Process Management (LLC.(s) & Affiliates)
# -----------------------------------------------------------------------------
PID.lock
PID.Lock
PID.LOCK
CID.lock
CID.Lock
CID.LOCK
Process.lock
Process.Lock
Process.LOCK
Parent.lock
Parent.Lock
Parent.LOCK
# -----------------------------------------------------------------------------
# File Buffers (LLC.(s) & Affiliates)
# -----------------------------------------------------------------------------
*~*
*.socket
*.Socket
*.SOCKET
# -----------------------------------------------------------------------------
# Automation (LLC.(s) & Affiliates)
# -----------------------------------------------------------------------------
*.unix
Environment.Properties
# -----------------------------------------------------------------------------
# Git (LLC.(s) & Affiliates)
# -----------------------------------------------------------------------------
Build/*
Build/**
*/Build/**
**/Build/**
Library/*
Metrics/*
Distribution/*
# -----------------------------------------------------------------------------
# Sensitive File(s) & Configuration (LLC.(s) & Affiliates)
# -----------------------------------------------------------------------------
TOKEN
Token
token
.TOKEN
.Token
.token
*.TOKEN
*.Token
*.token
.secret
.Secret
.SECRET
.secrets
.Secrets
.SECRETS
*.secret
*.Secret
*.SECRET
*.secrets
*.Secrets
*.SECRETS
# -----------------------------------------------------------------------------
# Application (LLC.(s) & Affiliates)
# -----------------------------------------------------------------------------
*.egg-info
*.egg-info/
*.egg-info/*
**/*.egg-info
**/*.egg-info/
**/*.egg-info/*
**/*/*.egg-info
**/*/*.egg-info/
**/*/*.egg-info/*
.idea
.idea/
.idea/*
*.idea
*.idea/
*.idea/*
**/.idea
**/.idea/
**/.idea/*
**/*.idea
**/*.idea/
**/*.idea/*
*venv*
*.log
*test*
*TEST*

View File

@ -0,0 +1,13 @@
#!/bin/bash
function autocomp_mordhau_start_server {
local cur opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
opts="--preserve"
if [ ${COMP_CWORD} -eq 2 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
}
complete -F autocomp_mordhau_start_server Mordhau-Start-Server

View File

@ -71,7 +71,7 @@ done
firewall-cmd --permanent --add-forward-port=port="${INBOUND_PORT}":proto=tcp:toaddr="${IP}":toport="${FORWARD_PORT}"
firewall-cmd --permanent --add-port="${INBOUND_PORT}"/tcp
firewall-cmd --add-masquerade
firewall-cmd --add-masquerade --permanent
firewall-cmd --reload
echo "Routing all data on ${INBOUND_PORT} to ${IP}:${FORWARD_PORT}"

72
CentOS/Steam-Add-User.bash Executable file
View File

@ -0,0 +1,72 @@
#!/bin/bash
set -e
usage() {
printf "%s\n" "Usage: $(basename "${0}") -u <steam username> -p <steam password>
--username <steam username> | -u <steam username>
Example:
--username Sbinalla"
}
error() {
printf "\n%s\n" "$1" >&2
exit 1
}
confirmation() {
while true; do
read -p "${1}" -n 1 -r choice
case "$choice" in
y|Y ) return 1;;
n|N ) return 0;;
* ) echo -e "\nInput must be either y, Y, n, or N";;
esac
done
}
while :; do
case $1 in
-h | -\? | --help)
usage # Display a usage synopsis.
exit
;;
--) # End of all options.
shift
break
;;
-u | --username)
shift
STEAMUSERNAME="${1}"
;;
-?*)
printf 'Unknown option: %s\n' "$1" >&2
usage
error
;;
*) # Default case: No more options, so break out of the loop.
break ;;
esac
shift
done
[[ "${STEAMUSERNAME}" == "" ]] && error "A steam username must be passed"
# Securely read password without echoing
stty -echo
printf "Enter the password for %s: " "${STEAMUSERNAME}"
read -r STEAMPASSWORD
stty echo
printf "\n"
[[ "${STEAMPASSWORD}" == "" ]] && error "A password for the steam account must be passed"
# Used to ensure a Steam directory is generated for userdata saving of account data
steamcmd +quit
# The below FEELS and LOOKS like bullshit, but steam does have output for the operation below.
# SteamCMD fails to return any exit code via the commands below and as such scripting it is a PITA and thus it
# stays like this.
steamcmd +login "${STEAMUSERNAME}" "${STEAMPASSWORD}" +quit

View File

@ -1,39 +0,0 @@
#!/bin/bash --posix
set -e
# Remote System
REMOTE_SSH_SERVER=Kansas-3800X
REMOTE_HOST_NAME=69.30.230.226
REMOTE_USER_TO_CREATE=Mordhau
# Local System
SSH_FILE_DIRECTORY=~/.ssh
SSH_FILE_NAME=${REMOTE_USER_TO_CREATE}-id_edcsa
SSH_FILE=${SSH_FILE_DIRECTORY}/${SSH_FILE_NAME}
SSH_HOST=Kansas-3800X
ssh-keygen -b 521 -t ECDSA -f ${SSH_FILE} -N ""
chmod 600 ${SSH_FILE}
PUB_KEY_CONTENTS=$(cat ${SSH_FILE}.pub)
ssh ${REMOTE_SSH_SERVER} -f "useradd ${REMOTE_USER_TO_CREATE}; bash -l"
ssh ${REMOTE_SSH_SERVER} -f "mkdir /home/${REMOTE_USER_TO_CREATE}/.ssh; bash -l"
ssh ${REMOTE_SSH_SERVER} -f "touch /home/${REMOTE_USER_TO_CREATE}/.ssh/authorized_keys; bash -l"
ssh ${REMOTE_SSH_SERVER} -f "echo ${PUB_KEY_CONTENTS} >> /home/${REMOTE_USER_TO_CREATE}/.ssh/authorized_keys; bash -l"
ssh ${REMOTE_SSH_SERVER} -f "chown -R ${REMOTE_USER_TO_CREATE}:${REMOTE_USER_TO_CREATE} /home/${REMOTE_USER_TO_CREATE}/.ssh; bash -l"
cat << EOF >> ~/.ssh/config
Host ${SSH_HOST}
HostName ${REMOTE_HOST_NAME}
Match user ${REMOTE_USER_TO_CREATE}
Identityfile ${SSH_FILE}
LogLevel INFO
EOF
ssh ${REMOTE_USER_TO_CREATE}@${SSH_HOST} -f "mkdir ~/.bin"
ssh ${REMOTE_USER_TO_CREATE}@${SSH_HOST} -f "echo export PATH=$PATH:~/.bin > ~/.bash_profile"
echo
echo "Finished, login via ssh with \"${REMOTE_USER_TO_CREATE}@${SSH_HOST}\""

95
Cron/Autodelete-Files.bash Executable file
View File

@ -0,0 +1,95 @@
#!/bin/bash --posix
#=======================================================================================================================
# Copyright 2021, Price Hiller - All Rights Reserved
#
# Copying, distribution, usage, or modification of this file or the following source code, via any
# method is strictly prohibited without the explicit written consent of Price Hiller (philler3138@gmail.com)
# The following file contains proprietary and confidential content
#=======================================================================================================================
set -e
DIRECTORY=""
HOUR=12
DAYS_OLD=3
usage() {
printf "%s\n" "Usage: Autodelete-Files -d <path>
--directory <dir> | -d <dir>
Example:
--directory ~/trash/
--hour <int < 24> | -h <int < 24>
Example:
--hour 5
Default: 12
--days-old <int > 0> | -o <int > 0>
Example:
--days-old 3
Default: 3"
}
error() {
printf "\n%s\n" "$1" >&2
exit 1
}
confirmation() {
while true; do
read -p "${1}" -n 1 -r choice
case "$choice" in
y|Y ) return 1;;
n|N ) return 0;;
* ) echo -e "\nInput must be either y, Y, n, or N";;
esac
done
}
while :; do
case $1 in
-h | -\? | --help)
usage # Display a usage synopsis.
exit
;;
--) # End of all options.
shift
break
;;
-d | --directory)
shift
DIRECTORY="${1}"
;;
-h | --hour)
shift
HOUR="${1}"
;;
-o | --days-old)
shift
DAYS_OLD="${1}"
;;
-?*)
printf 'Unknown option: %s\n' "$1" >&2
usage
error
;;
*) # Default case: No more options, so break out of the loop.
break ;;
esac
shift
done
[[ "${DIRECTORY}" == "" ]] && error "A directory must be provided!"
[[ -d "${DIRECTORY}" ]] && error "The given directory ${DIRECTORY} was invalid"
[[ "${HOUR}" -gt 23 ]] && error "Hour may be no more than 23"
[[ "${HOUR}" -lt 0 ]] && error "Hour may be no less than 0"
[[ ! "${HOUR}" -eq "${HOUR}" ]] && error "Hour must be a number"
[[ ! "${DAYS_OLD}" -eq "${DAYS_OLD}" ]] && error "Days-old must be a number"
NEW_CRON_ENTRY="00 ${HOUR} * * * find ${DIRECTORY} -mtime +${DAYS_OLD} -exec rm {} \;"
crontab -l | { cat; echo "${NEW_CRON_ENTRY}"; } | crontab -

67
Functions/Arg-Parsing.bash Executable file
View File

@ -0,0 +1,67 @@
#!/bin/bash --posix
usage() {
# Print out usage instructions for the local script
#
# Arguments:
# None
#
# Usage:
# usage
#
# POSIX Compliant:
# Yes
#
printf "Usage: %s %s\n" \
"$(basename ${0})" \
"-i \"this is some input\" -t \"this is some more example input\"
--input <string> | -i <string>
Example:
--input \"this is an example input\"
--test <string> | -t <string>
Example:
--test \"this is more example input\""
}
parse_args() {
# Parse input arguments
#
# Arguments:
# Consult the `usage` function
#
# Usage:
# parse_args "$@"
# - All arguments should be ingested by parse_args first for variable setting
#
# POSIX Compliant:
# Yes
#
while :; do
case ${1} in
-h | -\? | --help)
usage # Display a usage synopsis.
exit
;;
--) # End of all options.
break
;;
-i | --input)
echo "${2}"
;;
-t | --test)
echo "${2}"
;;
-?*)
printf 'Unknown option: %s\n' "$1" >&2
usage
;;
*) # Default case: No more options, so break out of the loop.
break ;;
esac
shift 2
done
}
parse_args "$@"

32
Functions/Confirmation.bash Executable file
View File

@ -0,0 +1,32 @@
#!/bin/bash
confirmation() {
# Receive confirmation from user as y, Y, n, or N
#
# Arguments:
# message <type: string> <position: 1> <required: true>
# - The confirmation prompt sent to the user, for example:
# Would you like to overwrite foobar.txt (y/N)?
#
# Usage:
# confirmation "Some prompt"
# - Sends "Some prompt" to the user and gets their input
#
# POSIX Compliant:
# Yes
#
local message
message="${1}"
local choice
while true; do
read -p "${message}" -n 1 -r choice
case "$choice" in
y | Y) return 1 ;;
n | N) return 0 ;;
*) echo -e "\nInput must be either y, Y, n, or N" ;;
esac
done
}

View File

@ -0,0 +1,13 @@
# What the function does
#
# Arguments:
# arg1 <type: string> <position: 1> <required: true>
# - An example argument
#
# Usage:
# functionName "hello"
# - Makes arg1 equal to "hello"
#
# POSIX Compliant:
# Yes
#

64
Functions/Logging.bash Executable file
View File

@ -0,0 +1,64 @@
#!/bin/bash --posix
set -e
log() {
# Print a message and send it to stdout or stderr depending upon log level, also configurable with debug etc.
#
# Arguments:
# level <type: string> <position: 1> <required: true>
# - The log level, defined within a case check in this function
# message <type: string> <position: 2> <required: true>
# - The info message
# line_number <type: int> <position: 3> <required: false>
# - The line number of the calling function (${LINNO})
#
# Usage:
# log "info" "Could not find that directory"
#
# POSIX Compliant:
# Yes
#
# Set debug status depending if a global debug variable has been set to either 1 or 0
local debug
if [ ${DEBUG} ]; then
debug=${DEBUG}
else
debug=0
fi
local FORMAT
FORMAT="[$(date +%Y-%m-%dT%H:%M:%S%z)]"
# Convert the level to uppercase
local level
level=$(echo "${1}" | tr '[:lower:]' '[:upper:]')
local message
message="${2}"
case "${level}" in
INFO)
# Output all info log levels to stdout
printf "${FORMAT}[INFO] %s\n" "${message}" >&1
return 0
;;
DEBUG)
[[ ${debug} == 0 ]] && return 0
printf "${FORMAT}[DEBUG] %s\n" "${message}" >&1
return 0
;;
ERROR)
# Output all error log levels to stderr
printf "${FORMAT}[ERROR] %s\n" "${message}" >&2
return 0
;;
# Further log levels can be added by extending this switch statement with more comparisons
*) # Default case, no matches
# Returns non-zero code as an improper log option was passed, this helps with using `set -e`
log "ERROR" "Invalid log level passed, received level \"${level}\" with message \"${message}\""
return 1
esac
}

View File

@ -0,0 +1,28 @@
#!/bin/bash --posix
# shellcheck disable=SC2120
read_sensitive() {
# Securely read input into a variable
#
# Arguments:
# READVARIABLE <type: variable> <position: 1> <required: true>
# - A variable must be passed and the output of this function will be set to that variable
# e.g: read_sensitive MYVAR
#
# Usage:
# read_sensitive SOMEVAR
#
# POSIX Compliant:
# Yes
#
stty -echo
local INPUT
read -r INPUT
stty echo
printf "\n"
eval "${1}=${INPUT}"
}
printf "Please input a password: " && read_sensitive PASSWORD_VARIABLE
echo "Received your password as ${PASSWORD_VARIABLE}"

View File

@ -39,8 +39,3 @@ bind ^Z undo main
# Rebinding redo
unbind ^R main
bind ^R redo main
## Syntax Highlighting ##
# Magic usage for syntax highlighting
magic #!/bin/bash

View File

@ -29,11 +29,11 @@ confirmation() {
while true; do
read -p "${1}" -n 1 -r choice
case "$choice" in
y|Y ) return 1;;
n|N ) return 0;;
* ) echo -e "\nInput must be either y, Y, n, or N";;
y | Y) return 1 ;;
n | N) return 0 ;;
*) echo -e "\nInput must be either y, Y, n, or N" ;;
esac
done
done
}
while :; do
@ -62,7 +62,6 @@ while :; do
shift
done
[[ "${DIRECTORY}" == "" ]] && error "A directory was not provided!"
[[ ! -d "${DIRECTORY}" ]] && error "The directory \"${DIRECTORY}\" does not exist"
@ -77,7 +76,7 @@ cp -R "Nano-Syntax-Highlighting/" "${DIRECTORY}"
NANORC_CONTENT="$(cat ./.nanorc)"
cat << EOF > ~/.nanorc
cat <<EOF >~/.nanorc
${NANORC_CONTENT}
include ${DIRECTORY}/*.nanorc"
EOF

View File

@ -1,3 +1,9 @@
// Copyright 2021, Price Hiller - All Rights Reserved
//
// Copying, distribution, usage, or modification of this file or the following source code, via any
// method is strictly prohibited without the explicit written consent of Price Hiller (philler3138@gmail.com)
// The following file contains proprietary and confidential content
##############################################################################
#
# Lua syntax highlighting for Nano.

View File

@ -1,3 +1,9 @@
// Copyright 2021, Price Hiller - All Rights Reserved
//
// Copying, distribution, usage, or modification of this file or the following source code, via any
// method is strictly prohibited without the explicit written consent of Price Hiller (philler3138@gmail.com)
// The following file contains proprietary and confidential content
## SPARQL 1.1 and SPARQL 1.1 UPDATE
#
syntax "SPARQL" ".*\.(rq|sparql)$"

43
SSH/Create-Remote-User.bash Executable file
View File

@ -0,0 +1,43 @@
#!/bin/bash --posix
set -e
# Remote System
REMOTE_SSH_SERVER=Kansas-5800X
REMOTE_HOST_NAME=208.110.85.242
REMOTE_USER_TO_CREATE=Arma
# Local System
SSH_FILE_DIRECTORY=~/.ssh
SSH_FILE_NAME=${REMOTE_USER_TO_CREATE}-id_edcsa
SSH_FILE=${SSH_FILE_DIRECTORY}/${SSH_FILE_NAME}
SSH_HOST=Kansas-5800X
ssh-keygen -b 521 -t ECDSA -f ${SSH_FILE} -N ""
chmod 600 ${SSH_FILE}
PUB_KEY_CONTENTS=$(cat ${SSH_FILE}.pub)
ssh ${REMOTE_SSH_SERVER} /bin/bash << EOF
useradd ${REMOTE_USER_TO_CREATE}
mkdir /home/${REMOTE_USER_TO_CREATE}/.ssh
touch /home/${REMOTE_USER_TO_CREATE}/.ssh/authorized_keys
echo ${PUB_KEY_CONTENTS} >> /home/${REMOTE_USER_TO_CREATE}/.ssh/authorized_keys
chown -R ${REMOTE_USER_TO_CREATE}:${REMOTE_USER_TO_CREATE} /home/${REMOTE_USER_TO_CREATE}/.ssh
EOF
cat << EOF >> ~/.ssh/config
Host ${SSH_HOST}
HostName ${REMOTE_HOST_NAME}
Match user ${REMOTE_USER_TO_CREATE}
Identityfile ${SSH_FILE}
LogLevel INFO
EOF
ssh ${REMOTE_USER_TO_CREATE}@${SSH_HOST} /bin/bash << EOF
mkdir ~/.bin
echo export PATH=$PATH:~/.bin > ~/.bash_profile
EOF
echo
echo "Finished, login via ssh with \"${REMOTE_USER_TO_CREATE}@${SSH_HOST}\""

45
SSH/SSH-Configuration.bash Executable file
View File

@ -0,0 +1,45 @@
#!/bin/bash --posix
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.back
cat << EOF | sudo tee "/etc/ssh/banner"
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Cloud Technology - Security Notice ┃
┃ ------------------------------------ ┃
┃ The following source file(s) contains confidential, ┃
┃ proprietary information. Unauthorized use is strictly ┃
┃ prohibited. No portions may be copied, reproduced, ┃
┃ or incorporated outside of this domain without ┃
┃ Cloud Hybrid LLCs or Price Hiller's ┃
┃ prior written consent. ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
EOF
cat << EOF | sudo tee /etc/ssh/sshd_config
UsePAM yes
X11Forwarding yes
PermitRootLogin yes
LogLevel INFO
SyslogFacility AUTH
AllowAgentForwarding yes
AllowTcpForwarding yes
PrintMotd no
PubkeyAuthentication yes
PasswordAuthentication no
ChallengeResponseAuthentication no
AcceptEnv LANG LC_*
Banner /etc/ssh/banner
AuthorizedKeysFile .ssh/authorized_keys
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS
Subsystem sftp /usr/libexec/openssh/sftp-server
EOF
sudo systemctl restart sshd.service