Applied CentOS 7 issues.

This commit is contained in:
Martin Edenhofer 2016-11-14 03:22:58 +01:00
parent 6c11e54884
commit 5d5b1766d5

View file

@ -45,26 +45,26 @@ else
# centos # centos
if [ -n "$(which postgresql-setup)" ]; then if [ -n "$(which postgresql-setup)" ]; then
echo "preparing postgresql server" echo "preparing postgresql server"
postgresql-setup initdb postgresql-setup initdb
echo "backuping postgres config" echo "backuping postgres config"
test -f /var/lib/pgsql/data/pg_hba.conf.bak || cp /var/lib/pgsql/data/pg_hba.conf /var/lib/pgsql/data/pg_hba.conf.bak test -f /var/lib/pgsql/data/pg_hba.conf.bak || cp /var/lib/pgsql/data/pg_hba.conf /var/lib/pgsql/data/pg_hba.conf.bak
echo "allow login via username and password in postgresql" echo "allow login via username and password in postgresql"
sed 's/ident/trust/g' < /var/lib/pgsql/data/pg_hba.conf.bak > /var/lib/pgsql/data/pg_hba.conf sed 's/ident/trust/g' < /var/lib/pgsql/data/pg_hba.conf.bak > /var/lib/pgsql/data/pg_hba.conf
echo "restarting postgresql server" echo "restarting postgresql server"
${INIT_CMD} restart postgresql ${INIT_CMD} restart postgresql
echo "create postgresql bootstart" echo "create postgresql bootstart"
${INIT_CMD} enable postgresql.service ${INIT_CMD} enable postgresql.service
fi fi
echo "creating zammad postgresql db" echo "creating zammad postgresql db"
su - postgres -c "createdb -E UTF8 ${DB}" su - postgres -c "createdb -E UTF8 ${DB}"
echo "creating zammad postgresql user" echo "creating zammad postgresql user"
echo "CREATE USER \"${DB_USER}\" WITH PASSWORD '${DB_PASS}';" | su - postgres -c psql echo "CREATE USER \"${DB_USER}\" WITH PASSWORD '${DB_PASS}';" | su - postgres -c psql
echo "grant privileges to new postgresql user" echo "grant privileges to new postgresql user"
@ -78,35 +78,35 @@ else
# mysql / mariadb # mysql / mariadb
elif [ -n "$(which mysql)" ];then elif [ -n "$(which mysql)" ];then
echo "installing zammd on mysql" echo "installing zammd on mysql"
if [ -f "${MY_CNF}" ]; then if [ -f "${MY_CNF}" ]; then
MYSQL_CREDENTIALS="--defaults-file=${MY_CNF}" MYSQL_CREDENTIALS="--defaults-file=${MY_CNF}"
else else
echo -n "Please enter your MySQL root password:" echo -n "Please enter your MySQL root password:"
read -s MYSQL_ROOT_PASS read -s MYSQL_ROOT_PASS
MYSQL_CREDENTIALS="-u root -p${MYSQL_ROOT_PASS}" MYSQL_CREDENTIALS="-u root -p${MYSQL_ROOT_PASS}"
fi fi
echo "creating zammad mysql db" echo "creating zammad mysql db"
mysql ${MYSQL_CREDENTIALS} -e "CREATE DATABASE ${DB} DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;" mysql ${MYSQL_CREDENTIALS} -e "CREATE DATABASE ${DB} DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;"
echo "creating zammad mysql user" echo "creating zammad mysql user"
mysql ${MYSQL_CREDENTIALS} -e "CREATE USER \"${DB_USER}\"@\"${DB_HOST}\" IDENTIFIED BY \"${DB_PASS}\";" mysql ${MYSQL_CREDENTIALS} -e "CREATE USER \"${DB_USER}\"@\"${DB_HOST}\" IDENTIFIED BY \"${DB_PASS}\";"
echo "grant privileges to new mysql user" echo "grant privileges to new mysql user"
mysql ${MYSQL_CREDENTIALS} -e "GRANT ALL PRIVILEGES ON ${DB}.* TO \"${DB_USER}\"@\"${DB_HOST}\"; FLUSH PRIVILEGES;" mysql ${MYSQL_CREDENTIALS} -e "GRANT ALL PRIVILEGES ON ${DB}.* TO \"${DB_USER}\"@\"${DB_HOST}\"; FLUSH PRIVILEGES;"
echo "updating database.yml" echo "updating database.yml"
sed -e "s/.*adapter:.*/ adapter: mysql2/" \ sed -e "s/.*adapter:.*/ adapter: mysql2/" \
-e "s/.*username:.*/ username: ${DB_USER}/" \ -e "s/.*username:.*/ username: ${DB_USER}/" \
-e "s/.*password:.*/ password: ${DB_PASS}/" \ -e "s/.*password:.*/ password: ${DB_PASS}/" \
-e "s/.*database:.*/ database: ${DB}/" < ${ZAMMAD_DIR}/config/database.yml.dist > ${ZAMMAD_DIR}/config/database.yml -e "s/.*database:.*/ database: ${DB}/" < ${ZAMMAD_DIR}/config/database.yml.dist > ${ZAMMAD_DIR}/config/database.yml
# sqlite / no local db # sqlite / no local db
elif [ -n "$(which sqlite)" ];then elif [ -n "$(which sqlite)" ];then
echo "installing zammad on sqlite" echo "installing zammad on sqlite"
echo "in fact this does nothing at the moment. use this to install zammad without a local database. sqlite should only be used in dev environment anyway." echo "in fact this does nothing at the moment. use this to install zammad without a local database. sqlite should only be used in dev environment anyway."
fi fi
# fill database # fill database
@ -118,6 +118,18 @@ fi
echo "# Starting Zammad" echo "# Starting Zammad"
${INIT_CMD} start zammad ${INIT_CMD} start zammad
# on centos, allow nginx to connect to application server
if [ -n "$(which setsebool)" ]; then
setsebool httpd_can_network_connect on -P
fi
# on centos, open port 80 and 443
if [ -n "$(which firewall-cmd)" ]; then
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --zone=public --add-port=443/tcp --permanent
firewall-cmd --reload
fi
# copy nginx config # copy nginx config
if [ -n "$(which nginx)" ]; then if [ -n "$(which nginx)" ]; then
# debian / ubuntu # debian / ubuntu
@ -132,12 +144,19 @@ if [ -n "$(which nginx)" ]; then
test -f ${NGINX_CONF} || cp ${ZAMMAD_DIR}/contrib/nginx/zammad.conf ${NGINX_CONF} test -f ${NGINX_CONF} || cp ${ZAMMAD_DIR}/contrib/nginx/zammad.conf ${NGINX_CONF}
fi fi
echo "# Restarting Nginx" echo "restarting Nginx"
${INIT_CMD} restart nginx ${INIT_CMD} restart nginx
echo "create Nginx bootstart"
${INIT_CMD} enable nginx
echo -e "############################################################################################################"
echo -e "\nAdd your FQDN to servername directive in ${NGINX_CONF} and restart nginx if you're not testing localy" echo -e "\nAdd your FQDN to servername directive in ${NGINX_CONF} and restart nginx if you're not testing localy"
echo -e "or open http://localhost in your browser to start using Zammad.\n" echo -e "or open http://localhost in your browser to start using Zammad.\n"
echo -e "############################################################################################################"
else else
echo -e "############################################################################################################"
echo -e "\nOpen http://localhost:3000 in your browser to start using Zammad.\n" echo -e "\nOpen http://localhost:3000 in your browser to start using Zammad.\n"
echo -e "############################################################################################################"
fi fi