-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.bash
More file actions
executable file
·81 lines (73 loc) · 2.2 KB
/
install.bash
File metadata and controls
executable file
·81 lines (73 loc) · 2.2 KB
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
#!/usr/bin/env bash
set -e
progname=$(basename "$0")
exists() { command -v "$1" >/dev/null 2>/dev/null; }
showHelp() {
cat >&2 <<EOF
$progname: a script for bootstrapping my settings/dotfiles.
Usage: $progname <ACTION> <DEST>
ACTION := { https | https-shallow | ssh | https-to-ssh }
https: clone to DEST via HTTPS\n"
https-shallow: clone to DEST via HTTPS with --depth 1\n"
ssh: clone to DEST via SSH\n"
https-to-ssh: clone to (already existing, but https-based) DEST via SSH (thus converting it to SSH)\n"
DEST: the path where the dotfiles will be installed to.
EOF
exit 2
}
[ $# != 2 ] && showHelp
case "$1" in
https|https-shallow) DOTFILES_URL="https://github.com/yohannd1/dotfiles" ;;
ssh|https-to-ssh) DOTFILES_URL="[email protected]:yohannd1/dotfiles" ;;
*)
printf >&2 "Invalid ACTION: %s\n" "$1"
printf >&2 "\n"
showHelp
;;
esac
if [ "$1" != https-to-ssh ] && [ -e "$2" ]; then
printf >&2 "DEST %s already exists. Please delete it or choose another path.\n" "$2"
exit 1
fi
# TODO: get the similar thing from LARBS or something and put it here instead
for dependency in git python3; do
if ! exists "$dependency"; then
printf >&2 "Could not find %s in PATH - attempting to install it...\n" "$dependency"
if exists pacman; then
sudo pacman -Syy "$dependency"
elif exists apt; then
sudo apt install "$dependency"
elif exists apt-get; then
sudo apt-get install "$dependency"
else
printf >&2 "Could not find your package manager. Please install said dependency manually.\n"
exit 1
fi
fi
done
case "$1" in
https-to-ssh)
if [ ! -d "$2" ]; then
printf >&2 "%s is not a directory.\n" "$2"
exit 1
fi
temp=$(mktemp)
mv "$2" "$temp"
if git clone "$DOTFILES_URL" "$2"; then
rm -rf "$temp"
else
mv "$temp" "$2"
fi
;;
*)
[ "$1" = 'https-shallow' ] && shallow=(--depth 1) || shallow=()
git clone "${shallow[@]}" "$DOTFILES_URL" "$2"
mkdir -p ~/.local/share/dots
realpath -m "$2" > ~/.local/share/dots/dotpath
echo "gruvbox-dark-medium" > ~/.local/share/dots/theme
export DOTFILES="$2"
. "$DOTFILES/config/dots/env.sh"
. "$DOTFILES/config/dots/path.sh"
sysm
;;
esac