From 041f5bc97d9835367daa7430cc857aa14ea40354 Mon Sep 17 00:00:00 2001 From: Pratham Patel Date: Mon, 20 Nov 2023 17:58:25 +0530 Subject: [PATCH] improve the dotfiles setup --- includes/post/user-setup.ksi | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/includes/post/user-setup.ksi b/includes/post/user-setup.ksi index 3b96a64..22b0d93 100644 --- a/includes/post/user-setup.ksi +++ b/includes/post/user-setup.ksi @@ -24,9 +24,23 @@ echo -e "${USER_PASSWORD}\n${USER_PASSWORD}" | passwd "${USER_NAME}" sed -i "s/# %wheel\tALL=(ALL)\tNOPASSWD: ALL/%wheel\tALL=(ALL)\tNOPASSWD: ALL/" /etc/sudoers # dotfiles -sudo -i -u "${USER_NAME}" git clone --bare https://gitlab.com/thefossguy/dotfiles.git "/home/${USER_NAME}/.dotfiles" -sudo -i -u "${USER_NAME}" git --git-dir="/home/${USER_NAME}/.dotfiles" --work-tree="/home/${USER_NAME}" checkout -f -rm -rf "/home/${USER_NAME}/.config/nvim" +cat << EOF > get-dotfiles.sh +#!/usr/bin/env bash + +set -x +if [[ "$(id -u)" -eq 0 ]]; then + echo "Not gonna run as root" + exit 1 +fi + +echo "Hi $USER" +git clone --bare https://gitlab.com/thefossguy/dotfiles.git "${HOME}/.dotfiles" +git --git-dir="${HOME}/.dotfiles" --work-tree="${HOME}" checkout -f +rm -rf "${HOME}/.config/nvim" +EOF +chmod +x get-dotfiles.sh +sudo -i -u "${USER_NAME}" bash get-dotfiles.sh +rm -vf get-dotfiles.sh # Lock the root account passwd -l root