Update zabbix-install.sh

Escape Special Characters
This commit is contained in:
tteckster 2024-06-11 13:50:59 -04:00 committed by GitHub
parent 5bc0ddda22
commit fd114369e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 1 deletions

View File

@ -31,7 +31,8 @@ msg_info "Setting up PostgreSQL"
$STD apt-get install -y postgresql $STD apt-get install -y postgresql
DB_NAME=zabbixdb DB_NAME=zabbixdb
DB_USER=zabbix DB_USER=zabbix
DB_PASS="$(openssl rand -base64 18 | cut -c1-13)" RAW_PASS="$(openssl rand -base64 18 | cut -c1-13)"
DB_PASS=$(printf '%s\n' "$RAW_PASS" | sed 's/[&/\]/\\&/g')
$STD sudo -u postgres psql -c "CREATE ROLE $DB_USER WITH LOGIN PASSWORD '$DB_PASS';" $STD sudo -u postgres psql -c "CREATE ROLE $DB_USER WITH LOGIN PASSWORD '$DB_PASS';"
$STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER ENCODING 'UTF8' TEMPLATE template0;" $STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER ENCODING 'UTF8' TEMPLATE template0;"
$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET client_encoding TO 'utf8';" $STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET client_encoding TO 'utf8';"