Commentted out some of Brave / Chrome extension stuff and updated installx

This commit is contained in:
Brian Zalewski 2024-04-01 06:56:44 +00:00
parent 9fa32d2ae6
commit 4623b0efba
2 changed files with 83 additions and 84 deletions

View file

@ -34,7 +34,7 @@ async function runScript(key, script) {
fs.writeFileSync(`${cacheDir}/${key}`, script) fs.writeFileSync(`${cacheDir}/${key}`, script)
const file = await $`cat ${cacheDir}/${key} | ( grep "^# @file" || [ "$?" == "1" ] ) | sed 's/^# @file //'` const file = await $`cat ${cacheDir}/${key} | ( grep "^# @file" || [ "$?" == "1" ] ) | sed 's/^# @file //'`
const brief = await $`cat ${cacheDir}/${key} | ( grep "^# @brief" || [ "$?" == "1" ] ) | sed 's/^# @brief //'` const brief = await $`cat ${cacheDir}/${key} | ( grep "^# @brief" || [ "$?" == "1" ] ) | sed 's/^# @brief //'`
fs.writeFileSync(`${cacheDir}/${key}-glow`, '```sh\n' + (file.stdout ? (!file.stdout && !brief.stdout ? '```sh' + '') + `# ${file.stdout}\n` : '') + (brief.stdout ? `> ${brief.stdout}\n` : '') + (file.stdout || brief.stdout ? '```sh\n' : '') + script + "\n```") fs.writeFileSync(`${cacheDir}/${key}-glow`, '```sh\n' + (file.stdout ? (!file.stdout && !brief.stdout ? '```sh' : '') + `# ${file.stdout}\n` : '') + (brief.stdout ? `> ${brief.stdout}\n` : '') + (file.stdout || brief.stdout ? '```sh\n' : '') + script + "\n```")
runSilentCommand(`glow "${cacheDir}/${key}-glow" && bash "${cacheDir}/${key}"`) runSilentCommand(`glow "${cacheDir}/${key}-glow" && bash "${cacheDir}/${key}"`)
} }

View file

