-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
executable file
·76 lines (60 loc) · 1.97 KB
/
install
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
#!/usr/bin/env bash
# ref
# - http://qiita.com/b4b4r07/items/24872cdcbec964ce2178#deploy
# - https://github.com/izumin5210/dotfiles/blob/438d5d82378b684500abfded0e92362a0cd500e0/install
set -eu
has() {
return $(type $1 >/dev/null 2>&1)
}
REPO="github.com/potsbo/dotfiles"
DOTPATH="${HOME}/src/${REPO}"
download() {
local github_url="https://${REPO}"
if has "git"; then
git clone --recursive "${github_url}" "${DOTPATH}"
elif has "curl" || has "wget"; then
tarball="${github_url}/archive/master.tar.gz"
if has "curl"; then
curl -L "${tarball}"
elif has "wget"; then
wget -O - "${tarball}"
fi | tar xv -
mv -f dotfiles-main "${dotpath}"
else
exit 1
fi
}
if [[ -e /proc/version ]] && grep -qEi "(Microsoft|WSL)" /proc/version; then
pattern='%sudo ALL=(ALL) NOPASSWD:ALL'
sudo grep -qxF "$pattern" /etc/sudoers || echo "$pattern" | sudo tee -a /etc/sudoers >/dev/null
fi
if [ ! -d $DOTPATH ]; then
echo "$DOTPATH not found. Cloning..."
download
fi
cd $DOTPATH
if [ $? -ne 0 ]; then
exit 1
fi
bin/setup_mitamae
if [ "$(uname)" = "Linux" ]; then
if [ "${CODESPACES:-"false"}" = "true" ]; then
# codespaces で sudo が command not found になったため入れていない
# もしかしたら codespaces の環境によっては必要かもしれない
apt update
# ghq のために workspace 自体もリンクする
mkdir -p "${HOME}/src/github.com/$(echo $GITHUB_REPOSITORY | cut -d'/' -f1)"
TARGET_REPO_PATH="${HOME}/src/github.com/${GITHUB_REPOSITORY}"
if [ ! -e "${TARGET_REPO_PATH}" ]; then
# 起動時は CODESPACE_VSCODE_FOLDER が使えなかったので手動で構築
ln -s "/workspaces/$(echo $GITHUB_REPOSITORY | cut -d'/' -f2)" "${TARGET_REPO_PATH}"
fi
# 任意の場所から aqua が使えるようにしておく
ln -s "$HOME/aqua.yaml" /aqua.yaml
fi
bin/mitamae local lib/recipe.rb
else
script/force_valid_name
script/keygen
bin/mitamae local lib/recipe.rb
fi