-
Notifications
You must be signed in to change notification settings - Fork 12
/
setup.sh
executable file
·96 lines (78 loc) · 4.26 KB
/
setup.sh
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
#!/bin/sh
CAT="/bin/cat"
CHMOD="/bin/chmod"
MKDIR="/bin/mkdir"
TOUCH="/usr/bin/touch"
github_base='https://raw.githubusercontent.com/'
repo_path='PeterDaveHello/Unitial/master/'
os="$(uname)"
if [ "$os" = "FreeBSD" ]; then
ECHO="echo"
${ECHO} -e "\n\e[1;36;40mYour operating system is $os\n\e[0m"
${ECHO} -e "\n\e[1;36;40mSuppose you have 'fetch' to download files!\n\e[0m"
download_o='fetch -o'
else
ECHO="/bin/echo"
${ECHO} -e "\n\e[1;36;40mYour operating system is $os\n\e[0m"
if type "curl" > /dev/null 2>&1; then
download_o='curl --compressed -#o'
elif type "wget" > /dev/null 2>&1; then
download_o='wget --no-timestamping --no-verbose -O '
else
echo "Unitial needs 'wget' or 'curl' to download the assets." 1>&2
fi
fi
${ECHO} -e "\n\e[1;36;40mUnitial is started to initial your Unix-like working environment\n\nPlease wait...\n\n\e[0m"
${ECHO} -e "\n\e[1;36;40mDownload and setup configs from server...\n\e[0m"
for file in gitconfig tcshrc bashrc bash_profile inputrc vimrc zshrc gitignore_global tmux.conf xinputrc wgetrc curlrc tigrc editorconfig php_cs markdownlintrc lftprc; do
${download_o} - "${github_base}${repo_path}${file}" | ${CAT} >> ~/."$file" &
done
${MKDIR} -p ~/.irssi/ ~/.git/contrib/ ~/.vim/colors/ ~/.vim/swp/ ~/.vim/bak/ ~/.vim/undo/ ~/.aria2/ ~/.w3m/ ~/.hadolint/
${download_o} ~/.w3m/config "${github_base}${repo_path}w3mconfig" &
${download_o} ~/.irssi/config "${github_base}${repo_path}irssi_config" &
${download_o} ~/.aria2/aria2.conf "${github_base}${repo_path}aria2.conf" &
${download_o} ~/.hadolint/hadolint.yaml "${github_base}${repo_path}hadolint.yaml" &
${download_o} ~/.colorEcho "${github_base}PeterDaveHello/ColorEchoForShell/master/dist/ColorEcho.bash" &
${MKDIR} -p ~/.gcin/
${download_o} ~/.gcin/gtab.list "${github_base}${repo_path}gtab.list" &
${MKDIR} -p -m 700 ~/.ssh/.tmp_session/
${CHMOD} 700 ~/.ssh/
${download_o} - "${github_base}${repo_path}ssh_config" | ${CAT} >> ~/.ssh/config &
${TOUCH} ~/.ssh/authorized_keys
${CHMOD} 600 ~/.ssh/config ~/.ssh/authorized_keys
wait
${ECHO} -e "\n\e[1;36;40mAdd some color setting which depends on your OS...\n\e[0m"
if [ "$os" = "FreeBSD" ] || [ "$os" = "Darwin" ]; then
${ECHO} -e "\n#color setting\nalias ls='\ls -F'" >> ~/.zshrc
${ECHO} -e "\n#color setting\nalias ls '\ls -F'" >> ~/.tcshrc
else
${ECHO} -e "\n#color setting\nalias ls='\ls -F --color=auto'" >> ~/.zshrc
${ECHO} -e "\n#color setting\nalias ls '\ls -F --color=auto'" >> ~/.tcshrc
fi
if [ "$os" = "FreeBSD" ]; then
${ECHO} -e "\n\e[1;36;40mAdd FreeBSD's package mirror setting...\n\e[0m"
${ECHO} -e "\n#package mirror setting\nexport PACKAGEROOT=http://ftp.tw.freebsd.org" >> ~/.bashrc
${ECHO} -e "\n#package mirror setting\nexport PACKAGEROOT=http://ftp.tw.freebsd.org" >> ~/.zshrc
${ECHO} -e "\n#package mirror setting\nsetenv PACKAGEROOT http://ftp.tw.freebsd.org" >> ~/.tcshrc
fi
if command -v git; then
git_version="v$(git --version | awk '{gsub(/\.windows.+/, "", $0); print $3}')"
else
git_version="master"
fi
${ECHO} -e "\n\e[1;36;40mDownload VIM color scheme - Kolor from server...\n\e[0m"
${download_o} ~/.vim/colors/kolor.vim "${github_base}zeis/vim-kolor/master/colors/kolor.vim" &
${ECHO} -e "\n\e[1;36;40mDownload git contrib - diff-highlight from server...\n\e[0m"
${download_o} ~/.git/contrib/diff-highlight "${github_base}git/git/v2.13.2/contrib/diff-highlight/diff-highlight" && ${CHMOD} +x ~/.git/contrib/diff-highlight &
${ECHO} -e "\n\e[1;36;40mDownload git's auto completion configs from server...\n\e[0m"
git_auto_complete_path="${github_base}git/git/${git_version}/contrib/completion/git-completion."
${download_o} ~/.git-completion.bash "${git_auto_complete_path}bash" &
${download_o} ~/.git-completion.tcsh "${git_auto_complete_path}tcsh" &
${download_o} ~/.git-completion.zsh "${git_auto_complete_path}zsh" &
wait
if [ "$os" = "FreeBSD" ] && [ -r /usr/local/share/certs/ca-root-nss.crt ]; then
${ECHO} -e "\n\e[1;36;40mAdd ca-certificate path for FreeBSD's wget & aria2...\n\e[0m"
${ECHO} -e "\nca-certificate=/usr/local/share/certs/ca-root-nss.crt" >> ~/.wgetrc
${ECHO} -e "\nca-certificate=/usr/local/share/certs/ca-root-nss.crt" >> ~/.aria2/aria2.conf
fi
${ECHO} -e "\n\e[1;36;40mUnitial installation was finished!\n\nPlease terminate all other works and restart your shell or re-login.\n\e[0m"