74 lines
2.6 KiB
Bash
Executable File
74 lines
2.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
MATTERMOST_VERSION="9.11.6"
|
|
|
|
# Postgresql
|
|
psql_db_host="10.0.3.147"
|
|
psql_db_port="5432"
|
|
psql_db_name="mattermost"
|
|
psql_db_user="mattermost"
|
|
psql_db_password='C5jzznfvn.-WV6J7-4rgT'
|
|
|
|
POSTGRES_DSN="postgres://${psql_db_user}:${psql_db_password}@${psql_db_host}:${psql_db_port}/${psql_db_name}"
|
|
|
|
# Mysql
|
|
mysql_db_host="10.0.3.147"
|
|
mysql_db_port="3306"
|
|
mysql_db_name="mattermost"
|
|
mysql_db_user="mattermost"
|
|
mysql_db_password='C5jzznfvn%%WV6J7-4rgT'
|
|
|
|
pgloader_bin='/usr/local/src/pgloader/pgloader/build/bin/pgloader'
|
|
|
|
MYSQL_DSN="${mysql_db_user}:${mysql_db_password}@tcp(${mysql_db_host}:${mysql_db_port})/${mysql_db_name}"
|
|
|
|
|
|
echo ""
|
|
|
|
scho -e "\n\tapt purge -y postgresql postgresql-*"
|
|
DEBIAN_FRONTEND=noninteractive apt purge -y postgresql postgresql-*
|
|
|
|
echo -e "\n\trm -rf /var/lib/postgresql"
|
|
rm -rf /var/lib/postgresql
|
|
|
|
echo -e "\n\trm -rf /etc/postgresql"
|
|
rm -rf /etc/postgresql
|
|
|
|
echo -e "\n\trm -rf /var/log/postgresql"
|
|
rm -rf /var/log/postgresql
|
|
|
|
echo -e "\n\tDEBIAN_FRONTEND=noninteractive apt install -y --allow-unauthenticated postgresql"
|
|
DEBIAN_FRONTEND=noninteractive apt install -y --allow-unauthenticated postgresql
|
|
|
|
|
|
echo -e "\n\t"cp -a /etc/postgresql/15/main/pg_hba.conf /etc/postgresql/15/main/pg_hba.conf.ORIG
|
|
cp -a /etc/postgresql/15/main/pg_hba.conf /etc/postgresql/15/main/pg_hba.conf.ORIG
|
|
echo -e "\n\t"cp /root/postgresql_15_main/pg_hba.conf /etc/postgresql/15/main/pg_hba.conf
|
|
cp /root/postgresql_15_main/pg_hba.conf /etc/postgresql/15/main/pg_hba.conf
|
|
|
|
echo -e "\n\t"etc/postgresql/15/main/postgresql.conf /etc/postgresql/15/main/postgresql.conf.ORIG
|
|
cp -a /etc/postgresql/15/main/postgresql.conf /etc/postgresql/15/main/postgresql.conf.ORIG
|
|
echo -e "\n\t"p /root/postgresql_15_main/postgresql.conf /etc/postgresql/15/main/postgresql.conf
|
|
cp /root/postgresql_15_main/postgresql.conf /etc/postgresql/15/main/postgresql.conf
|
|
|
|
echo ""
|
|
|
|
cd /tmp
|
|
sudo -u postgres psql -c "CREATE DATABASE ${psql_db_name};"
|
|
sudo -u postgres psql ${psql_db_name} -c "CREATE USER ${psql_db_user} WITH PASSWORD '${psql_db_password}';"
|
|
sudo -u postgres psql ${psql_db_name} -c "GRANT ALL PRIVILEGES ON DATABASE ${psql_db_name} to ${psql_db_user};"
|
|
sudo -u postgres psql ${psql_db_name} -c "ALTER DATABASE ${psql_db_name} OWNER TO ${psql_db_user};"
|
|
sudo -u postgres psql ${psql_db_name} -c "GRANT USAGE, CREATE ON SCHEMA PUBLIC TO ${psql_db_user};"
|
|
sudo -u postgres psql ${psql_db_name} -c "ALTER SCHEMA public OWNER TO ${psql_db_user};"
|
|
sudo -u postgres psql ${psql_db_name} -c "GRANT ALL ON SCHEMA public to ${psql_db_user};"
|
|
|
|
echo -e "\n\tsystemctl stop postgresql"
|
|
systemctl stop postgresql
|
|
|
|
echo -e "\n\tsystemctl start postgresql"
|
|
systemctl start postgresql
|
|
|
|
echo ""
|
|
exit 0
|
|
|