-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-root.sh
executable file
·65 lines (55 loc) · 1.63 KB
/
install-root.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
#!/bin/sh
if [ "$REPOHUB" = '' ]; then
REPOHUB="$(printf "$(dirname $0)/../" | xargs realpath)";
else
_util_source_force=1
fi
. "$REPOHUB"/util.sh
check_is_root
_help() {
printf "Usage:\n"
printf " -h --help Displays this message\n"
printf " -y --noconfim Skips confirmations\n"
exit 1
}
handle_args '-y|--noconfirm=export YOLO=1' "$@"
# If path starts with %, will not override
COPY_FROM_TO="\
.config/nvim \
.config/fish \
.zshrc \
.bashrc \
.config/at-login.sh \
.config/aliases.sh \
.config/.bash-preexec.sh \
"
info_garr "Installing dotfiles for root..."
for path in $COPY_FROM_TO; do
_continue=0
path="$(echo "$path" | tr '|' ' ')"
override=1
if [ "$(echo "$path" | head -c +1)" = '%' ]; then
override=0;
path="$(echo "$path" | tail -c +2)";
fi
from="$REPOHUB/dotfiles/user/$path"
dest="/root/$path"
if [ "$override" = '1' ] || [ ! -e "$dest" ]; then
if [ -h "$dest" ]; then unlink "$dest"; fi
if [ -e "$dest" ]; then
[ "$YOLO" = '0' ] && confirm 'Y barr' "Do you want to override <path>${dest}</path> ?" "rm -rf $dest" 'export _continue=1';
# shellcheck disable=SC2154
[ "$_continue" = '1' ] && continue
fi
mkdir -p "$(dirname "$dest" | head --lines 1)"
info_barr "Copying <path>$path</path>"
cp -rf "$from" "$dest"
chown_root "$dest"
fi
done
# Update nvim plugins if there is internet
if nc -z 8.8.8.8 53 -w 1; then
info_barr 'Updating neovim plugins...'
timeout 20s nvim --headless "+Lazy! sync" +qa > /dev/null 2>&1
info 'Done'
fi