-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
executable file
·128 lines (106 loc) · 3.99 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
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
#!/bin/bash
set -e
# Current working directory
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
# Load environment variables
######################################################################
for file in ${DIR}/.{env,env.local}; do
# shellcheck source=./.env
[ -r "$file" ] && [ -f "$file" ] && source "$file"
done
unset file
if [ -f "$DIR/bin/shell-common" ]; then
# shellcheck disable=SC1094
# shellcheck source=./bin/shell-common
source "$DIR/bin/shell-common"
else
echo "shell-common - File does not exist."
exit 1
fi
output "\nCreate symlink" "heading"
if ! test -f "$DIR/.env.local"; then
touch "$DIR/.env.local"
fi
declare -a files
files+=(
"$DIR/.env::$HOME/.env"
"$DIR/.env.local::$HOME/.env.local"
"$DIR/profile/.zshrc::$HOME/.zshrc"
"$DIR/profile/.bash_profile::$HOME/.bash_profile"
"$DIR/profile/.bash_aliases::$HOME/.bash_aliases"
"$DIR/config/.gitconfig::$HOME/.gitconfig"
"$DIR/config/.gitignore::$HOME/.gitignore"
"$DIR/config/gpg.conf::$HOME/.gnupg/gpg.conf"
"$DIR/config/gpg-agent.conf::$HOME/.gnupg/gpg-agent.conf"
"$DIR/config/ssh.conf::$HOME/.ssh/config"
)
for index in "${files[@]}"; do
source_file="${index%%::*}"
target_file="${index##*::}"
if [ -L "${target_file}" ]; then
output "${target_file} symbolic exists." 'info'
else
if [ ! -f "${source_file}" ]; then
error_exit "File ${source_file} does not exists."
fi
if [ -f "${target_file}" ]; then
backup_file "${target_file}"
rm "${target_file}"
# error_exit "File ${target_file} is exists."
fi
output "${target_file}"
command_eval ln -sf "${source_file}" "${target_file}" || {
error_exit "An error occurred, failed to create symbolic link: ${source_file} to ${target_file}"
}
# Владелец может читать, записывать и запускать на выполнение; никто другой не имеет права выполнять никакие действия
command_eval chmod -R 700 "${target_file}" || {
error_exit "An error occurred, failed to apply chmod"
}
output "File '${source_file}' symlink to '${target_file}'" 'success'
fi
unset source_file
unset target_file
done
unset files
## SSH Config
#ssh_home="${HOME}/.ssh"
#ssh_config_file="${HOME}/.ssh/config"
#
#output "\nSSH Config" "heading"
#
#command_eval mkdir -p "${ssh_home}" || {
# error_exit "An error occurred, the directory could not be created."
#}
#
## Владелец может читать, записывать и запускать на выполнение; никто другой не имеет права выполнять никакие действия
#command_eval chmod -R 700 "${ssh_home}" || {
# error_exit "An error occurred, failed to apply chmod"
#}
#
#command_eval backup_file "${ssh_config_file}" true || {
# output "An error occurred, failed to create backup." "warn"
#}
#
#command_eval ln -sf "${DIR}/config/ssh.conf" "${ssh_config_file}" || {
# error_exit "An error occurred, failed to create symbolic link."
#}
#
## Все пользователи имеют право чтения; владелец может редактировать
#command_eval chmod 644 "${ssh_config_file}" || {
# error_exit "An error occurred, failed to apply chmod"
#}
# https://shankarkulumani.com/2019/03/gpg.html
# https://menduz.com/posts/2020.11.08
# export GNUPGHOME=$(mktemp -d)
# export GNUPGHOME="${HOME}/.gnupg"
# echo $GNUPGHOME
#mkdir -p "$GNUPGHOME"
#curl -o "$GNUPGHOME/gpg.conf" https://raw.githubusercontent.com/drduh/config/master/gpg.conf
#curl -o "$GNUPGHOME/gpg-agent.conf" https://raw.githubusercontent.com/drduh/config/master/gpg-agent.conf
#chmod 600 "$GNUPGHOME/gpg.conf"
#chmod 600 "$GNUPGHOME/gpg-agent.conf"
#base=https://github.com/docker/machine/releases/download/v0.16.0 \
# && curl -L $base/docker-machine-$(uname -s)-$(uname -m) >/usr/local/bin/docker-machine \
# && chmod +x /usr/local/bin/docker-machine
# 1. Copy ./bin/* to >>> /usr/local/bin/
# 2. set: chmod +x /usr/local/bin/...