51 lines
1.5 KiB
Bash
Executable File
51 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -ex
|
|
|
|
. .drone/common.sh
|
|
|
|
# set FQDN in /etc/hosts
|
|
add_fqdn_to_hosts $(get_ip_addr $(hostname)) coffee
|
|
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
apt update
|
|
|
|
apt install --no-install-recommends -y default-mysql-server postgresql
|
|
|
|
service mysql stop
|
|
sed -E -i 's/^(bind-address[[:space:]]+= 127.0.0.1)$/#\1/' /etc/mysql/mariadb.conf.d/50-server.cnf
|
|
service mysql start
|
|
cat <<EOF | mysql
|
|
CREATE USER 'mysql' IDENTIFIED BY 'mysql';
|
|
GRANT ALL PRIVILEGES ON *.* TO 'mysql' WITH GRANT OPTION;
|
|
EOF
|
|
|
|
service postgresql stop
|
|
POSTGRES_DIR=/etc/postgresql/11/main
|
|
cat <<EOF > $POSTGRES_DIR/pg_hba.conf
|
|
# TYPE DATABASE USER ADDRESS METHOD
|
|
local all postgres peer
|
|
host all postgres 0.0.0.0/0 md5
|
|
|
|
local all all peer
|
|
host all all localhost md5
|
|
|
|
local sameuser all md5
|
|
host sameuser all 0.0.0.0/0 md5
|
|
EOF
|
|
grep -Eq "^listen_addresses = '*'$" $POSTGRES_DIR/postgresql.conf || \
|
|
echo "listen_addresses = '*'" >> $POSTGRES_DIR/postgresql.conf
|
|
service postgresql start
|
|
su -c "
|
|
cat <<EOF | psql
|
|
ALTER USER postgres WITH PASSWORD 'postgres';
|
|
REVOKE ALL ON SCHEMA public FROM public;
|
|
GRANT ALL ON SCHEMA public TO postgres;
|
|
EOF" postgres
|
|
|
|
# sync with phosphoric-acid
|
|
apt install -y netcat-openbsd
|
|
nc -l 0.0.0.0 9000
|
|
|
|
sleep infinity
|