function genYumInstallScript() { var ver = document.getElementById('version').value; var plat = document.getElementById('platform').value; var arch = document.getElementById('arch').value; if (!plat || plat == -1) { return null; } var shortver = ver.replace('.', ''); var url = 'https://download.postgresql.org/pub/repos/yum/reporpms/' + plat + '-' + arch + '/pgdg-' + get_rpm_prefix(plat) +'-repo-latest.noarch.rpm'; var installer = get_installer(plat); var setupcmd = Number(ver) < 10 ? 'postgresql' + shortver + '-setup' : 'postgresql-' + shortver + '-setup'; var lines = []; lines.push('# Install the repository RPM:'); lines.push(installer + ' install ' + url); lines.push(''); lines.push('# Install client tools:'); lines.push(installer + ' install postgresql' + shortver); lines.push(''); lines.push('# Optionally install the database server:'); lines.push(installer + ' install postgresql' + shortver + '-server'); if (disable_module_on(plat)) { lines.push(''); lines.push('# Disable the built-in PostgreSQL module:'); lines.push('dnf -qy module disable postgresql'); } lines.push(''); lines.push('# Optionally initialize the database and enable automatic start:'); if (uses_systemd(plat)) { lines.push('/usr/pgsql-' + ver + '/bin/' + setupcmd + ' initdb'); lines.push('systemctl enable postgresql-' + ver); lines.push('systemctl start postgresql-' + ver); } else { lines.push('service postgresql-' + ver + ' initdb'); lines.push('chkconfig postgresql-' + ver + ' on'); lines.push('service postgresql-' + ver + ' start'); } return lines.join('\n') + '\n'; } function archChanged() { var text = genYumInstallScript(); $('#scriptbox').text(text || 'Select version and platform above'); $('#scriptcopy').css('display', text ? 'block' : 'none'); }