This commit is contained in:
Brian Zalewski 2023-07-15 05:28:48 +00:00
parent b9df102d73
commit be03797995
15 changed files with 108 additions and 28 deletions

View file

@ -210,6 +210,7 @@ data:
timezone: "{{ $timezone }}"
tinypngKey: "g355tx7dxG5yJfl0RXJnpQlQqk88dJBv"
username: "{{ default "user" (env "USER") }}"
weatherZipCode: 07960
diff:
format: "git"
pager: "delta"

View file

@ -66,6 +66,12 @@
type = "file"
url = "https://gitlab.com/megabyte-labs/gas-station/-/raw/master/environments/prod/group_vars/all/helm.yml"
refreshPeriod = "{{ $refreshPeriod }}"
[".local/share/blesh"]
type = "git-repo"
url = "https://github.com/akinomyoga/ble.sh.git"
refreshPeriod = "{{ $refreshPeriod }}"
clone.args = ["--depth", "1"]
pull.args = ["--ff-only"]
[".local/share/bash_it"]
type = "git-repo"
url = "https://github.com/Bash-it/bash-it.git"

View file

@ -54,7 +54,7 @@
{{- $softwareList := list (index .softwareGroups $softwareGroup | toString | replace "[" "" | replace "]" "") | uniq | join " " -}}
{{- $secretKey := "" -}}
{{- if (stat (joinPath (.chezmoi.sourceDir ".chezmoitemplates" "secrets" "VMWARE_WORKSTATION_LICENSE_KEY"))) -}}
{{- if (stat (joinPath .chezmoi.sourceDir ".chezmoitemplates" "secrets" "VMWARE_WORKSTATION_LICENSE_KEY")) -}}
{{- $secretKey = (default "4C21U-2KK9Q-M8130-4V2QH-CF810" (includeTemplate "secrets/VMWARE_WORKSTATION_LICENSE_KEY" | decrypt | trim)) -}}
{{- else -}}
{{- $secretKey = (default "4C21U-2KK9Q-M8130-4V2QH-CF810" (env "VMWARE_WORKSTATION_LICENSE_KEY")) -}}

View file

@ -15,6 +15,12 @@ if ! command -v powerline > /dev/null; then
install-software powerline > /dev/null
fi
### Ensure ble.sh installed
if [ -d "${XDG_DATA_HOME:-$HOME/.local/share}/ble.sh" ] && [ ! ]; then
logg info "${XDG_DATA_HOME:-$HOME/.local/share}/ble.sh present and ${XDG_DATA_HOME:-$HOME/.local/share}/blesh not present - installing ble.sh..."
make -C "${XDG_DATA_HOME:-$HOME/.local/share}/ble.sh" install > /dev/null && logg success "Installed ble.sh"
fi
### Bash-it completions / plugins
if command -v powerline > /dev/null && [ -f "$HOME/.bashrc" ]; then
# These three lines are probably not needed:
@ -26,6 +32,8 @@ if command -v powerline > /dev/null && [ -f "$HOME/.bashrc" ]; then
if ! command -v bash-it > /dev/null; then
logg info 'Installing `bash-it` since it is not available yet as a command'
bash "$BASH_IT/install.sh" --silent --no-modify-config
else
logg info '`bash-it` already available'
fi
### Ensure completions are enabled
@ -33,9 +41,10 @@ if command -v powerline > /dev/null && [ -f "$HOME/.bashrc" ]; then
logg info 'Enabling bash-it completions'
# TODO: Move these plugins to the .chezmoidata.yaml
for COMPLETION in defaults dirs docker docker-compose export git makefile ng npm ssh system vagrant; do
if ! ls "$BASH_IT/enabled" | grep "$COMPLETION" > /dev/null; then
echo y | bash-it enable completion dirs > /dev/null && logg info "Enabled the bash-it $COMPLETION completion plugin" || logg error "Failed to install the $COMPLETION bash-it completion plugin"
if ls "$BASH_IT/enabled" | grep "$COMPLETION" > /dev/null; then
rm -f "$BASH_IT/enabled/"*"$COMPLETION"* > /dev/null && logg info "Removed old $COMPLETION bash-it completion symlink" || logg error "Failed to remove $COMPLETION bash-it completion symlink"
fi
echo y | bash-it enable completion "$COMPLETION" > /dev/null && logg info "Enabled the bash-it $COMPLETION completion plugin" || logg error "Failed to install the $COMPLETION bash-it completion plugin"
done
### Ensure plugins are enabled
@ -43,8 +52,9 @@ if command -v powerline > /dev/null && [ -f "$HOME/.bashrc" ]; then
# TODO: Move these plugins to the .chezmoidata.yaml
for PLUGIN in base blesh browser cht-sh dirs gitstatus powerline sudo xterm; do
if ls "$BASH_IT/enabled" | grep "$PLUGIN" > /dev/null; then
echo y | bash-it enable plugin "$PLUGIN" > /dev/null && logg info "Enabled the bash-it $PLUGIN plugin" || logg error "Failed to install the $PLUGIN bash-it plugin"
rm -f "$BASH_IT/enabled/"*"$PLUGIN"* > /dev/null && logg info "Removed old $PLUGIN bash-it plugin symlink" || logg error "Failed to remove $PLUGIN bash-it plugin symlink"
fi
echo y | bash-it enable plugin "$PLUGIN" > /dev/null && logg info "Enabled the bash-it $PLUGIN plugin" || logg error "Failed to install the $PLUGIN bash-it plugin"
done
else
logg warn 'The path specified by BASH_IT does not exist yet'