@ -1215,39 +1215,38 @@ softwarePackages:
done done
### Add Chrome extension JSON ### Add Chrome extension JSON
logg info 'Populating Chrome extension JSON' # logg info 'Populating Chrome extension JSON'
for EXTENSION_DIR in "/etc/brave/extensions" "$HOME/Library/Application Support/BraveSoftware/Brave-Browser/External Extensions"; do # for EXTENSION_DIR in "/etc/brave/extensions" "$HOME/Library/Application Support/BraveSoftware/Brave-Browser/External Extensions"; do
### Ensure program-type is installed # ### Ensure program-type is installed
if [ -d "$(dirname "$EXTENSION_DIR")" ]; then # if [ -d "$(dirname "$EXTENSION_DIR")" ]; then
### Ensure extension directory exists # ### Ensure extension directory exists
if [[ "$EXTENSION_DIR" == '/opt/'* ]] || [[ "$EXTENSION_DIR" == '/etc/'* ]]; then # if [[ "$EXTENSION_DIR" == '/opt/'* ]] || [[ "$EXTENSION_DIR" == '/etc/'* ]]; then
if [ ! -d "$EXTENSION_DIR" ]; then # if [ ! -d "$EXTENSION_DIR" ]; then
logg info "Creating directory $EXTENSION_DIR" && sudo mkdir -p "$EXTENSION_DIR" # logg info "Creating directory $EXTENSION_DIR" && sudo mkdir -p "$EXTENSION_DIR"
fi # fi
else # else
if [ ! -d "$EXTENSION_DIR" ]; then # if [ ! -d "$EXTENSION_DIR" ]; then
logg info "Creating directory $EXTENSION_DIR" && mkdir -p "$EXTENSION_DIR" # logg info "Creating directory $EXTENSION_DIR" && mkdir -p "$EXTENSION_DIR"
fi # fi
fi # fi
# ### Add extension JSON
### Add extension JSON # logg info "Adding Chrome extensions to $EXTENSION_DIR"
logg info "Adding Chrome extensions to $EXTENSION_DIR" # for EXTENSION in { { list (.chromeExtensions | toString | replace "[" "" | replace "]" "") | uniq | join " " } }; do
for EXTENSION in {{ list (.chromeExtensions | toString | replace "[" "" | replace "]" "") | uniq | join " " }}; do # logg info "Adding Chrome extension manifest ($EXTENSION)"
logg info "Adding Chrome extension manifest ($EXTENSION)" # if ! echo "$EXTENSION" | grep 'https://chrome.google.com/webstore/detail/' > /dev/null; then
if ! echo "$EXTENSION" | grep 'https://chrome.google.com/webstore/detail/' > /dev/null; then # EXTENSION="https://chrome.google.com/webstore/detail/$EXTENSION"
EXTENSION="https://chrome.google.com/webstore/detail/$EXTENSION" # fi
fi # EXTENSION_ID="$(echo "$EXTENSION" | sed 's/^.*\/\([^\/]*\)$/\1/')"
EXTENSION_ID="$(echo "$EXTENSION" | sed 's/^.*\/\([^\/]*\)$/\1/')" # if [[ "$EXTENSION_DIR" == '/opt/'* ]] || [[ "$EXTENSION_DIR" == '/etc/'* ]]; then
if [[ "$EXTENSION_DIR" == '/opt/'* ]] || [[ "$EXTENSION_DIR" == '/etc/'* ]]; then # sudo cp -f "${XDG_CONFIG_HOME:-$HOME/.config}/chrome/extension.json" "$EXTENSION_DIR/${EXTENSION_ID}.json"
sudo cp -f "${XDG_CONFIG_HOME:-$HOME/.config}/chrome/extension.json" "$EXTENSION_DIR/${EXTENSION_ID}.json" # else
else # cp -f "${XDG_CONFIG_HOME:-$HOME/.config}/chrome/extension.json" "$EXTENSION_DIR/${EXTENSION_ID}.json"
cp -f "${XDG_CONFIG_HOME:-$HOME/.config}/chrome/extension.json" "$EXTENSION_DIR/${EXTENSION_ID}.json" # fi
fi # done
done # else
else # logg info "$EXTENSION_DIR does not exist"
logg info "$EXTENSION_DIR does not exist" # fi
fi # done
done
} }
chromeSetUp chromeSetUp
@ -1619,41 +1618,40 @@ softwarePackages:
fi fi
done done
### Add Chrome extension JSON # ### Add Chrome extension JSON
logg info 'Populating Chrome extension JSON' # logg info 'Populating Chrome extension JSON'
### TODO - Find `EXTENSION_DIR` for macOS in Application Support folder like `$HOME/Library/Application Support/Google/Chrome/External Extensions` for Google Chrome # ### TODO - Find `EXTENSION_DIR` for macOS in Application Support folder like `$HOME/Library/Application Support/Google/Chrome/External Extensions` for Google Chrome
for EXTENSION_DIR in "/etc/chromium/extensions"; do # for EXTENSION_DIR in "/etc/chromium/extensions"; do
### Ensure program-type is installed # ### Ensure program-type is installed
if [ -d "$(dirname "$EXTENSION_DIR")" ]; then # if [ -d "$(dirname "$EXTENSION_DIR")" ]; then
### Ensure extension directory exists # ### Ensure extension directory exists
if [[ "$EXTENSION_DIR" == '/opt/'* ]] || [[ "$EXTENSION_DIR" == '/etc/'* ]]; then # if [[ "$EXTENSION_DIR" == '/opt/'* ]] || [[ "$EXTENSION_DIR" == '/etc/'* ]]; then
if [ ! -d "$EXTENSION_DIR" ]; then # if [ ! -d "$EXTENSION_DIR" ]; then
logg info "Creating directory $EXTENSION_DIR" && sudo mkdir -p "$EXTENSION_DIR" # logg info "Creating directory $EXTENSION_DIR" && sudo mkdir -p "$EXTENSION_DIR"
fi # fi
else # else
if [ ! -d "$EXTENSION_DIR" ]; then # if [ ! -d "$EXTENSION_DIR" ]; then
logg info "Creating directory $EXTENSION_DIR" && mkdir -p "$EXTENSION_DIR" # logg info "Creating directory $EXTENSION_DIR" && mkdir -p "$EXTENSION_DIR"
fi # fi
fi # fi
# ### Add extension JSON
### Add extension JSON # logg info "Adding Chrome extensions to $EXTENSION_DIR"
logg info "Adding Chrome extensions to $EXTENSION_DIR" # for EXTENSION in {{ list (.chromeExtensions | toString | replace "[" "" | replace "]" "") | uniq | join " " }}; do
for EXTENSION in {{ list (.chromeExtensions | toString | replace "[" "" | replace "]" "") | uniq | join " " }}; do # logg info "Adding Chrome extension manifest ($EXTENSION)"
logg info "Adding Chrome extension manifest ($EXTENSION)" # if ! echo "$EXTENSION" | grep 'https://chrome.google.com/webstore/detail/' > /dev/null; then
if ! echo "$EXTENSION" | grep 'https://chrome.google.com/webstore/detail/' > /dev/null; then # EXTENSION="https://chrome.google.com/webstore/detail/$EXTENSION"
EXTENSION="https://chrome.google.com/webstore/detail/$EXTENSION" # fi
fi # EXTENSION_ID="$(echo "$EXTENSION" | sed 's/^.*\/\([^\/]*\)$/\1/')"
EXTENSION_ID="$(echo "$EXTENSION" | sed 's/^.*\/\([^\/]*\)$/\1/')" # if [[ "$EXTENSION_DIR" == '/opt/'* ]] || [[ "$EXTENSION_DIR" == '/etc/'* ]]; then
if [[ "$EXTENSION_DIR" == '/opt/'* ]] || [[ "$EXTENSION_DIR" == '/etc/'* ]]; then # sudo cp -f "${XDG_CONFIG_HOME:-$HOME/.config}/chrome/extension.json" "$EXTENSION_DIR/${EXTENSION_ID}.json"
sudo cp -f "${XDG_CONFIG_HOME:-$HOME/.config}/chrome/extension.json" "$EXTENSION_DIR/${EXTENSION_ID}.json" # else
else # cp -f "${XDG_CONFIG_HOME:-$HOME/.config}/chrome/extension.json" "$EXTENSION_DIR/${EXTENSION_ID}.json"
cp -f "${XDG_CONFIG_HOME:-$HOME/.config}/chrome/extension.json" "$EXTENSION_DIR/${EXTENSION_ID}.json" # fi
fi # done
done # else
else # logg info "$EXTENSION_DIR does not exist"
logg info "$EXTENSION_DIR does not exist" # fi
fi # done
done
} }
chromeSetUp chromeSetUp
@ -3041,19 +3039,19 @@ softwarePackages:
# SSH port. It is intended to break unsophisticated malware that targets SSH. # SSH port. It is intended to break unsophisticated malware that targets SSH.
# #
# If the `endlessh` program is installed, this script applies the configuration stored in `home/private_dot_ssh/endlessh/config.tmpl` # If the `endlessh` program is installed, this script applies the configuration stored in `home/private_dot_ssh/endlessh/config.tmpl`
# (that unpacks with Chezmoi to `~/.ssh/endlessh/config`) to the system location and then starts the service. # (that unpacks with Chezmoi to `~/.ssh/endlessh/config`) to the system location and then starts the service.
# #
# **Note:** _This script runs under the assumption that the actual SSH port which is defined in `home/.chezmoidata.yaml` # **Note:** _This script runs under the assumption that the actual SSH port which is defined in `home/.chezmoidata.yaml`
# is assigned to a non-standard port like 2214. This allows the default port to be used for `endlessh`._ # is assigned to a non-standard port like 2214. This allows the default port to be used for `endlessh`._
# #
# ## Links # ## Links
@ -3169,15 +3167,14 @@ softwarePackages:
### Import environment variables into `envchain` ### Import environment variables into `envchain`
if command -v envchain > /dev/null; then if command -v envchain > /dev/null; then
if [ -f "$HOME/.config/age/chezmoi.txt" ]; then
{{- if (stat (joinPath .host.home ".config" "age" "chezmoi.txt")) }} logg info 'Importing environment variables into the System keyring'
logg info 'Importing environment variables into the System keyring' for file in {{ joinPath .chezmoi.sourceDir ".chezmoitemplates" "secrets" "*" }}; do
for file in {{ joinPath .chezmoi.sourceDir ".chezmoitemplates" "secrets" "*" }}; do cat "$file" | chezmoi decrypt | envchain -s default "$(basename $file)" > /dev/null || logg info 'Importing "$(basename $file)" failed'
cat "$file" | chezmoi decrypt | envchain -s default "$(basename $file)" > /dev/null || logg info 'Importing "$(basename $file)" failed' done
done else
{{- else }} logg warn 'Unable to import any variables into envchain because ~/.config/age/chezmoi.txt was not created by the secrets encryption process yet'
logg warn 'Unable to import any variables into envchain because ~/.config/age/chezmoi.txt was not created by the secrets encryption process yet' fi
{{- end }}
else else
logg info 'envchain is not installed or it is not available in the PATH' logg info 'envchain is not installed or it is not available in the PATH'
@ -4791,9 +4788,11 @@ softwarePackages:
else else
logg info 'Creating runner configuration' logg info 'Creating runner configuration'
### Configure labels ### Configure labels
LABELS="self-hosted,{{ .chezmoi.hostname }},{{ .host.distro.family }}" HOST_DISTRO_FAMILY="$(yq '.data.host.distro.family' "${XDG_CONFIG_HOME:-$HOME/.config}/chezmoi/chezmoi.yaml")"
if [ '{{ .host.distro.family }}' != '{{ .host.distro.id }}' ]; then HOST_DISTRO_ID="$(yq '.data.host.distro.id' "${XDG_CONFIG_HOME:-$HOME/.config}/chezmoi/chezmoi.yaml")"
LABELS="${LABELS},{{ .host.distro.id }}" LABELS="self-hosted,$(yq '.data.host.hostname' "${XDG_CONFIG_HOME:-$HOME/.config}/chezmoi/chezmoi.yaml"),$HOST_DISTRO_FAMILY"
if [ "$HOST_DISTRO_FAMILY" != "$HOST_DISTRO_ID" ]; then
LABELS="${LABELS},$HOST_DISTRO_ID"
fi fi
if command -v VirtualBox > /dev/null; then if command -v VirtualBox > /dev/null; then
LABELS="${LABELS},virtualbox" LABELS="${LABELS},virtualbox"