-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall
More file actions
executable file
·60 lines (59 loc) · 2.26 KB
/
Copy pathinstall
File metadata and controls
executable file
·60 lines (59 loc) · 2.26 KB
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
#!/usr/bin/env bash
# Install script for dotfiles
src_dir="\${HOME}/dotfiles/src/${1}"
# Check if the first argument is either 'zsh' or 'bash'
if [ "$1" != "zsh" ] && [ "$1" != "bash" ]; then
echo "Installation Error:: The first argument must be either 'zsh' or 'bash'."
exit 1
fi
ident=$(grep "Dotfile installation" < "${HOME}/.${1}rc" | wc -c)
if [ "$ident" -gt 0 ]; then
. "./src/bash/functions"
wmsg "Dotfiles are already installed. Delete the existing installation and try again."
exit 1
fi
update_rc_file() {
cat <<EOF >> "${HOME}/.${1}rc"
# Dotfile installation start
# Source dotfiles_dirs
source "\${HOME}/dotfiles/src/bash/functions"
set -a
source "${src_dir}/env.env"
# Add custom dotfiles
# Add environment variables
[ -f "\${HOME}/${1}-src/env.env" ] && source "\${HOME}/${1}-src/env.env"
[ -f "\${HOME}/${1}-src/ecr.env.ecr" ] && decrypt "\${HOME}/${1}-src/ecr.env.ecr"
[ -f "\${HOME}/${1}-src/ecr.env" ] && source \${HOME}/${1}-src/ecr.env && rm "\${HOME}/${1}-src/ecr.env"
[ -f "\${HOME}/bash-src/environments/production.env" ] && source "\${HOME}/bash-src/environments/production.env"
set +a
# Add aliases
source "${src_dir}/aliases"
[ -f "\${HOME}/${1}-src/aliases" ] && source "\${HOME}/${1}-src/aliases"
[ -d "\${HOME}/bash-src/src" ] && export BASHSRCPATH="\${HOME}/bash-src/"
[ -d "\${HOME}/awk-src/scripts" ] && export AWKSRCPATH="\${HOME}/awk-src/"
# save the current directory
export SDIR=\$(pwd)
# Add dotfiles bin directory to PATH
export PATH="\${HOME}/dotfiles/bin:\${PATH}"
# Add functions
[ -d "\${HOME}/bash-src/src" ] && cd "\${HOME}/bash-src/src" && git checkout production &> /dev/null && git pull &> /dev/null && {
for file in *; do
source "\$BASHSRCPATH""src/\$file"
done
}
[ -d "\${HOME}/awk-src/scripts" ] && cd "\${HOME}/awk-src/" && git checkout production &> /dev/null && git pull &> /dev/null
cd "\${HOME}/dotfiles/" && git checkout production &> /dev/null && git pull &> /dev/null && cd "\$SDIR"
# Dotfile installation end
EOF
}
git checkout production && git pull &> /dev/null
. "./src/bash/functions"
imsg "Installing ${1}..."
update_rc_file "$1"
# Loop through all files in the bin directory and make them executable
for file in "${HOME}"/dotfiles/bin/./*; do
if [ -f "${file}" ]; then
chmod +x "${file}"
fi
done
kmsg "Installation complete."