-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add CI config and refactor scripts to include an unattended setup * Fix github actions trigger condition * Fix chezmoi installation * Fix chezmoi init command * Fix email prompt on CI * Fix typo * Fix template common references * Fix env var * fix ci command * fix ci script * fix env var declaration * fix templates * fix unbound variable error * fix unbound variable error * make some improvements to the passwordless sudo logic and add cache to github actions * refactor passwordless sudo script to make it a bit more clear * Check if asdf dir exists * Fix typo * Add quiet flag to commands to reduce output noise * Reduce more output noise * Reduce noise from starship installation * Fix asdf installation
- Loading branch information
Showing
23 changed files
with
208 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Chezmoi Setup Validation | ||
|
||
on: | ||
push: | ||
paths-ignore: | ||
- 'LICENSE' | ||
- 'README.md' | ||
|
||
env: | ||
dev: "false" | ||
|
||
jobs: | ||
validate-chezmoi-setup: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Extract branch name | ||
shell: bash | ||
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT | ||
id: extract_branch | ||
|
||
- name: Cache asdf tools | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/.asdf | ||
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }} | ||
restore-keys: | | ||
${{ runner.os }}-asdf- | ||
|
||
- name: Initialize chezmoi with the current branch content | ||
run: sh -c "$(curl -fsLS chezmoi.io/get)" -- init --apply ${{ github.repository_owner }} --branch ${{ steps.extract_branch.outputs.branch }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
**/fish_variables | ||
home/bundle/cache | ||
config/gtk-3.0/bookmarks | ||
**/gtk-3.0/bookmarks | ||
|
||
### Python ### | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
*$py.class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{{ template "common" }} | ||
{{ template "common" . -}} | ||
|
||
bot "Setup was successfully done!" | ||
echo "Happy Coding!" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
{{ template "common" }} | ||
|
||
{{ if eq (env "dev") "true" -}} | ||
{{ template "common" . -}} | ||
{{ template "dotfile" }} | ||
|
||
bot "This script will guide you through the dofiles setup as well as installing required system packages." | ||
echo "It will not install anything without your direct agreement!" | ||
echo | ||
read -p "Do you want to proceed with the installation? [y/N] " -n 1 -r -s answer | ||
answer=$(prompt "Do you want to proceed with the installation?") | ||
echo | ||
if [[ ! $answer =~ ^[Yy]$ ]];then | ||
exit 1 | ||
fi | ||
|
||
bot "Setting dotfiles up on the home folder." | ||
echo | ||
read -p "Proceed? [y/N] " -n 1 -r -s answer | ||
echo | ||
answer=$(prompt "Proceed?") | ||
if [[ ! $answer =~ ^[Yy]$ ]];then | ||
exit 1 | ||
fi | ||
|
||
{{ end -}} |
57 changes: 57 additions & 0 deletions
57
home/.chezmoiscripts/run_once_after_00-passwordless_sudo.sh.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{{ if eq (env "dev") "true" }} | ||
{{ template "common" . }} | ||
|
||
validate_logname() { | ||
if [[ ! "$LOGNAME" =~ ^[a-zA-Z0-9][a-zA-Z0-9_-]*$ ]]; then | ||
echo "Error: LOGNAME contains invalid characters." | ||
exit 1 | ||
fi | ||
} | ||
|
||
prompt_for_sudo_if_needed() { | ||
if ! sudo -nv > /dev/null 2>&1; then | ||
echo "Please provide your sudo password:" | ||
sudo -v | ||
fi | ||
# Keep-alive: update existing sudo time stamp until the script has finished | ||
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null & | ||
} | ||
|
||
setup_passwordless_sudo() { | ||
# Determine sudoers.d directory based on OS | ||
local sudoers_d_dir="{{ if eq .osid "darwin" }}/private/etc/sudoers.d{{ else }}/etc/sudoers.d{{ end }}" | ||
local includedir_line="{{ if eq .osid "darwin" }}#includedir /private/etc/sudoers.d{{ else }}@includedir /etc/sudoers.d{{ end }}" | ||
|
||
# Check if NOPASSWD entry already exists for the user | ||
if ! sudo grep -q "NOPASSWD: ALL" "$sudoers_d_dir/$LOGNAME" > /dev/null 2>&1; then | ||
echo "No sudoer file found for passwordless operation." | ||
bot "Enabling passwordless sudo can reduce security. Are you sure you want to proceed?" | ||
answer=$(prompt "Make sudo passwordless? [y/N]") | ||
|
||
if [[ $answer =~ ^[Yy]$ ]]; then | ||
# Ensure sudoers.d is included and directory exists | ||
if ! sudo grep -q "$includedir_line" /etc/sudoers; then | ||
echo "$includedir_line" | sudo tee -a /etc/sudoers > /dev/null | ||
fi | ||
[[ ! -d "$sudoers_d_dir" ]] && sudo mkdir -p "$sudoers_d_dir" | ||
|
||
# Add NOPASSWD entry for the user | ||
local tmpfile=$(mktemp) | ||
echo "Defaults:$LOGNAME !requiretty\n$LOGNAME ALL=(ALL) NOPASSWD: ALL" > "$tmpfile" | ||
if sudo visudo -cf "$tmpfile" && sudo mv "$tmpfile" "$sudoers_d_dir/$LOGNAME"; then | ||
echo "You can now run sudo commands without a password!" | ||
else | ||
echo "Error in sudoers file" | ||
rm "$tmpfile" | ||
exit 1 | ||
fi | ||
fi | ||
else | ||
echo "Passwordless sudo already configured for $LOGNAME." | ||
fi | ||
fi | ||
|
||
validate_logname | ||
prompt_for_sudo_if_needed | ||
setup_passwordless_sudo | ||
{{ end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
home/.chezmoiscripts/run_once_after_08-starship-setup.sh.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 21 additions & 17 deletions
38
home/.chezmoiscripts/run_once_after_09-font-fira-code-setup.sh.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,29 @@ | ||
{{ if eq .chezmoi.os "linux" -}} | ||
{{- if eq .chezmoi.os "linux" -}} | ||
|
||
{{ template "common" }} | ||
{{ template "common" . }} | ||
|
||
bot "Fira Code setup." | ||
read -p "Would you like to install Fira Code NerdFont to get cool icons on the terminal? [y/N]" -n 1 -r -s answer | ||
echo | ||
if [[ $answer =~ ^[Yy]$ ]] ;then | ||
action "Downloading from https://github.com/ryanoasis/nerd-fonts/releases/download/v3.0.2/FiraCode.zip" | ||
wget https://github.com/ryanoasis/nerd-fonts/releases/download/v3.0.2/FiraCode.zip | ||
if [ -f "FiraCode.zip" ]; then | ||
action "Unzipping and adding to ~/.fonts..." | ||
unzip FiraCode.zip -d ~/.fonts | ||
fc-cache -fv | ||
action "rm -rf FiraCode.zip" | ||
rm -rf FiraCode.zip | ||
|
||
if ! fc-list | grep -qi "Fira Code" > /dev/null 2>&1; then | ||
answer=$(prompt "Would you like to install Fira Code NerdFont to get cool icons on the terminal?") | ||
if [[ $answer =~ ^[Yy]$ ]]; then | ||
action "Downloading from https://github.com/ryanoasis/nerd-fonts/releases/download/v3.0.2/FiraCode.zip" | ||
wget -q https://github.com/ryanoasis/nerd-fonts/releases/download/v3.0.2/FiraCode.zip && \ | ||
if [ -f "FiraCode.zip" ]; then | ||
action "Unzipping and adding to ~/.fonts..." | ||
unzip -q FiraCode.zip -d ~/.fonts && \ | ||
fc-cache -f > /dev/null | ||
action "Cleaning up..." | ||
rm -f FiraCode.zip | ||
else | ||
error "Download failed. FiraCode.zip not found." | ||
exit 1 | ||
fi | ||
else | ||
error "Download failed. FiraCode.zip not found." | ||
exit 1 | ||
ok "Skipping" | ||
fi | ||
else | ||
ok "Skipping" | ||
ok "Fira Code already installed!" | ||
fi | ||
|
||
{{ end -}} | ||
{{- end -}} |
10 changes: 5 additions & 5 deletions
10
home/.chezmoiscripts/run_once_after_10-gh-cli-setup.sh.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.