-
Notifications
You must be signed in to change notification settings - Fork 0
/
init-dot
executable file
·85 lines (73 loc) · 2.03 KB
/
init-dot
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
#!/bin/bash
# Stop on error
set -e
function install_package() {
# Detect OS
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
# Linux OS
if [ -f "/etc/redhat-release" ]; then
# CentOS, Red Hat or Fedora
sudo dnf install -y $1
elif [ -f "/etc/debian_version" ]; then
# Debian or Ubuntu
sudo apt-get install -y $1
elif [ -f "/etc/arch-release" ]; then
# Arch Linux
sudo pacman -S --noconfirm $1
else
# Unsupported Linux OS
echo "Unsupported Linux OS"
exit 1
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
# macOS
# brew install $1
# TODO: make work with mac os.
echo "mac not suppported yet"
exit 1
else
# Unsupported OS
echo "Unsupported OS"
exit 1
fi
}
dir_exists () {
return $(test -d "$1")
}
if ! command -v git &> /dev/null; then
install_package git-all
fi
# Once git is installed
mkdir -p ~/.ssh
FILE=$HOME/.ssh/gitkey
if [ ! -f "$FILE" ]; then
ssh-keygen -t ed25519 -C "git" -f ~/.ssh/gitkey
fi
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/gitkey
echo "Please add the following public key to github:"
cat ~/.ssh/gitkey.pub
read -n 1 -p "any key to continue" tmp
# zsh
install_package -y zsh
if ! dir_exists $HOME/.oh-my-zsh; then
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
fi
# yadm
# Detect Linux OS
if [ -f "/etc/redhat-release" ]; then
# CentOS, Red Hat or Fedora
sudo dnf config-manager --add-repo https://download.opensuse.org/repositories/home:TheLocehiliosan:yadm/Fedora_35/home:TheLocehiliosan:yadm.repo
sudo dnf install -y yadm
elif [ -f "/etc/debian_version" ]; then
# Debian or Ubuntu
sudo apt-get install -y yadm
elif [ -f "/etc/arch-release" ]; then
# Arch Linux
sudo pacman -S --noconfirm yadm
else
# Unsupported OS
echo "Unsupported Linux OS"
exit 1
fi
yadm clone "[email protected]:aperullo/dotfiles.git" -f