parent
409894a07d
commit
01e3bef9ca
@ -0,0 +1,48 @@ |
||||
#!/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 |
@ -0,0 +1,17 @@ |
||||
# don't resolve container names to *real* CSC machines |
||||
sed -E '/^(domain|search)[[:space:]]+csclub.uwaterloo.ca/d' /etc/resolv.conf > /tmp/resolv.conf |
||||
cp /tmp/resolv.conf /etc/resolv.conf |
||||
rm /tmp/resolv.conf |
||||
|
||||
get_ip_addr() { |
||||
getent hosts $1 | cut -d' ' -f1 |
||||
} |
||||
|
||||
add_fqdn_to_hosts() { |
||||
ip_addr=$1 |
||||
hostname=$2 |
||||
sed -E "/${ip_addr}.*\\b${hostname}\\b/d" /etc/hosts > /tmp/hosts |
||||
cp /tmp/hosts /etc/hosts |
||||
rm /tmp/hosts |
||||
echo "$ip_addr $hostname.csclub.internal $hostname" >> /etc/hosts |
||||
} |
Loading…
Reference in new issue