Skip to content

Commit

Permalink
fix(executable_dotfiles-install-apt-pkgs): add ability to run script …
Browse files Browse the repository at this point in the history
…to add APT repositories
  • Loading branch information
entelecheia committed Aug 23, 2023
1 parent c5f08fc commit c1d3ed2
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions chezmoi/dot_local/bin/executable_dotfiles-install-apt-pkgs.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,24 @@ SOURCE_LIST_LINE="{{ .source_list_line }}"
{{- else }}
SOURCE_LIST_LINE=""
{{- end }}
if [[ ! -f "${SOURCE_LIST_FILE}" ]] && [[ -n "${SOURCE_LIST_LINE}" ]] && is_item_in_array "${PKG_NAME}" "${wanted_packages[@]}"; then
log_task "Adding {{ .source_list_file }} repository to APT"
if [ "$USER" = "root" ]; then
c echo "$SOURCE_LIST_LINE" | tee "$SOURCE_LIST_FILE"
{{- if and (hasKey . "source_list_script") (.source_list_script) }}
SOURCE_LIST_SCRIPT="{{ .source_list_script }}"
{{- else }}
SOURCE_LIST_SCRIPT=""
{{- end }}
if [[ ! -f "${SOURCE_LIST_FILE}" ]] && is_item_in_array "${PKG_NAME}" "${wanted_packages[@]}"; then
if [[ -n "${SOURCE_LIST_SCRIPT}" ]]; then
log_task "Running {{ .source_list_file }} repository script"
c "${SOURCE_LIST_SCRIPT}"
elif [[ -n "${SOURCE_LIST_LINE}" ]]; then
log_task "Adding {{ .source_list_file }} repository to APT"
if [ "$USER" = "root" ]; then
c echo "$SOURCE_LIST_LINE" | tee "$SOURCE_LIST_FILE"
else
c echo "$SOURCE_LIST_LINE" | sudo tee "$SOURCE_LIST_FILE"
fi
else
c echo "$SOURCE_LIST_LINE" | sudo tee "$SOURCE_LIST_FILE"
log_error "No source list line or script provided for {{ .source_list_file }}"
fi
fi
{{- end }}
Expand Down

0 comments on commit c1d3ed2

Please sign in to comment.