-
-
Notifications
You must be signed in to change notification settings - Fork 34
/
install-greyhole-package.sh
161 lines (134 loc) · 4.84 KB
/
install-greyhole-package.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
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/bin/bash
# Detect package type from /etc/issue
_found_arch() {
local _ostype="$1"
shift
grep -qis "$*" /etc/issue && _OSTYPE="$_ostype"
}
# Detect package type
_OSTYPE_detect() {
_found_arch apt-get "Debian GNU/Linux" && return
_found_arch apt-get "Ubuntu" && return
_found_arch yum "CentOS" && return
_found_arch yum "Red Hat" && return
_found_arch yum "Fedora" && return
[[ -x "/usr/bin/apt-get" ]] && _OSTYPE="apt-get" && return
[[ -x "/usr/bin/yum" ]] && _OSTYPE="yum" && return
echo
echo "Error: can't find either yum or apt-get to install Greyhole."
echo " Download the latest .tar.gz file on the Github Releases page: https://github.com/gboudreau/Greyhole/releases"
echo " Then follow the instructions from the INSTALL file: https://raw.github.com/gboudreau/Greyhole/master/INSTALL"
echo
exit 1
}
mysql_server_installed() {
if rpm -q mysql-server >/dev/null 2>&1; then
return 0
fi
if rpm -q mysql-community-server >/dev/null 2>&1; then
return 0
fi
if rpm -q mariadb-server >/dev/null 2>&1; then
return 0
fi
if rpm -q mariadb-galera-server >/dev/null 2>&1; then
return 0
fi
return 1
}
install_mysql_server() {
if yum info mysql-server >/dev/null 2>&1; then
sudo yum install -y mysql-server
return
fi
if yum info mysql-community-server >/dev/null 2>&1; then
sudo yum install -y mysql-community-server
return
fi
if yum info mariadb-server >/dev/null 2>&1; then
sudo yum install -y mariadb-server
return
fi
if yum info mariadb-galera-server >/dev/null 2>&1; then
sudo yum install -y mariadb-galera-server
return
fi
echo
echo "Can't find any packages in your configured yum repos that provide mysql-server functionality."
echo "Searched for: mysql-server, mysql-community-server, mariadb-server, mariadb-galera-server"
echo
exit 2
}
php_mysql_installed() {
if rpm -q php-mysql >/dev/null 2>&1; then
return 0
fi
if rpm -q php-mysqlnd >/dev/null 2>&1; then
return 0
fi
return 1
}
install_php_mysql() {
if yum info php-mysql >/dev/null 2>&1; then
sudo yum install -y php-mysql
return
fi
if yum info php-mysqlnd >/dev/null 2>&1; then
sudo yum install -y php-mysqlnd
return
fi
echo
echo "Can't find any packages in your configured yum repos that provide php-mysql functionality."
echo "Searched for: php-mysql, php-mysqlnd"
echo
exit 2
}
_OSTYPE_detect
if [ "$_OSTYPE" = "yum" ]; then
sudo curl -so /etc/yum.repos.d/greyhole.repo https://www.greyhole.net/releases/rpm/greyhole.repo
# Can't hard-code mysql-server dependency into the RPM, because some distributions (CentOS 7) don't offer it, and include MariaDB instead.
if ! mysql_server_installed; then
echo "Can't find mysql-server or mariadb-server installed."
echo "Will install either one (whichever is available for your distribution)."
install_mysql_server
fi
# Can't hard-code php-mysql dependency into the RPM, because some distributions (FC25) don't offer it, and include php-mysqlnd instead.
if ! php_mysql_installed; then
echo "Can't find php-mysql or php-mysqlnd installed."
echo "Will install either one (whichever is available for your distribution)."
install_php_mysql
fi
if [ ! -f /sbin/chkconfig ] && [ ! -f /usr/sbin/update-rc.d ]; then
echo "Installing chkconfig..."
sudo yum install -y chkconfig
fi
if [ ! -f /sbin/service ]; then
echo "Installing initscripts..."
sudo yum install -y initscripts
fi
if ! sudo yum install -y greyhole; then
exit 2;
fi
elif [ "$_OSTYPE" = "apt-get" ]; then
if apt-cache showpkg php-mbstring >/dev/null; then
apt-get -y install php-mbstring
fi
if apt-cache showpkg gnupg >/dev/null; then
# Required for apt-key
apt-get -y install gnupg
fi
echo "deb [signed-by=/usr/share/keyrings/greyhole-archive-keyring.gpg] https://www.greyhole.net/releases/deb stable main previous before-previous" > /etc/apt/sources.list.d/greyhole.list
mkdir -p /usr/share/keyrings
curl -s https://www.greyhole.net/releases/deb/greyhole-debsig.asc | gpg --dearmor -o /usr/share/keyrings/greyhole-archive-keyring.gpg
apt-get update
if ! apt-get -y -o DPkg::options::=--force-confmiss install greyhole; then
exit 2;
fi
fi
echo
echo "----------------------------------------"
echo "You will need to configure Greyhole now."
echo "See USAGE file for details: /usr/share/greyhole/USAGE"
echo " or online: https://raw.github.com/gboudreau/Greyhole/master/USAGE"
echo "----------------------------------------"
echo