-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup
114 lines (86 loc) · 3 KB
/
setup
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/bin/sh
# Let script exit when a command fail
set -e
### Variables
DOTFILES=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
PWSH_PATH=/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe
WINDOWS_PATH=/mnt/c/Users/$($PWSH_PATH '$env:UserName' | sed -e 's/\r//g')
echo Dotfile path: $DOTFILES
echo Powershell path: $PWSH_PATH
echo Windows home path: $WINDOWS_PATH
### Create directories
mkdir -p $HOME/.config/git $HOME/.gpg $HOME/.ssh
echo Created essential directories
### Git
# Config file
ln -sf $DOTFILES/git/.gitconfig $HOME/.gitconfig
chown -h $(whoami):$(whoami) $HOME/.gitconfig
# Other git files
for file in .gitignore .gitattributes .gitmessage; do
ln -sf $DOTFILES/git/$file $HOME/.config/git/$file
chown -h $(whoami):$(whoami) $HOME/.config/git/$file
echo Created softlink to $HOME/.config/git/$file to $file
done
### SSH
# private
if [ -e $WINDOWS_PATH/.ssh/id_ed25519 ]; then
cp $WINDOWS_PATH/.ssh/id_ed25519 $HOME/.ssh/id_ed25519
chmod 700 $HOME/.ssh/id_ed25519
chown -h $(whoami):$(whoami) $HOME/.ssh/id_ed25519
fi
# public
if [ -e $WINDOWS_PATH/.ssh/id_ed25519.pub ]; then
cp $WINDOWS_PATH/.ssh/id_ed25519.pub $HOME/.ssh/id_ed25519.pub
chmod 700 $HOME/.ssh/id_ed25519.pub
chown -h $(whoami):$(whoami) $HOME/.ssh/id_ed25519.pub
fi
# hosts
if [ -e $WINDOWS_PATH/.ssh/known_hosts ]; then
ln -sf $WINDOWS_PATH/.ssh/known_hosts $HOME/.ssh/known_hosts
chown -h $(whoami):$(whoami) $HOME/.ssh/known_hosts
fi
# config
if [ -e $WINDOWS_PATH/.ssh/config ]; then
cp $WINDOWS_PATH/.ssh/config $HOME/.ssh/config
chmod 700 $HOME/.ssh/config
chown -h $(whoami):$(whoami) $HOME/.ssh/config
fi
echo Fixed ssh config
### GPG
echo $WINDOWS_PATH/.gpg/private_keys.gpg
# private
if [ -e $WINDOWS_PATH/.gpg/private_keys.gpg ]; then
cp $WINDOWS_PATH/.gpg/private_keys.gpg $HOME/.gpg/private_keys.gpg
chmod 700 $HOME/.gpg/private_keys.gpg
chown -h $(whoami):$(whoami) $HOME/.gpg/private_keys.gpg
fi
# public
if [ -e $WINDOWS_PATH/.gpg/public_keys.gpg ]; then
cp $WINDOWS_PATH/.gpg/public_keys.gpg $HOME/.gpg/public_keys.gpg
chmod 700 $HOME/.gpg/public_keys.gpg
chown -h $(whoami):$(whoami) $HOME/.gpg/public_keys.gpg
fi
echo Moved GPG keys into WSL
gpg --import $HOME/.gpg/private_keys.gpg
ln -sf $DOTFILES/gpg/gpg-agent.conf $HOME/.gnupg/gpg-agent.conf
chown -h $(whoami):$(whoami) $HOME/.gnupg/gpg-agent.conf
### Wget
ln -sf $DOTFILES/wget/.wgetrc $HOME/.wgetrc
chown -h $(whoami):$(whoami) $HOME/.wgetrc
### Bash
if [ ! -z "$BASH_VERSION" ]; then
# oh-my-bash
URL="https://raw.githubusercontent.com/ohmybash/oh-my-bash/master/tools/install.sh"
if [ ! -d "$HOME/.oh-my-bash" ]; then
bash -c "$(curl -fsSL $URL)" "" --unattended
fi
ln -sf $DOTFILES/bash/.bashrc $HOME/.bashrc
chown -h $(whoami):$(whoami) $HOME/.bashrc
fi
echo Installed oh-my-bash and configured
### System
ln -sf $DOTFILES/.profile $HOME/.profile
chown -h $(whoami):$(whoami) $HOME/.profile
echo Added softlink to .profile
# Restart
exec bash; source $HOME/.bashrc