Skip to main content

View / Edit on GitHub: home/.chezmoiscripts/universal/run_after_15-chezmoi-system.sh.tmpl

System Files

Applies the files stored at ${XDG_CONFIG_HOME:-$HOME/.config}/system to the base file system

Overview

This script applies the files stored at ${XDG_CONFIG_HOME:-$HOME/.config}/system to the base file system. This way, you can store your system files in your ~/.config folder.

Script Functions

systemFiles

Copies system files over to root file system

Source Code

#!/usr/bin/env bash
# @file System Files
# @brief Applies the files stored at `${XDG_CONFIG_HOME:-$HOME/.config}/system` to the base file system
# @description
# This script applies the files stored at `${XDG_CONFIG_HOME:-$HOME/.config}/system` to the
# base file system. This way, you can store your system files in your `~/.config` folder.

# @description
# Copies system files over to root file system
systemFiles() {
gum log -sl info 'Running sudo rsync -artuE --chown=root:root --chmod=Du=rwx,Dg=rx,Do=rx,Fu=rwX,Fg=rX,Fo=rX \ --inplace --exclude .git/ "${XDG_CONFIG_HOME:-$HOME/.config}/system/" /'
sudo rsync -artuE --chown=root:root --chmod=Du=rwx,Dg=rx,Do=rx,Fu=rwX,Fg=rX,Fo=rX --inplace --exclude .git/ "${XDG_CONFIG_HOME:-$HOME/.config}/system/" / > /dev/null
gum log -sl info 'Finished applying system configuration files'
}

if [ -n "$DEBUG" ] || [ -n "$DEBUG_MODE" ]; then
gum log -sl info 'The DEBUG or DEBUG_MODE environment variable is set so the chezmoi-system tasks will be run synchronously'
systemFiles
else
systemFiles &
wait
fi