This repository has been archived by the owner on Dec 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup
executable file
·137 lines (106 loc) · 4.05 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/sh
# ____ __
# / __/__ / /___ _____
# _\ \/ -_) __/ // / _ \
# /___/\__/\__/\_,_/ .__/
# /_/
# Add description here:
# > Hello World!
# > This is my setup script.
# Imports
DOTFILES_PATH=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
cd "$DOTFILES_PATH" || exit 1
git submodule update --init --recursive --remote --merge 2>&-
cd "$WD" || exit 1
. "$DOTFILES_PATH/extra/sbb/sbb" # You can change SSB packages manager path here
# Values
BSYMLINK_PATH="$DOTFILES_PATH/extra/bsymlink/bin/bsymlink" # If you use Bsymlink, you can change Bsymlink path here
# source "$DOTFILES_PATH/home/.bashrc" # You can import values or functions from other file
STEPS="${*:-install before home root after}" # Default order of steps
# Functions
install_packages() {
printf '\n\033[1;7;34m%s\033[0m\n' 'Install packages' >&2
# You can add additional package manager
# Example: to add "SomePackageManager"
#SomePackageManager_MARK='SPM'
#SomePackageManager_PM='somepm'
#SomePackageManager_COMMAND="$PERMISSION_COMMAND $SomePackageManager_PM install --assume-yes"
#
# Creating a setup function for "SomePackageManager"
#sbb_setup_SomePackageManager() {
# $PERMISSION_COMMAND somepm update --assume-yes
# $PERMISSION_COMMAND somepm upgrade --assume-yes
#}
#
# Then add "SomePackageManager" to the package managers list only when bootstrapping on Linux
#[ "$KERNEL" = 'linux' ] && PACKAGEMANAGER_LIST="$PACKAGEMANAGER_LIST SomePackageManager"
# You can also change some aspect of an existence package manager
# Example: using pipx to manage pip packages
#PIP_PM='sbb_pipx'
#PIP_COMMAND="$PIP_PM"
#sbb_setup_PIP() {
# sbb_install_curl
# sbb_install_python
#
# cd "$TEMPORARY" || exit 1
# curl --remote-header-name --location --remote-name "https://bootstrap.pypa.io/get-pip.py"
# python get-pip.py
#
# pip install --upgrade pip
# pip install --user pipx
# pipx ensurepath
#
# sbb_make_install_command 'pipx' "pipx install"
#}
sbb_install_packages "$DOTFILES_PATH/packageslist" # You can change packageslist's path here
}
symlink_home() {
printf '\n\033[1;7;36m%s\033[0m\n' "Symlink to home ($HOME)" >&2
"$BSYMLINK_PATH" "$DOTFILES_PATH/home" "$HOME"
# Use this instead if you want to batch symlink with stow (you must cd to the directory that contain this setup file)
#stow -vt ~ home
}
symlink_root() {
printf '\n\033[1;7;36m%s\033[0m\n' 'Symlink to root (/)' >&2
$PERMISSION_COMMAND "$BSYMLINK_PATH" "$DOTFILES_PATH/root" '/'
# Use this instead if you want to batch symlink with stow (you must cd to the directory that contain this setup file)
#$PERMISSION_COMMAND stow -vt / root
}
before_symlink() {
printf '\n\033[1;7;33m%s\033[0m\n' 'Setup before symlink' >&2
# Remove files that may conflict when symlink dotfiles
#rm .bashrc
# Remove conflicting items in $HOME/.config
#[ -d "$HOME/.config" ] && for config_directory_path in "$HOME/.config/."* "$HOME/.config/"*; do
# config_directory_name="${config_directory_path#$XDG_CONFIG_HOME/}"
#
# if [ "$config_directory_name" != '.' ] && [ "$config_directory_name" != '..' ] && [ -e "$HOME/dots/home/.config/$config_directory_name" ]; then
# rm "$config_directory_path"
# fi
#done
# Create directories (to symlink files inside only, not the directory itself)
#mkdir "$HOME/.config" "$HOME/.local/share" "$HOME/.local/bin" "$HOME/.cache"
}
after_symlink() {
printf '\n\033[1;7;33m%s\033[0m\n' 'Setup after symlink' >&2
# Change default shell
#chsh -s "$(command -v bash)"
# Enable firewall
#$PERMISSION_COMMAND ufw enable
}
# Start
for step_check in $STEPS; do
case "$step_check" in
'i'|'install') steps_list="${steps_list:+$steps_list; }install_packages" ;;
'b'|'before') steps_list="${steps_list:+$steps_list; }before_symlink" ;;
'h'|'home') steps_list="${steps_list:+$steps_list; }symlink_home" ;;
'r'|'root') steps_list="${steps_list:+$steps_list; }symlink_root" ;;
'a'|'after') steps_list="${steps_list:+$steps_list; }after_symlink" ;;
*)
printf '\n\033[1;7;31m%s\033[0m\n' "Step '$step_check' not found" >&2
exit 1
;;
esac
done
eval "$steps_list"
exit 0