View file

@ -176,7 +176,7 @@ if command -v warp-cli > /dev/null; then
if command -v gcloud > /dev/null; then
logg info "Configuring gcloud to use "${XDG_DATA_HOME:-$HOME/.local/share}/warp/Cloudflare_CA.pem" and "${XDG_DATA_HOME:-$HOME/.local/share}/curl/cacert.pem""
mkdir -p "${XDG_DATA_HOME:-$HOME/.local/share}/gcloud"
cat cacert.pem "${XDG_DATA_HOME:-$HOME/.local/share}/warp/Cloudflare_CA.pem" > "${XDG_DATA_HOME:-$HOME/.local/share}/gcloud/ca.pem"
cat "${XDG_DATA_HOME:-$HOME/.local/share}/curl/cacert.pem" "${XDG_DATA_HOME:-$HOME/.local/share}/warp/Cloudflare_CA.pem" > "${XDG_DATA_HOME:-$HOME/.local/share}/gcloud/ca.pem"
gcloud config set core/custom_ca_certs_file "${XDG_DATA_HOME:-$HOME/.local/share}/gcloud/ca.pem"
fi

View file

@ -17,6 +17,11 @@ if [ -f "$HOME/.config/shell/profile.sh" ]; then
. "$HOME/.config/shell/profile.sh"
fi
### /etc/bashrc
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
### Escape if shell not interactive
case $- in
*i*) ;;
@ -37,11 +42,6 @@ if [ -d "$HISTFILE" ]; then
rm -rf "$HISTFILE"
fi
### /etc/bashrc
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
### Bash Initialization Hooks
if [ "$BASH_SUPPORT" = 'true' ]; then
# Prompt (on bash only)
@ -142,6 +142,6 @@ if [ "$BASH_SUPPORT" = 'true' ]; then
### zoxide
if command -v zoxide > /dev/null; then
eval "$(zoxide init --cmd cd bash )"
eval "$(zoxide init --cmd cd bash)"
fi
fi

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<service>
<short>Plex</short>
<description>.</description>
<description>Plex media center</description>
<port protocol="udp" port="1900"/> # Plex DLNA Server
<port protocol="tcp" port="32469"/> # Plex DLNA Server
<port protocol="udp" port="32410-32414"/> # GDM Network Discovery

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<service>
<short>RustDesk</short>
<description>RustDesk remote desktop software (server)</description>
<port protocol="udp" port="21116"/>
<port protocol="tcp" port="8000"/>
<port protocol="tcp" port="21115-21119"/>
</service>

View file

@ -0,0 +1,4 @@
[RustDesk]
title=RustDesk
description=RustDesk server
ports=21116/udp|8000/tcp|21115:21119/tcp

View file

@ -8,9 +8,9 @@
### macOS Polyfills
# Note: May cause conflicts
if command -v brew > /dev/null; then
PATH="$(brew --prefix)/opt/coreutils/libexec/gnubin:$PATH"
PATH="$(brew --prefix)/opt/gnu-indent/libexec/gnubin:$PATH"
PATH="$(brew --prefix)/opt/gnu-sed/libexec/gnubin:$PATH"
export PATH="$(brew --prefix)/opt/coreutils/libexec/gnubin:$PATH"
export PATH="$(brew --prefix)/opt/gnu-indent/libexec/gnubin:$PATH"
export PATH="$(brew --prefix)/opt/gnu-sed/libexec/gnubin:$PATH"
fi
{{- end }}

View file

@ -33,7 +33,7 @@ frontend=ascii-art-table
jsn-no-indent=false
# LOCATION to be queried (default 40.748,-73.985)
location=Morristown, NJ
location={{ .user.weatherZipCode }}
# md-frontend: Show geo coordinates (default false)
md-coords=false

View file

