OSDN Git Service

initial commit
[otrs-setup/otrs_repo.git] / otrs_setup.sh
1 #!/bin/bash
2 #
3 #    otrs_setup.sh is a helper script to automate most of the steps for setting up OTRS on CentOS7.
4 #
5 #    Copyright (C) 2019 Yordan Manolov
6 #
7 #    This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
8 #
9 #    This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
10 #
11 #    You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
12 #
13
14 OTRS_VER="otrs-6.0.19-02"
15 OTRS_RPM="$OTRS_VER.noarch.rpm"
16 OTRS_URL="http://ftp.otrs.org/pub/otrs/RPMS/rhel/7/$OTRS_RPM"
17
18 if [ "$EUID" -ne 0 ]
19   then echo "Insufficient privileges: non-root user detected. Aborting ... "
20   exit
21 fi
22
23 sed -ie 's@^ONBOOT="no@ONBOOT="yes@' $(ls /etc/sysconfig/network-scripts/ | grep ens)
24 dhclient -v
25
26 yum install -y epel-release mariadb-server wget
27
28
29 if [ $(grep -c "SELINUX=enforcing" /etc/selinux/config) -gt 0 ]; then
30         echo "SELINUX is preventing OTRS installation. Disabling SELINUX rules... "
31         sed -ie 's@SELINUX=enforcing@SELINUX=permissive@' /etc/selinux/config
32         reboot 
33 fi 
34  
35 touch /etc/my.cnf.d/zotrs.cnf
36
37 echo "
38 [client]
39 default-character-set = utf8
40
41 [mysql]
42 default-character-set = utf8
43
44 [mysqld]
45 collation-server = utf8_unicode_ci
46 init-connect = 'SET NAMES utf8'
47 character-set-server = utf8
48
49 max_allowed_packet   = 64M
50 query_cache_size     = 32M
51 innodb_log_file_size = 256M
52 " > /etc/my.cnf.d/zotrs.cnf
53
54 if [ $? -ne 0 ]; then
55         echo "Could not write MariaDB config for OTRS. Aborting..."
56         exit 1
57 fi
58
59 systemctl enable mariadb
60 systemctl restart mariadb
61
62 wget $OTRS_URL
63 yum install -y $OTRS_RPM
64
65 yum install -y "perl(YAML::XS)" "perl(Archive::Tar)" "perl(Archive::Zip)" "perl(Date::Format)" "perl(DateTime)" "perl(Digest::SHA)" "perl(Net::DNS)" "perl(Template)"  "perl(Crypt::Eksblowfish::Bcrypt)" "perl(JSON::XS)" "perl(Text::CSV_XS)" "perl(DBD::ODBC)" "perl(DBD::Pg)" "perl(Mail::IMAPClient)"  "perl(Authen::NTLM)"  "perl(ModPerl::Util)"
66
67 systemctl enable httpd
68 systemctl restart httpd
69
70 echo "This system uses the following network interfaces: "
71 ip -br -f inet addr
72
73 ip route add default via $(ip -br addr | tail -n 1 | awk '{print $3}' | cut -c 1-14)
74 firewall-cmd --add-port=80/tcp --permanent
75 firewall-cmd --add-port=8080/tcp --permanent
76 firewall-cmd --reload
77 systemctl restart firewalld