aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Williams <tgwil@tgwil.net>2024-10-13 12:43:03 -0400
committerTristan Williams <tgwil@tgwil.net>2024-10-13 12:43:03 -0400
commite774d6cbedd15d34d84e1a390d959cc55809de74 (patch)
treec05fe6ce8043e433eb7b7f9d42bb7762f84b5008
parentAdd GPG configuration (diff)
downloaddotfiles.core-e774d6cbedd15d34d84e1a390d959cc55809de74.tar.gz
dotfiles.core-e774d6cbedd15d34d84e1a390d959cc55809de74.tar.bz2
dotfiles.core-e774d6cbedd15d34d84e1a390d959cc55809de74.zip
Make messages from installer consistent and pleasing
-rwxr-xr-xnew-user-setup.sh62
1 files changed, 42 insertions, 20 deletions
diff --git a/new-user-setup.sh b/new-user-setup.sh
index 2f4ded8..7b8dbe1 100755
--- a/new-user-setup.sh
+++ b/new-user-setup.sh
@@ -12,6 +12,21 @@
12# should be cloned and run this way for every new user. 12# should be cloned and run this way for every new user.
13 13
14 14
15# Messages passed to the user by this script are in 8-char columns.
16#Created:
17#Removed:
18#Moved :
19#Skipped:
20#
21#ERROR :
22#WARNING:
23#INFO :
24#
25#File :
26#Dir :
27#Symlink:
28
29
15######################################################################## 30########################################################################
16## Setup 31## Setup
17######################################################################## 32########################################################################
@@ -26,51 +41,58 @@ ENDCOLOR="\e[0m"
26 41
27 42
28# Startup message 43# Startup message
29echo ""
30echo "### Starting dotfiles.core installation... ###" 44echo "### Starting dotfiles.core installation... ###"
31 45
32 46
33######################################################################## 47########################################################################
34## Put files into place 48## Put files into place
35######################################################################## 49########################################################################
50
36# File placement function 51# File placement function
37place_file () { 52place_file () {
38 file=$1 53 file=$1
39 target=$2 54 target=$2
40 if [[ -e $target ]]; then 55 if [[ -e $target ]]; then
41 echo -e "\n${WARN}WARNING: ${target} already exists!${ENDCOLOR}" 56 echo -e \
57 "${WARN}WARNING: File : ${target} already exists!" \
58 "[A]bort, [D]elete, [R]eplace, [S]kip: ${ENDCOLOR}"
42 invalid_selection=0 59 invalid_selection=0
43 while 60 while
44 read -p "[A]bort, [D]elete, [R]eplace, [S]kip: " -n1 selection 61 # The following echo fixes read's annoying newline that
45 echo "" 62 # messes up my nice script formatting. It sends cursor back
63 # to the "target already exists" line.
64 # \033[1A moves up to previous line.
65 # \033[1000C moves to the last column in the line up to 1000.
66 echo -en "\033[1A\033[1000C"
67 read -n1 selection
46 case $selection in 68 case $selection in
47 "a"|"A") 69 "a"|"A")
48 echo "Abort!" 70 echo "INFO : Abort!"
49 exit 0;; 71 exit 0;;
50 "d"|"D") 72 "d"|"D")
51 rm -fv $target 73 rm -fv $target
52 echo -e "${YELLOW}Removed ${target}${ENDCOLOR}" 74 echo -e "${YELLOW}Removed: File : ${target}${ENDCOLOR}"
53 ln -s $file $target 75 ln -s $file $target
54 echo -e "${GREEN}Created: ${target} -> ${file}${ENDCOLOR}" 76 echo -e "${GREEN}Created: Symlink: ${target} -> ${file}${ENDCOLOR}"
55 return 0;; 77 return 0;;
56 "r"|"R") 78 "r"|"R")
57 mv -f $target $target.bak & \ 79 mv -f $target $target.bak
58 echo -e "${YELLOW}Moved: ${target} to ${target}.bak${ENDCOLOR}" 80 echo -e "${YELLOW}Moved : File : ${target} to ${target}.bak${ENDCOLOR}"
59 ln -s $file $target & \ 81 ln -s $file $target
60 echo -e "${GREEN}Created: ${target} -> ${file}${ENDCOLOR}" 82 echo -e "${GREEN}Created: Symlink: ${target} -> ${file}${ENDCOLOR}"
61 return 0;; 83 return 0;;
62 "s"|"S") 84 "s"|"S")
63 echo -e "${YELLOW}Skipping ${target}${ENDCOLOR}" 85 echo -e "${YELLOW}Skipped: File : ${target}${ENDCOLOR}"
64 return 0;; 86 return 0;;
65 *) 87 *)
66 echo -e "${WARN}Invalid selection, try again...${ENDCOLOR}" 88 echo -e "${WARN}ERROR : Invalid selection, try again...${ENDCOLOR}"
67 invalid_selection=1;; 89 invalid_selection=1;;
68 esac 90 esac
69 [[ $invalid_selection==1 ]] 91 [[ $invalid_selection==1 ]]
70 do true; done 92 do true; done
71 else 93 else
72 ln -s $file $target 94 ln -s $file $target
73 echo -e "\n${GREEN}Created: ${target} -> ${file}${ENDCOLOR}" 95 echo -e "${GREEN}Created: File : ${target} -> ${file}${ENDCOLOR}"
74 fi 96 fi
75} 97}
76 98
@@ -78,10 +100,10 @@ place_file () {
78place_directory () { 100place_directory () {
79 directory=$1 101 directory=$1
80 if [[ -d $directory ]]; then 102 if [[ -d $directory ]]; then
81 echo -e "${YELLOW}${directory} already exists.${ENDCOLOR}" 103 echo -e "${YELLOW}Skipped: Dir : ${directory}${ENDCOLOR}"
82 else 104 else
83 mkdir -p $directory & \ 105 mkdir -p $directory
84 echo -e "${GREEN}Created: ${directory}${ENDCOLOR}" 106 echo -e "${GREEN}Created: Dir : ${directory}${ENDCOLOR}"
85 fi 107 fi
86} 108}
87 109
@@ -91,11 +113,11 @@ place_file $HOME/dotfiles.core/home/.bashrc $HOME/.bashrc
91place_file $HOME/dotfiles.core/home/.bash_aliases $HOME/.bash_aliases 113place_file $HOME/dotfiles.core/home/.bash_aliases $HOME/.bash_aliases
92 114
93# GPG Configuration 115# GPG Configuration
94place_directory $HOME/.gnupg & \ 116place_directory $HOME/.gnupg/
95 place_file $HOME/dotfiles.core/home/.gnupg/gpg-agent.conf $HOME/.gnupg/gpg-agent.conf 117place_file $HOME/dotfiles.core/home/.gnupg/gpg-agent.conf $HOME/.gnupg/gpg-agent.conf
96 118
97 119
98######################################################################## 120########################################################################
99## END OF SCRIPT 121## END OF SCRIPT
100######################################################################## 122########################################################################
101echo -e "\nInstallation completed: dotfiles.core\n" 123echo -e "INFO : Installation completed: dotfiles.core"