@ -12,13 +12,21 @@
# Check if the script is being run as root
if [[ $EUID -ne 0 ]]; then
echo -e "\e[91mThis script must be run as root\e[0m"
exit 1
if command -v logg > /dev/null; then
logg error "This script must be run as root"
else
echo -e "\e[91mThis script must be run as root\e[0m"
fi
exit 1
fi
# Check if the correct number of arguments is provided
if [[ $# -ne 1 ]]; then
echo -e "\e[93mUsage: $0 <group>\e[0m"
if command -v logg > /dev/null; then
logg info "Usage: $0 <group>"
else
echo -e "\e[93mUsage: $0 <group>\e[0m"
fi
exit 1
fi
@ -26,7 +34,11 @@ GROUP=$1
# Check if the operating system is macOS
if [[ "$(uname)" == "Darwin" ]]; then
echo -e "\e[96mCreating group and user ${GROUP} on macOS...\e[0m"
if command -v logg > /dev/null; then
logg info "Creating group and user ${GROUP} on macOS..."
else
echo -e "\e[96mCreating group and user ${GROUP} on macOS...\e[0m"
fi
# Check if the group already exists
if ! sudo dscl . read /Groups/"${GROUP}" >/dev/null 2>&1; then
@ -39,7 +51,11 @@ if [[ "$(uname)" == "Darwin" ]]; then
sudo dscl . create /Groups/"${GROUP}" gid "$GROUP_ID"
fi
else
echo -e "\e[93mGroup ${GROUP} already exists\e[0m"
if command -v logg > /dev/null; then
logg info "Group ${GROUP} already exists."
else
echo -e "\e[93mGroup ${GROUP} already exists\e[0m"
fi
fi
# Check if the user already exists
@ -62,20 +78,36 @@ if [[ "$(uname)" == "Darwin" ]]; then
# Add the current user to the group
sudo dseditgroup -o edit -t user -a "${USER}" "${GROUP}"
else
echo -e "\e[93mUser ${GROUP} already exists\e[0m"
if command -v logg > /dev/null; then
logg info "User ${GROUP} already exists"
else
echo -e "\e[93mUser ${GROUP} already exists\e[0m"
fi
fi
echo -e "\e[92mGroup and user ${GROUP} created successfully on macOS\e[0m"
if command -v logg > /dev/null; then
logg info "Group and user ${GROUP} created successfully on macOS"
else
echo -e "\e[92mGroup and user ${GROUP} created successfully on macOS\e[0m"
fi
exit 0
elif [[ "$(uname)" == "Linux" ]]; then
echo -e "\e[96mCreating group and user ${GROUP} on Linux...\e[0m"
if command -v logg > /dev/null; then
logg info "Creating group and user ${GROUP} on Linux..."
else
echo -e "\e[96mCreating group and user ${GROUP} on Linux...\e[0m"
fi
# Check if the group already exists
if ! grep -qE "^${GROUP}:" /etc/group; then
# Create the group
groupadd "${GROUP}"
else
echo -e "\e[93mGroup ${GROUP} already exists\e[0m"
if command -v logg > /dev/null; then
logg info "Group ${GROUP} already exists"
else
echo -e "\e[93mGroup ${GROUP} already exists\e[0m"
fi
fi
# Check if the user already exists
@ -83,13 +115,25 @@ elif [[ "$(uname)" == "Linux" ]]; then
# Create the user and assign it to the group
useradd -g "${GROUP}" "${GROUP}"
else
echo -e "\e[93mUser ${GROUP} already exists\e[0m"
if command -v logg > /dev/null; then
logg info "User ${GROUP} already exists"
else
echo -e "\e[93mUser ${GROUP} already exists\e[0m"
fi
fi
echo -e "\e[92mGroup and user ${GROUP} created successfully on Linux\e[0m"
if command -v logg > /dev/null; then
logg success "Group and user ${GROUP} created successfully on Linux"
else
echo -e "\e[92mGroup and user ${GROUP} created successfully on Linux\e[0m"
fi
exit 0
fi
# If the operating system is neither macOS nor Linux, display an error message
echo -e "\e[91mUnsupported operating system\e[0m"
if command -v logg > /dev/null; then
logg error "Unsupported operating system"
else
echo -e "\e[91mUnsupported operating system\e[0m"
fi
exit 1

View file

@ -0,0 +1,3 @@
{{- if (eq .host.distro.family "darwin") -}}
/bin/stty
{{- end -}}

View file

@ -22,6 +22,10 @@ ingress:
service: localhost:8445
- hostname: vnc.{{ $baseDomain }}
service: tcp://localhost:5901
{{- if eq .host.softwareGroup "Kubernetes" }}
- hostname: k8s.{{ .host.domain }}
service: bastion
{{- end }}
# Example of an HTTP request over a Unix socket:
# - hostname: {{ $baseDomain }}
# service: unix:/home/production/echo.sock