-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·52 lines (42 loc) · 963 Bytes
/
install.sh
File metadata and controls
executable file
·52 lines (42 loc) · 963 Bytes
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
#!/bin/bash
set -ueo pipefail
shopt -s nullglob dotglob
# Constants
SCRIPT_DIR="$(cd "$(dirname "$0")"; pwd)"
XDG_CONFIG_HOME="${XDG_CONFIG_HOME:="$HOME/.config"}"
CONFIG_SOURCE=("$SCRIPT_DIR/config/"*)
create_dir_if_not_exist(){
local target="$1"
if [ ! -d "$target" ]; then
echo "ディレクトリが存在しません: $target"
echo "作成します..."
mkdir -p "$target"
echo "ディレクトリを作成"
else
echo "ディレクトリはすでに存在します: $target"
fi
}
create_symlink(){
local src="$1"
local dst="$2"
ln -sfn "$src" "$dst"
echo "Linked : $src -> $dst"
}
prepare_deploy(){
create_dir_if_not_exist "$XDG_CONFIG_HOME"
}
deploy_config(){
for entry in "${CONFIG_SOURCE[@]}"; do
local name="$(basename "$entry")"
create_symlink "$SCRIPT_DIR/config/$name" "$XDG_CONFIG_HOME/$name"
done
}
deploy(){
prepare_deploy
deploy_config
}
# Entry point
__main(){
deploy
}
__main "$@"