-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.bash
129 lines (113 loc) · 2.93 KB
/
install.bash
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
# Install and update script
INSTALLED_FROM=https://raw.githubusercontent.com/tpanj/bash4all/master/modes/pkg.mode.bash
OS=$(uname -o)
shopt -s expand_aliases
unset _FILE_EXSISTS _PROFILE
Echo () {
echo "=> $@"
}
[ -d ~/.bash4all ] && {
Echo "Alreary installed. Proceed with update? [Y/n]"
read yn
if [[ $yn != [Nn]* ]]; then
cd ~/.bash4all; git pull
fi
exit 0
}
nyi_contribute() {
echo "Not yet implemented for $1 you have."
echo "Have you thought to https://github.com/tpanj/bash4all/wiki/Contribute"
exit 2
}
cmd_exists() {
command -v "$@" >/dev/null 2>&1
}
get_install_cmd() {
cmd_exists curl && BASED="$1" . <(curl -fsSL $INSTALLED_FROM)
cmd_exists curl || {
cmd_exists wget && BASED="$1" . <(wget -O- $INSTALLED_FROM)
}
echo "$(alias I); export BASED=$1" # export from f.
}
case $OS in
"GNU/Linux")
DISTRIB=$(lsb_release --id --short)
case "$DISTRIB" in
Ubuntu | LinuxMint | Debian | MX)
. <(get_install_cmd DEBIAN)
;;
Arch | ManjaroLinux | Garuda)
. <(get_install_cmd ARCH)
;;
CentOS | Redhat | Fedora | Scientific)
. <(get_install_cmd REDHAT)
;;
Fedora | Scientific)
. <(get_install_cmd FEDORA)
;;
Mageia | Mandriva | PCLinuxOS)
. <(get_install_cmd MAGEIA)
;;
"openSUSE project" | SUSE)
. <(get_install_cmd SUSE)
;;
PC)
;;
*)
nyi_contribute "$DISTRIB"
esac
;;
# not linuxes
Haiku)
. <(get_install_cmd BEOS)
;;
Darwin*)
. <(get_install_cmd MAC)
;;
FreeBSD)
. <(get_install_cmd BSD)
;;
# Cygwin)
# . <(get_install_cmd DOS)
# ;;
*)
nyi_contribute $OS
esac
Echo "This script will backup necessary files and install per user config"
cmd_exists git || {
echo -n "Do you want to install needed git using \""
echo $(alias I | sed -n 's/^alias I=.//p'|sed -n 's/.$//p' ) git\" ?
}
Echo "[Y/n]"
if [ Y = "$NON_INTERACTIVE" ]; then yn=Y; else read yn ;fi
read yn
[[ $yn != [Nn]* ]] && {
cmd_exists git || I git
git clone https://github.com/tpanj/bash4all ~/.bash4all
}
if [ -w ~/.bashrc ]; then
_PROFILE=~/.bashrc; _FILE_EXSISTS="end of "
else
_PROFILE=~/.bashrc
fi
# special cases of locations
[[ ${BASED} == 'BEOS' ]] && _PROFILE=~/config/settings/profile
[ "$_FILE_EXSISTS" ] && {
cp $_PROFILE{,.bash4all};
Echo "Backups of existing files will be created with .bash4all extensions"
}
cat >>$_PROFILE <<EOF
# call bash4all scripts to change environment
BASED=$BASED
for i in ~/.bash4all/core/*.bash ; do
. \$i
done
EOF
Echo "Installed call of main script to $_FILE_EXSISTS \"$_PROFILE\"."
# normalization outside repo
_lc_BASED="${BASED,,}"
[ -d ~/.bash4all/based/$_lc_BASED ] && bash ~/.bash4all/based/$_lc_BASED/index.bash
# user defined post install
[ -f ~/.bash4all_install ] && . ~/.bash4all_install
Echo "Installation complete. To start using it here now type 'bash -' or open new terminal."
exit 0