From be03797995e59d9251e0e72f1c9cca26a65afeb7 Mon Sep 17 00:00:00 2001 From: Brian Zalewski <59970525+ProfessorManhattan@users.noreply.github.com> Date: Sat, 15 Jul 2023 05:28:48 +0000 Subject: [PATCH] Latest --- home/.chezmoi.yaml.tmpl | 1 + home/.chezmoiexternal.toml.tmpl | 6 ++ .../run_onchange_after_45-vmware.sh.tmpl | 2 +- .../run_onchange_after_94-bash-it.sh.tmpl | 16 ++++- .../run_onchange_after_97-cloudflare.sh.tmpl | 2 +- home/dot_bashrc | 12 ++-- .../firewall/etc/firewalld/services/plex.xml | 2 +- .../firewalld/services/rustdesk-server.xml | 8 +++ .../etc/ufw/applications.d/rustdesk-server | 4 ++ home/dot_config/shell/aliases.sh.tmpl | 6 +- home/dot_config/wego/wegorc.tmpl | 2 +- home/dot_local/bin/executable_add-user | 68 +++++++++++++++---- .../bin/{executable_open => executable_openn} | 0 home/dot_local/bin/symlink_stty.tmpl | 3 + .../etc/cloudflared/config.yaml.tmpl | 4 ++ 15 files changed, 108 insertions(+), 28 deletions(-) create mode 100644 home/dot_config/firewall/etc/firewalld/services/rustdesk-server.xml create mode 100644 home/dot_config/firewall/etc/ufw/applications.d/rustdesk-server rename home/dot_local/bin/{executable_open => executable_openn} (100%) create mode 100644 home/dot_local/bin/symlink_stty.tmpl diff --git a/home/.chezmoi.yaml.tmpl b/home/.chezmoi.yaml.tmpl index 32037f6d..411766c3 100644 --- a/home/.chezmoi.yaml.tmpl +++ b/home/.chezmoi.yaml.tmpl @@ -210,6 +210,7 @@ data: timezone: "{{ $timezone }}" tinypngKey: "g355tx7dxG5yJfl0RXJnpQlQqk88dJBv" username: "{{ default "user" (env "USER") }}" + weatherZipCode: 07960 diff: format: "git" pager: "delta" diff --git a/home/.chezmoiexternal.toml.tmpl b/home/.chezmoiexternal.toml.tmpl index 6a968379..dfbf4b08 100644 --- a/home/.chezmoiexternal.toml.tmpl +++ b/home/.chezmoiexternal.toml.tmpl @@ -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" diff --git a/home/.chezmoiscripts/universal/run_onchange_after_45-vmware.sh.tmpl b/home/.chezmoiscripts/universal/run_onchange_after_45-vmware.sh.tmpl index e0816b07..24a726f9 100644 --- a/home/.chezmoiscripts/universal/run_onchange_after_45-vmware.sh.tmpl +++ b/home/.chezmoiscripts/universal/run_onchange_after_45-vmware.sh.tmpl @@ -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")) -}} diff --git a/home/.chezmoiscripts/universal/run_onchange_after_94-bash-it.sh.tmpl b/home/.chezmoiscripts/universal/run_onchange_after_94-bash-it.sh.tmpl index edcf0790..953cdd2f 100644 --- a/home/.chezmoiscripts/universal/run_onchange_after_94-bash-it.sh.tmpl +++ b/home/.chezmoiscripts/universal/run_onchange_after_94-bash-it.sh.tmpl @@ -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' diff --git a/home/.chezmoiscripts/universal/run_onchange_after_97-cloudflare.sh.tmpl b/home/.chezmoiscripts/universal/run_onchange_after_97-cloudflare.sh.tmpl index b6e49f71..c79e0aaa 100644 --- a/home/.chezmoiscripts/universal/run_onchange_after_97-cloudflare.sh.tmpl +++ b/home/.chezmoiscripts/universal/run_onchange_after_97-cloudflare.sh.tmpl @@ -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 diff --git a/home/dot_bashrc b/home/dot_bashrc index 76bc801a..e2ee3313 100644 --- a/home/dot_bashrc +++ b/home/dot_bashrc @@ -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 diff --git a/home/dot_config/firewall/etc/firewalld/services/plex.xml b/home/dot_config/firewall/etc/firewalld/services/plex.xml index 8193592d..f040ed86 100644 --- a/home/dot_config/firewall/etc/firewalld/services/plex.xml +++ b/home/dot_config/firewall/etc/firewalld/services/plex.xml @@ -1,7 +1,7 @@ Plex - . + Plex media center # Plex DLNA Server # Plex DLNA Server # GDM Network Discovery diff --git a/home/dot_config/firewall/etc/firewalld/services/rustdesk-server.xml b/home/dot_config/firewall/etc/firewalld/services/rustdesk-server.xml new file mode 100644 index 00000000..893da125 --- /dev/null +++ b/home/dot_config/firewall/etc/firewalld/services/rustdesk-server.xml @@ -0,0 +1,8 @@ + + + RustDesk + RustDesk remote desktop software (server) + + + + \ No newline at end of file diff --git a/home/dot_config/firewall/etc/ufw/applications.d/rustdesk-server b/home/dot_config/firewall/etc/ufw/applications.d/rustdesk-server new file mode 100644 index 00000000..92478c36 --- /dev/null +++ b/home/dot_config/firewall/etc/ufw/applications.d/rustdesk-server @@ -0,0 +1,4 @@ +[RustDesk] +title=RustDesk +description=RustDesk server +ports=21116/udp|8000/tcp|21115:21119/tcp \ No newline at end of file diff --git a/home/dot_config/shell/aliases.sh.tmpl b/home/dot_config/shell/aliases.sh.tmpl index 6e7529d7..dccc2cd1 100644 --- a/home/dot_config/shell/aliases.sh.tmpl +++ b/home/dot_config/shell/aliases.sh.tmpl @@ -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 }} diff --git a/home/dot_config/wego/wegorc.tmpl b/home/dot_config/wego/wegorc.tmpl index 8999bd7b..4744723d 100644 --- a/home/dot_config/wego/wegorc.tmpl +++ b/home/dot_config/wego/wegorc.tmpl @@ -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 diff --git a/home/dot_local/bin/executable_add-user b/home/dot_local/bin/executable_add-user index a8e2c6fb..9d9dc26e 100644 --- a/home/dot_local/bin/executable_add-user +++ b/home/dot_local/bin/executable_add-user @@ -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 \e[0m" + if command -v logg > /dev/null; then + logg info "Usage: $0 " + else + echo -e "\e[93mUsage: $0 \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 diff --git a/home/dot_local/bin/executable_open b/home/dot_local/bin/executable_openn similarity index 100% rename from home/dot_local/bin/executable_open rename to home/dot_local/bin/executable_openn diff --git a/home/dot_local/bin/symlink_stty.tmpl b/home/dot_local/bin/symlink_stty.tmpl new file mode 100644 index 00000000..1f4bb1f8 --- /dev/null +++ b/home/dot_local/bin/symlink_stty.tmpl @@ -0,0 +1,3 @@ +{{- if (eq .host.distro.family "darwin") -}} +/bin/stty +{{- end -}} \ No newline at end of file diff --git a/home/dot_local/etc/cloudflared/config.yaml.tmpl b/home/dot_local/etc/cloudflared/config.yaml.tmpl index 05d625ea..7de466b8 100644 --- a/home/dot_local/etc/cloudflared/config.yaml.tmpl +++ b/home/dot_local/etc/cloudflared/config.yaml.tmpl @@ -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