-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·91 lines (81 loc) · 2.57 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
#
#*****************************************************************
# dotfiles install.sh - equk.co.uk
#*****************************************************************
# Copyright (C) 2019 B.Walden
#*****************************************************************
# This script was made as an alternative to using multiple
# symlinks for the syncing of dotfiles to github.
# The script simply copies files from the /configs directory
#*****************************************************************
# NOTES:
# This script will prompt before overwriting existing configs
#*****************************************************************
# LICENSE: MIT
#*****************************************************************
# COLORS
blue="\033[1;34m"
green="\033[1;32m"
red="\033[1;31m"
bold="\033[1;37m"
reset="\033[0m"
# CLI FEEDBACK
gplus="[$green+$reset]"
bplus="[$blue+$reset]"
rplus="[$red+$reset]"
# CHECK ROOT USER
if [ $(id -u) -eq 0 ]; then
echo -e "$red ERROR:$reset do not run this script as root"
exit 1
fi
if [ $(whoami) = "root" ]; then
echo -e "$red ERROR:$reset do not run this script as root"
exit 1
fi
# COPY FUNC
function copy() {
if [ -f $1 ]; then
ORIGIN=$1
DESTINATION=$(echo "$ORIGIN" | sed "s#^\./configs/#$HOME/#")
mkdir -p $(dirname "$DESTINATION")
if [ -a "$DESTINATION" ]; then
if diff "$ORIGIN" "$DESTINATION" >/dev/null; then
echo -e "$bplus $DESTINATION already up to date"
return 2
fi
while true; do
echo -e "$rplus $DESTINATION already exists"
read -p "!!! Overwrite it? [Y/N]" yn
case $yn in
[Yy]*)
echo -e "$gplus Copying $ORIGIN to $DESTINATION"
cp "$ORIGIN" "$DESTINATION"
return 2
;;
[Nn]*) return 2 ;;
*) echo -e "$rplus Expected yes or no." ;;
esac
done
else
echo -e "$gplus Copying $ORIGIN to $DESTINATION"
cp "$ORIGIN" "$DESTINATION"
fi
else
echo "$red ERROR:$reset '$1' does not exist"
fi
}
# BANNER
echo -e ""
echo -e "equk $red::$reset linux dotfiles install"
echo -e "------------------------------"
echo -e ""
echo -e " $green git:$reset https://github.com/equk"
echo -e " $blue web:$reset https://equk.co.uk"
echo -e ""
echo -e "$green+++$reset installing equk dotfiles"
echo -e ""
# COPY CONFIG FILES
for file in $(find ./configs -type f); do
copy $file
done